Compare commits

...

2 Commits

Author SHA1 Message Date
lash
212b06ea5c
Bump version 2022-03-08 09:56:44 +00:00
lash
748542cb0b
Rehabilitate to chaintool release candidates 2022-03-08 09:56:15 +00:00
3 changed files with 29 additions and 12 deletions

View File

@ -7,15 +7,22 @@ import argparse
# external imports # external imports
import confini import confini
from chainsyncer.backend.memory import MemBackend from chainsyncer.backend.memory import MemBackend
from chainsyncer.driver import ( from chainsyncer.driver.head import HeadSyncer
HeadSyncer, from chainsyncer.driver.history import HistorySyncer
HistorySyncer,
)
from chainsyncer.filter import SyncFilter from chainsyncer.filter import SyncFilter
from chainsyncer.error import NoBlockForYou from chainsyncer.error import NoBlockForYou
from chainlib.chain import ChainSpec from chainlib.chain import ChainSpec
from chainlib.eth.connection import EthHTTPConnection 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 # local imports
from eth_stat_syncer.store import ( from eth_stat_syncer.store import (
@ -70,6 +77,15 @@ class GasPriceFilter(SyncFilter):
self.gas_aggregator.put(tx.gas_price) 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(): def main():
gas_store = RunStore(basedir=config.get('STORE_BASE_DIR')) gas_store = RunStore(basedir=config.get('STORE_BASE_DIR'))
gas_aggregator = GasAggregator(gas_store, 360) gas_aggregator = GasAggregator(gas_store, 360)
@ -81,11 +97,12 @@ def main():
start_block = n start_block = n
logg.info('block height at start {}'.format(start_block)) logg.info('block height at start {}'.format(start_block))
chain_interface = EthChainInterface()
if config.get('_START') != None: if config.get('_START') != None:
offset = start_block - config.get('_START') 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_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) syncer.add_filter(gas_filter)
try: try:
syncer.loop(0.0, conn) syncer.loop(0.0, conn)
@ -94,7 +111,7 @@ def main():
syncer_backend = MemBackend(chain_spec, None) syncer_backend = MemBackend(chain_spec, None)
syncer_backend.set(start_block + 1, 0) 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.add_filter(gas_filter)
syncer.loop(1.0, conn) syncer.loop(1.0, conn)

View File

@ -1,3 +1,3 @@
chainsyncer~=0.0.2a3 chainsyncer~=0.2.0
chainlib~=0.0.3a1 chainlib-eth>=0.1.0b1,<=0.1.0
jsonrpc_std~=0.0.1a2 jsonrpc_std~=0.1.0

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = eth-stat-syncer name = eth-stat-syncer
version = 0.0.1a3 version = 0.1.0
description = Cache live EVM blockchain stats description = Cache live EVM blockchain stats
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no