Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Commit e2e17b2

Browse files
committed
Got rid of OrderedDict #233
1 parent daa9d8d commit e2e17b2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

teos/watcher.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from queue import Queue
22
from threading import Thread
3-
from collections import OrderedDict
43
from readerwriterlock import rwlock
54

65
from 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

Comments
 (0)