mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Add comparison handling to Block, fix reward type
This commit is contained in:
parent
1b503fd0ab
commit
c6256fe4e1
5 changed files with 83 additions and 6 deletions
|
@ -115,7 +115,7 @@ class JSONRPCDaemon(object):
|
|||
'nonce': bhdr['nonce'],
|
||||
'orphan': bhdr['orphan_status'],
|
||||
'prev_hash': bhdr['prev_hash'],
|
||||
'reward': bhdr['reward'],
|
||||
'reward': from_atomic(bhdr['reward']),
|
||||
'transactions': self.transactions(
|
||||
[bhdr['miner_tx_hash']] + sub_json['tx_hashes']),
|
||||
}
|
||||
|
|
|
@ -25,10 +25,17 @@ class Block(object):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
for k in ('hash', 'height', 'timestamp', 'version', 'difficulty', 'nonce', 'prev_hash', 'reward'):
|
||||
setattr(self, k, kwargs[k])
|
||||
self.orphan = kwargs['orphan']
|
||||
self.transactions = kwargs['transactions']
|
||||
self.blob = kwargs.get('blob', None)
|
||||
setattr(self, k, kwargs.get(k, getattr(self, k)))
|
||||
self.orphan = kwargs.get('orphan', self.orphan)
|
||||
self.transactions = kwargs.get('transactions', self.transactions or [])
|
||||
self.blob = kwargs.get('blob', self.blob)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Block):
|
||||
return self.hash == other.hash
|
||||
elif isinstance(other, six.string_types):
|
||||
return six.ensure_text(self.hash) == six.ensure_text(other)
|
||||
return super(Block, self).__eq__(other)
|
||||
|
||||
def __contains__(self, tx):
|
||||
if isinstance(tx, six.string_types):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue