From: ThomasV Date: Thu, 14 Jun 2012 19:03:01 +0000 (+0400) Subject: add sql limit to config X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=commitdiff_plain;h=58c5d73cb2503b5fb7d08f091565de10d4d9b9a1 add sql limit to config --- diff --git a/backends/abe/__init__.py b/backends/abe/__init__.py index 4b94e86..d34cf28 100644 --- a/backends/abe/__init__.py +++ b/backends/abe/__init__.py @@ -10,7 +10,6 @@ from Queue import Queue import time, threading -SQL_LIMIT=500 class AbeStore(Datastore_class): @@ -27,6 +26,8 @@ class AbeStore(Datastore_class): Datastore_class.__init__(self,args) + self.sql_limit = config.get('database','limit') + self.tx_cache = {} self.bitcoind_url = 'http://%s:%s@%s:%s/' % ( config.get('bitcoind','user'), config.get('bitcoind','password'), config.get('bitcoind','host'), config.get('bitcoind','port')) @@ -151,9 +152,9 @@ class AbeStore(Datastore_class): JOIN pubkey ON (pubkey.pubkey_id = prevout.pubkey_id) WHERE pubkey.pubkey_hash = ? AND cc.in_longest = 1 - LIMIT ? """, (dbhash,SQL_LIMIT)) + LIMIT ? """, (dbhash,self.sql_limit)) - if len(out)==SQL_LIMIT: + if len(out)==self.sql_limit: raise BaseException('limit reached') return out @@ -169,9 +170,9 @@ class AbeStore(Datastore_class): JOIN txout prevout ON (txin.txout_id = prevout.txout_id) JOIN pubkey ON (pubkey.pubkey_id = prevout.pubkey_id) WHERE pubkey.pubkey_hash = ? - LIMIT ? """, (dbhash,SQL_LIMIT)) + LIMIT ? """, (dbhash,self.sql_limit)) - if len(out)==SQL_LIMIT: + if len(out)==self.sql_limit: raise BaseException('limit reached') return out @@ -194,9 +195,9 @@ class AbeStore(Datastore_class): JOIN pubkey ON (pubkey.pubkey_id = txout.pubkey_id) WHERE pubkey.pubkey_hash = ? AND cc.in_longest = 1 - LIMIT ? """, (dbhash,SQL_LIMIT)) + LIMIT ? """, (dbhash,self.sql_limit)) - if len(out)==SQL_LIMIT: + if len(out)==self.sql_limit: raise BaseException('limit reached') return out @@ -211,9 +212,9 @@ class AbeStore(Datastore_class): JOIN txout ON (txout.tx_id = tx.tx_id) JOIN pubkey ON (pubkey.pubkey_id = txout.pubkey_id) WHERE pubkey.pubkey_hash = ? - LIMIT ? """, (dbhash,SQL_LIMIT)) + LIMIT ? """, (dbhash,self.sql_limit)) - if len(out)==SQL_LIMIT: + if len(out)==self.sql_limit: raise BaseException('limit reached') return out diff --git a/server.py b/server.py index c636c0c..1250a5e 100755 --- a/server.py +++ b/server.py @@ -42,6 +42,7 @@ def create_config(): config.add_section('database') config.set('database', 'type', 'psycopg2') config.set('database', 'database', 'abe') + config.set('database', 'limit', '500') config.set('server', 'backend', 'abe') for path in ('/etc/', ''):