11from queue import Queue
22from threading import Thread
3- from collections import OrderedDict
43from readerwriterlock import rwlock
54
65from teos .logger import get_logger
@@ -44,7 +43,7 @@ class LocatorCache:
4443 logger (:obj:`Logger <teos.logger.Logger>`): The logger for this component.
4544 cache (:obj:`dict`): A dictionary of ``locator:dispute_txid`` pairs that received appointments are checked
4645 against.
47- blocks (:obj:`OrderedDict `): An ordered dictionary of the last ``blocks_in_cache`` blocks
46+ blocks (:obj:`dict `): An ordered dictionary of the last ``blocks_in_cache`` blocks
4847 (``block_hash:locators``). Used to keep track of what data belongs to what block, so data can be pruned
4948 accordingly. Also needed to rebuild the cache in case of reorgs.
5049 cache_size (:obj:`int`): The size of the cache in blocks.
@@ -54,7 +53,7 @@ class LocatorCache:
5453 def __init__ (self , blocks_in_cache ):
5554 self .logger = get_logger (component = LocatorCache .__name__ )
5655 self .cache = dict ()
57- self .blocks = OrderedDict ()
56+ self .blocks = dict ()
5857 self .cache_size = blocks_in_cache
5958 self .rw_lock = rwlock .RWLockWrite ()
6059
@@ -85,7 +84,7 @@ def init(self, last_known_block, block_processor):
8584 self .blocks [target_block_hash ] = list (locator_txid_map .keys ())
8685 target_block_hash = target_block .get ("previousblockhash" )
8786
88- self .blocks = OrderedDict (reversed ((list (self .blocks .items ()))))
87+ self .blocks = dict (reversed ((list (self .blocks .items ()))))
8988
9089 def get_txid (self , locator ):
9190 """
@@ -159,7 +158,7 @@ def fix(self, last_known_block, block_processor):
159158 target_block_hash = target_block .get ("previousblockhash" )
160159
161160 with self .rw_lock .gen_wlock ():
162- self .blocks = OrderedDict (reversed ((list (tmp_cache .blocks .items ()))))
161+ self .blocks = dict (reversed ((list (tmp_cache .blocks .items ()))))
163162 self .cache = tmp_cache .cache
164163
165164
0 commit comments