commit 748542cb0be1675682e84d7117e38511b81f938d
parent a0790619e9203736dd66171ab50e41cc62a594a6
Author: lash <dev@holbrook.no>
Date: Tue, 8 Mar 2022 09:56:15 +0000
Rehabilitate to chaintool release candidates
Diffstat:
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/eth_stat_syncer/runnable/tracker.py b/eth_stat_syncer/runnable/tracker.py
@@ -7,15 +7,22 @@ import argparse
# external imports
import confini
from chainsyncer.backend.memory import MemBackend
-from chainsyncer.driver import (
- HeadSyncer,
- HistorySyncer,
- )
+from chainsyncer.driver.head import HeadSyncer
+from chainsyncer.driver.history import HistorySyncer
from chainsyncer.filter import SyncFilter
from chainsyncer.error import NoBlockForYou
from chainlib.chain import ChainSpec
from chainlib.eth.connection import EthHTTPConnection
-from chainlib.eth.block import block_latest
+from chainlib.interface import ChainInterface
+from chainlib.eth.block import (
+ block_by_number,
+ Block,
+ block_latest,
+ )
+from chainlib.eth.tx import (
+ receipt,
+ Tx,
+ )
# local imports
from eth_stat_syncer.store import (
@@ -70,6 +77,15 @@ class GasPriceFilter(SyncFilter):
self.gas_aggregator.put(tx.gas_price)
+class EthChainInterface(ChainInterface):
+
+ def __init__(self):
+ self._block_by_number = block_by_number
+ self._block_from_src = Block.from_src
+ self._tx_receipt = receipt
+ self._src_normalize = Tx.src_normalize
+
+
def main():
gas_store = RunStore(basedir=config.get('STORE_BASE_DIR'))
gas_aggregator = GasAggregator(gas_store, 360)
@@ -81,11 +97,12 @@ def main():
start_block = n
logg.info('block height at start {}'.format(start_block))
+ chain_interface = EthChainInterface()
if config.get('_START') != None:
offset = start_block - config.get('_START')
- syncer_backend = MemBackend(chain_spec, None, target_block=start_block)
+ syncer_backend = MemBackend.custom(chain_spec, start_block)
syncer_backend.set(offset, 0)
- syncer = HistorySyncer(syncer_backend, block_callback=gas_aggregator.block_callback)
+ syncer = HistorySyncer(syncer_backend, chain_interface, block_callback=gas_aggregator.block_callback)
syncer.add_filter(gas_filter)
try:
syncer.loop(0.0, conn)
@@ -94,7 +111,7 @@ def main():
syncer_backend = MemBackend(chain_spec, None)
syncer_backend.set(start_block + 1, 0)
- syncer = HeadSyncer(syncer_backend, block_callback=gas_aggregator.block_callback)
+ syncer = HeadSyncer(syncer_backend, chain_interface, block_callback=gas_aggregator.block_callback)
syncer.add_filter(gas_filter)
syncer.loop(1.0, conn)
diff --git a/requirements.txt b/requirements.txt
@@ -1,3 +1,3 @@
-chainsyncer~=0.0.2a3
-chainlib~=0.0.3a1
-jsonrpc_std~=0.0.1a2
+chainsyncer~=0.2.0
+chainlib-eth>=0.1.0b1,<=0.1.0
+jsonrpc_std~=0.1.0