Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fc27671da
|
||
|
|
8f86e9c970
|
||
|
|
abc619d7b2
|
||
|
|
42aa809500
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ build/
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
*.sqlite
|
*.sqlite
|
||||||
.coverage
|
.coverage
|
||||||
|
.chaind
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ from chainqueue.cache import CacheTokenTx
|
|||||||
from chainlib.encode import TxHexNormalizer
|
from chainlib.encode import TxHexNormalizer
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from chaind.adapters.fs import ChaindFsAdapter
|
from chaind.adapters.fs import ChaindFsAdapter
|
||||||
|
from chaind.dispatch import DispatchProcessor
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chaind.eth.dispatch import EthDispatcher
|
|
||||||
from chaind.eth.cache import EthCacheTx
|
from chaind.eth.cache import EthCacheTx
|
||||||
from chaind.eth.settings import ChaindEthSettings
|
from chaind.eth.settings import ChaindEthSettings
|
||||||
|
from chaind.eth.dispatch import EthDispatcher
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@@ -66,49 +67,16 @@ settings.process(config)
|
|||||||
|
|
||||||
logg.debug('settings:\n{}'.format(settings))
|
logg.debug('settings:\n{}'.format(settings))
|
||||||
|
|
||||||
|
|
||||||
def process_outgoing(chain_spec, adapter, rpc, limit=50):
|
|
||||||
adapter = None
|
|
||||||
process_err = None
|
|
||||||
for i in range(2):
|
|
||||||
try:
|
|
||||||
adapter = ChaindFsAdapter(
|
|
||||||
settings.get('CHAIN_SPEC'),
|
|
||||||
settings.dir_for('queue'),
|
|
||||||
EthCacheTx,
|
|
||||||
dispatcher,
|
|
||||||
)
|
|
||||||
except BackendIntegrityError as e:
|
|
||||||
process_err = e
|
|
||||||
continue
|
|
||||||
|
|
||||||
if adapter == None:
|
|
||||||
raise BackendIntegrityError(process_err)
|
|
||||||
|
|
||||||
upcoming = adapter.upcoming(limit=limit)
|
|
||||||
logg.info('processor has {} candidates for {}, processing with limit {} adapter {} rpc {}'.format(len(upcoming), chain_spec, limit, adapter, rpc))
|
|
||||||
i = 0
|
|
||||||
for tx_hash in upcoming:
|
|
||||||
if adapter.dispatch(tx_hash):
|
|
||||||
i += 1
|
|
||||||
return i
|
|
||||||
|
|
||||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
|
||||||
|
|
||||||
rpc = chainlib.eth.cli.Rpc()
|
rpc = chainlib.eth.cli.Rpc()
|
||||||
conn = rpc.connect_by_config(config)
|
conn = rpc.connect_by_config(config)
|
||||||
|
|
||||||
tx_normalizer = TxHexNormalizer().tx_hash
|
tx_normalizer = TxHexNormalizer().tx_hash
|
||||||
token_cache_store = CacheTokenTx(chain_spec, normalizer=tx_normalizer)
|
token_cache_store = CacheTokenTx(settings.get('CHAIN_SPEC'), normalizer=tx_normalizer)
|
||||||
dispatcher = EthDispatcher(conn)
|
|
||||||
queue_adapter = ChaindFsAdapter(
|
dispatcher = EthDispatcher(conn)
|
||||||
settings.get('CHAIN_SPEC'),
|
processor = DispatchProcessor(settings.get('CHAIN_SPEC'), settings.dir_for('queue'), dispatcher)
|
||||||
settings.dir_for('queue'),
|
ctrl = SessionController(settings, processor.process)
|
||||||
EthCacheTx,
|
|
||||||
dispatcher,
|
|
||||||
)
|
|
||||||
|
|
||||||
ctrl = SessionController(settings, queue_adapter, process_outgoing)
|
|
||||||
signal.signal(signal.SIGINT, ctrl.shutdown)
|
signal.signal(signal.SIGINT, ctrl.shutdown)
|
||||||
signal.signal(signal.SIGTERM, ctrl.shutdown)
|
signal.signal(signal.SIGTERM, ctrl.shutdown)
|
||||||
|
|
||||||
@@ -134,6 +102,14 @@ def main():
|
|||||||
ctrl.process(conn)
|
ctrl.process(conn)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
queue_adapter = ChaindFsAdapter(
|
||||||
|
settings.get('CHAIN_SPEC'),
|
||||||
|
settings.dir_for('queue'),
|
||||||
|
EthCacheTx,
|
||||||
|
dispatcher,
|
||||||
|
store_sync=False,
|
||||||
|
)
|
||||||
|
|
||||||
result_data = None
|
result_data = None
|
||||||
r = 0 # no error
|
r = 0 # no error
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ def main():
|
|||||||
m = GasTokenResolver
|
m = GasTokenResolver
|
||||||
token_resolver = m(chain_spec, rpc.get_sender_address(), rpc.get_signer(), rpc.get_gas_oracle(), rpc.get_nonce_oracle())
|
token_resolver = m(chain_spec, rpc.get_sender_address(), rpc.get_signer(), rpc.get_gas_oracle(), rpc.get_nonce_oracle())
|
||||||
|
|
||||||
processor = Processor(token_resolver, config.get('_SOURCE'))
|
processor = Processor(token_resolver, config.get('_SOURCE'), use_checksum=not config.get('_UNSAFE'))
|
||||||
processor.add_processor(CSVProcessor())
|
processor.add_processor(CSVProcessor())
|
||||||
|
|
||||||
sends = None
|
sends = None
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import logging
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from chaind.error import TxSourceError
|
from chaind.error import TxSourceError
|
||||||
from chainlib.eth.address import is_checksum_address
|
from chainlib.eth.address import (
|
||||||
|
is_checksum_address,
|
||||||
|
to_checksum_address,
|
||||||
|
)
|
||||||
from chainlib.eth.tx import unpack
|
from chainlib.eth.tx import unpack
|
||||||
from chainlib.eth.gas import Gas
|
from chainlib.eth.gas import Gas
|
||||||
from hexathon import (
|
from hexathon import (
|
||||||
@@ -17,10 +20,11 @@ logg = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class Processor:
|
class Processor:
|
||||||
|
|
||||||
def __init__(self, resolver, source):
|
def __init__(self, resolver, source, use_checksum=True):
|
||||||
self.resolver = resolver
|
self.resolver = resolver
|
||||||
self.source = source
|
self.source = source
|
||||||
self.processor = []
|
self.processor = []
|
||||||
|
self.safe = use_checksum
|
||||||
self.conn = None
|
self.conn = None
|
||||||
|
|
||||||
|
|
||||||
@@ -50,9 +54,14 @@ class Processor:
|
|||||||
txs = []
|
txs = []
|
||||||
for i, r in enumerate(self.content):
|
for i, r in enumerate(self.content):
|
||||||
logg.debug('processing {}'.format(r))
|
logg.debug('processing {}'.format(r))
|
||||||
if not is_checksum_address(r[0]):
|
address = r[0]
|
||||||
raise ValueError('invalid checksum address {} in record {}'.format(r[0], i))
|
if self.safe:
|
||||||
self.content[i][0] = add_0x(r[0])
|
if not is_checksum_address(address):
|
||||||
|
raise ValueError('invalid checksum address {} in record {}'.format(address, i))
|
||||||
|
else:
|
||||||
|
address = to_checksum_address(address)
|
||||||
|
|
||||||
|
self.content[i][0] = add_0x(address)
|
||||||
try:
|
try:
|
||||||
self.content[i][1] = int(r[1])
|
self.content[i][1] = int(r[1])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
chaind~=0.2.0
|
chaind~=0.2.7
|
||||||
hexathon~=0.1.5
|
hexathon~=0.1.6
|
||||||
chainlib-eth~=0.1.1
|
chainlib-eth~=0.1.2
|
||||||
pyxdg~=0.27
|
pyxdg~=0.27
|
||||||
shep~=0.2.3
|
shep~=0.2.5
|
||||||
funga-eth~=0.6.0
|
funga-eth~=0.6.1
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = chaind-eth
|
name = chaind-eth
|
||||||
version = 0.2.0
|
version = 0.2.6
|
||||||
description = Queue server for ethereum
|
description = Queue server for ethereum
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from chainlib.chain import ChainSpec
|
|||||||
from chainqueue.cache import CacheTokenTx
|
from chainqueue.cache import CacheTokenTx
|
||||||
from chainlib.error import RPCException
|
from chainlib.error import RPCException
|
||||||
from chainlib.status import Status as TxStatus
|
from chainlib.status import Status as TxStatus
|
||||||
from chaind.unittest.common import TestChaindFsBase
|
from chaind.unittest.fs import TestChaindFsBase
|
||||||
from chaind.driver import QueueDriver
|
from chaind.driver import QueueDriver
|
||||||
from chaind.filter import StateFilter
|
from chaind.filter import StateFilter
|
||||||
from chainlib.eth.gas import Gas
|
from chainlib.eth.gas import Gas
|
||||||
|
|||||||
Reference in New Issue
Block a user