Handle ethtester return values in historysyncer driver getter and process
This commit is contained in:
parent
7b3cf46732
commit
2400084251
@ -3,14 +3,19 @@ import uuid
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import signal
|
import signal
|
||||||
|
import json
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
import sqlalchemy
|
|
||||||
from chainlib.eth.block import (
|
from chainlib.eth.block import (
|
||||||
block_by_number,
|
block_by_number,
|
||||||
Block,
|
Block,
|
||||||
)
|
)
|
||||||
from chainlib.eth.tx import receipt
|
from chainlib.eth.tx import (
|
||||||
|
receipt,
|
||||||
|
transaction,
|
||||||
|
Tx,
|
||||||
|
)
|
||||||
|
from chainlib.error import JSONRPCException
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chainsyncer.filter import SyncFilter
|
from chainsyncer.filter import SyncFilter
|
||||||
@ -129,13 +134,19 @@ class HeadSyncer(BlockPollSyncer):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
tx = block.tx(i)
|
tx = block.tx(i)
|
||||||
|
except AttributeError:
|
||||||
|
o = transaction(block.txs[i])
|
||||||
|
r = conn.do(o)
|
||||||
|
tx = Tx(Tx.src_normalize(r), block=block)
|
||||||
except IndexError as e:
|
except IndexError as e:
|
||||||
logg.debug('index error syncer rcpt get {}'.format(e))
|
logg.debug('index error syncer rcpt get {}'.format(e))
|
||||||
self.backend.set(block.number + 1, 0)
|
self.backend.set(block.number + 1, 0)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# TODO: Move specifics to eth subpackage, receipts are not a global concept
|
||||||
rcpt = conn.do(receipt(tx.hash))
|
rcpt = conn.do(receipt(tx.hash))
|
||||||
tx.apply_receipt(rcpt)
|
if rcpt != None:
|
||||||
|
tx.apply_receipt(Tx.src_normalize(rcpt))
|
||||||
|
|
||||||
self.process_single(conn, block, tx)
|
self.process_single(conn, block, tx)
|
||||||
self.backend.reset_filter()
|
self.backend.reset_filter()
|
||||||
@ -180,9 +191,13 @@ class HistorySyncer(HeadSyncer):
|
|||||||
block_number = height[0]
|
block_number = height[0]
|
||||||
block_hash = []
|
block_hash = []
|
||||||
o = block_by_number(block_number)
|
o = block_by_number(block_number)
|
||||||
|
try:
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
|
# TODO: Disambiguate whether error is temporary or permanent, if permanent, SyncDone should be raised, because a historical sync is attempted into the future
|
||||||
|
except JSONRPCException:
|
||||||
|
r = None
|
||||||
if r == None:
|
if r == None:
|
||||||
raise NoBlockForYou()
|
raise SyncDone() #NoBlockForYou()
|
||||||
b = Block(r)
|
b = Block(r)
|
||||||
|
|
||||||
return b
|
return b
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# standard imports
|
# standard imports
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# external imports
|
|
||||||
import sqlalchemy
|
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from .error import BackendError
|
from .error import BackendError
|
||||||
|
|
||||||
@ -12,8 +9,7 @@ logg = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class SyncFilter:
|
class SyncFilter:
|
||||||
|
|
||||||
def __init__(self, backend, safe=True):
|
def __init__(self, backend):
|
||||||
self.safe = safe
|
|
||||||
self.filters = []
|
self.filters = []
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
|
|
||||||
@ -30,7 +26,7 @@ class SyncFilter:
|
|||||||
session = None
|
session = None
|
||||||
try:
|
try:
|
||||||
session = self.backend.connect()
|
session = self.backend.connect()
|
||||||
except sqlalchemy.exc.TimeoutError as e:
|
except TimeoutError as e:
|
||||||
self.backend.disconnect()
|
self.backend.disconnect()
|
||||||
raise BackendError('database connection fail: {}'.format(e))
|
raise BackendError('database connection fail: {}'.format(e))
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
confini~=0.3.6rc3
|
confini~=0.3.6rc3
|
||||||
semver==2.13.0
|
semver==2.13.0
|
||||||
hexathon~=0.0.1a7
|
hexathon~=0.0.1a7
|
||||||
chainlib~=0.0.2a6
|
chainlib~=0.0.2a15
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = chainsyncer
|
name = chainsyncer
|
||||||
version = 0.0.2a2
|
version = 0.0.2a3
|
||||||
description = Generic blockchain syncer driver
|
description = Generic blockchain syncer driver
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
Loading…
Reference in New Issue
Block a user