Make block by number compatible with geth
This commit is contained in:
parent
7f2c32975d
commit
1efc936085
@ -1,5 +1,8 @@
|
||||
- 0.0.23:
|
||||
* Make get block args and responses compatible with picky golang marhaling in geth
|
||||
- 0.0.22:
|
||||
* Enable unpack of pre EIP-155 transactions
|
||||
* Allow missing status property of receipts in non-strict modes
|
||||
- 0.0.21:
|
||||
* Remove warnings from cytoolz/rlp in funga-eth
|
||||
- 0.0.15:
|
||||
|
@ -4,7 +4,7 @@ from chainlib.block import Block as BaseBlock
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
even,
|
||||
compact,
|
||||
)
|
||||
|
||||
# local imports
|
||||
@ -34,7 +34,9 @@ def block_by_hash(hsh, include_tx=True, id_generator=None):
|
||||
def block_by_number(n, include_tx=True, id_generator=None):
|
||||
"""Implements chainlib.interface.ChainInterface method
|
||||
"""
|
||||
nhx = add_0x(even(hex(n)[2:]))
|
||||
hx = strip_0x(hex(n))
|
||||
nhx = add_0x(compact(hx), compact_value=True)
|
||||
print('>>>>> hx {}'.format(hx))
|
||||
j = JSONRPCRequest(id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_getBlockByNumber'
|
||||
|
@ -105,7 +105,10 @@ def main():
|
||||
|
||||
o = block_latest(id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
n = int(r, 16)
|
||||
try:
|
||||
n = int(r, 16)
|
||||
except ValueError:
|
||||
n = int(r)
|
||||
first_block_number = n
|
||||
if human:
|
||||
n = format(n, ',')
|
||||
|
@ -519,7 +519,7 @@ class Tx(BaseTx):
|
||||
#:todo: divide up constructor method
|
||||
"""
|
||||
|
||||
def __init__(self, src, block=None, rcpt=None):
|
||||
def __init__(self, src, block=None, rcpt=None, strict=False):
|
||||
self.__rcpt_block_hash = None
|
||||
|
||||
src = self.src_normalize(src)
|
||||
@ -575,7 +575,7 @@ class Tx(BaseTx):
|
||||
self.logs = None
|
||||
|
||||
if rcpt != None:
|
||||
self.apply_receipt(rcpt)
|
||||
self.apply_receipt(rcpt, strict=strict)
|
||||
|
||||
self.v = src.get('v')
|
||||
self.r = src.get('r')
|
||||
@ -618,7 +618,7 @@ class Tx(BaseTx):
|
||||
return self.src()
|
||||
|
||||
|
||||
def apply_receipt(self, rcpt):
|
||||
def apply_receipt(self, rcpt, strict=False):
|
||||
"""Apply receipt data to transaction object.
|
||||
|
||||
Effect is the same as passing a receipt at construction.
|
||||
@ -642,6 +642,12 @@ class Tx(BaseTx):
|
||||
status_number = int(rcpt['status'], 16)
|
||||
except TypeError:
|
||||
status_number = int(rcpt['status'])
|
||||
except KeyError as e:
|
||||
if strict:
|
||||
raise(e)
|
||||
logg.warning('setting "sucess" status on missing status property for {}'.format(self.hash))
|
||||
status_number = 1
|
||||
|
||||
if rcpt['block_number'] == None:
|
||||
self.status = Status.PENDING
|
||||
else:
|
||||
@ -696,12 +702,12 @@ class Tx(BaseTx):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def from_src(src, block=None, rcpt=None):
|
||||
def from_src(src, block=None, rcpt=None, strict=False):
|
||||
"""Creates a new Tx object.
|
||||
|
||||
Alias of constructor.
|
||||
"""
|
||||
return Tx(src, block=block, rcpt=rcpt)
|
||||
return Tx(src, block=block, rcpt=rcpt, strict=strict)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
|
@ -1,6 +1,6 @@
|
||||
funga-eth~=0.5.3
|
||||
pysha3==1.0.2
|
||||
hexathon~=0.1.1
|
||||
hexathon~=0.1.2
|
||||
websocket-client==0.57.0
|
||||
potaahto~=0.1.0
|
||||
chainlib~=0.0.17
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = chainlib-eth
|
||||
version = 0.0.22
|
||||
version = 0.0.23
|
||||
description = Ethereum implementation of the chainlib interface
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
@ -48,4 +48,3 @@ console_scripts =
|
||||
eth-info = chainlib.eth.runnable.info:main
|
||||
eth-nonce = chainlib.eth.runnable.count:main
|
||||
eth-wait = chainlib.eth.runnable.wait:main
|
||||
eth = chainlib.eth.runnable.info:main
|
||||
|
Loading…
Reference in New Issue
Block a user