walker bugfix

This commit is contained in:
Tim
2024-04-04 00:00:43 -04:00
parent 34359155e1
commit 9103bf4214
3 changed files with 3 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ from dexorder.blockstate import current_blockstate
from dexorder.blockstate.branch import Branch
from dexorder.blockstate.fork import Fork, current_fork
from dexorder.blockstate.state import FinalizedBlockState
from dexorder.base.block import Block, BlockInfo
from dexorder.base.block import Block, BlockInfo, latest_block
from dexorder.progressor import BlockProgressor
from dexorder.util.async_util import Maywaitable
@@ -69,6 +69,7 @@ class BlockWalker (BlockProgressor):
try:
latest_blockdata: BlockInfo = await w3.eth.get_block('latest')
latest = Block(chain_id, latest_blockdata)
latest_block[chain_id] = latest
if prev_height is None or latest.height > prev_height:
prev_height = latest.height
log.debug(f'polled new block {latest.height}')
@@ -83,7 +84,7 @@ class BlockWalker (BlockProgressor):
self.flush_type=='blocks' and last_flush + self.flush_delay <= processed_height or \
self.flush_type=='time' and last_flush + self.flush_delay <= now():
if self.flush_callback is not None:
self.flush_callback()
await self.flush_callback()
# flush height to db
db.kv[kv_key] = cur_height
if self.flush_type=='blocks':