1
1
from queue import Queue
2
2
from threading import Thread
3
- from collections import OrderedDict
4
3
from readerwriterlock import rwlock
5
4
6
5
from teos .logger import get_logger
@@ -44,7 +43,7 @@ class LocatorCache:
44
43
logger (:obj:`Logger <teos.logger.Logger>`): The logger for this component.
45
44
cache (:obj:`dict`): A dictionary of ``locator:dispute_txid`` pairs that received appointments are checked
46
45
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
48
47
(``block_hash:locators``). Used to keep track of what data belongs to what block, so data can be pruned
49
48
accordingly. Also needed to rebuild the cache in case of reorgs.
50
49
cache_size (:obj:`int`): The size of the cache in blocks.
@@ -54,7 +53,7 @@ class LocatorCache:
54
53
def __init__ (self , blocks_in_cache ):
55
54
self .logger = get_logger (component = LocatorCache .__name__ )
56
55
self .cache = dict ()
57
- self .blocks = OrderedDict ()
56
+ self .blocks = dict ()
58
57
self .cache_size = blocks_in_cache
59
58
self .rw_lock = rwlock .RWLockWrite ()
60
59
@@ -85,7 +84,7 @@ def init(self, last_known_block, block_processor):
85
84
self .blocks [target_block_hash ] = list (locator_txid_map .keys ())
86
85
target_block_hash = target_block .get ("previousblockhash" )
87
86
88
- self .blocks = OrderedDict (reversed ((list (self .blocks .items ()))))
87
+ self .blocks = dict (reversed ((list (self .blocks .items ()))))
89
88
90
89
def get_txid (self , locator ):
91
90
"""
@@ -159,7 +158,7 @@ def fix(self, last_known_block, block_processor):
159
158
target_block_hash = target_block .get ("previousblockhash" )
160
159
161
160
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 ()))))
163
162
self .cache = tmp_cache .cache
164
163
165
164
0 commit comments