Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 4a0be79

Browse files
author
Jan Xie
committed
fix get_block, add has_blockhash to chain
1 parent 6fe134b commit 4a0be79

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ethereum/casper_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def get_finalizer_code():
5555
casper_config['HOMESTEAD_FORK_BLKNUM'] = 0
5656
casper_config['METROPOLIS_FORK_BLKNUM'] = 0
5757
casper_config['SERENITY_FORK_BLKNUM'] = 0
58+
# config['CASPER_ADDR'] == config['SERENITY_HEADER_VERIFIER']
5859
casper_config['CASPER_ADDR'] = utils.int_to_addr(255)
5960
casper_config['RLP_DECODER_ADDR'] = utils.int_to_addr(253)
6061
casper_config['HASH_WITHOUT_BLOOM_ADDR'] = utils.int_to_addr(252)

ethereum/chain.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ def get_parent(self, block):
131131

132132
def get_block(self, blockhash):
133133
try:
134-
return rlp.decode(self.db.get(blockhash), Block)
134+
block_rlp = self.db.get(blockhash)
135+
if block_rlp == 'GENESIS':
136+
return self.genesis
137+
else:
138+
return rlp.decode(block_rlp, Block)
135139
except:
136140
return None
137141

@@ -312,6 +316,9 @@ def __contains__(self, blk):
312316
def has_block(self, block):
313317
return block in self
314318

319+
def has_blockhash(self, blockhash):
320+
return blockhash in self.db
321+
315322
def get_chain(self, frm=None, to=2**63 - 1):
316323
if frm is None:
317324
frm = int(self.db.get('GENESIS_NUMBER')) + 1

0 commit comments

Comments
 (0)