diff --git a/electrumx/server/controller.py b/electrumx/server/controller.py index 9144664..45d198c 100644 --- a/electrumx/server/controller.py +++ b/electrumx/server/controller.py @@ -99,7 +99,7 @@ class Controller(ServerBase): BlockProcessor = env.coin.BLOCK_PROCESSOR self.bp = BlockProcessor(env, self.tasks, daemon, notifications) self.mempool = MemPool(env.coin, self.tasks, daemon, notifications, - self.bp.db_utxo_lookup) + self.bp.lookup_utxos) self.chain_state = ChainState(env, self.tasks, daemon, self.bp, notifications) self.peer_mgr = PeerManager(env, self.tasks, self.chain_state) diff --git a/electrumx/server/db.py b/electrumx/server/db.py index 3ee5103..8b5ec0b 100644 --- a/electrumx/server/db.py +++ b/electrumx/server/db.py @@ -35,9 +35,6 @@ class DB(object): DB_VERSIONS = [6] - class MissingUTXOError(Exception): - '''Raised if a mempool tx input UTXO couldn't be found.''' - class DBError(Exception): '''Raised on general DB errors generally indicating corruption.''' @@ -399,43 +396,52 @@ class DB(object): tx_hash, height = self.fs_tx_hash(tx_num) yield UTXO(tx_num, tx_pos, tx_hash, height, value) - def db_utxo_lookup(self, tx_hash, tx_idx): - '''Given a prevout return a (hashX, value) pair. + async def lookup_utxos(self, prevouts): + '''For each prevout, lookup it up in the DB and return a (hashX, + value) pair or None if not found. - Raises MissingUTXOError if the UTXO is not found. Used by the - mempool code. + Used by the mempool code. ''' - idx_packed = pack('