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

Commit c8d0777

Browse files
committed
initialize head_candidate and pep8
1 parent c8669e2 commit c8d0777

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

ethereum/blocks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def calc_difficulty(parent, timestamp):
100100

101101

102102
class Account(rlp.Serializable):
103+
103104
"""An Ethereum account.
104105
105106
:ivar nonce: the account's nonce (the number of transactions sent by the
@@ -172,6 +173,7 @@ def bloom(self):
172173

173174

174175
class BlockHeader(rlp.Serializable):
176+
175177
"""A block header.
176178
177179
If the block with this header exists as an instance of :class:`Block`, the
@@ -306,7 +308,7 @@ def hex_hash(self):
306308
@property
307309
def mining_hash(self):
308310
return utils.sha3(rlp.encode(self,
309-
BlockHeader.exclude(['mixhash', 'nonce'])))
311+
BlockHeader.exclude(['mixhash', 'nonce'])))
310312

311313
@property
312314
def seed(self):
@@ -405,6 +407,7 @@ def setter(self, value):
405407
set(['state_root', 'receipts_root', 'tx_list_root']),
406408
only_getters=False)
407409
class Block(rlp.Serializable):
410+
408411
"""A block.
409412
410413
All attributes from the block header are accessible via properties
@@ -563,7 +566,7 @@ def must_le(what, a, b):
563566
"database" % self)
564567
if (not self.is_genesis() and self.nonce and not self.header.check_pow()):
565568
raise ValueError("PoW check failed")
566-
self.db.put('validated:'+self.hash, '1')
569+
self.db.put('validated:' + self.hash, '1')
567570

568571
@classmethod
569572
def init_from_header(cls, header_rlp, db):
@@ -1351,7 +1354,7 @@ def get_block(db, blockhash):
13511354
return CachedBlock.create_cached(blk)
13521355

13531356

1354-
#def has_block(blockhash):
1357+
# def has_block(blockhash):
13551358
# return blockhash in db.DB(utils.get_db_path())
13561359

13571360

ethereum/chain.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,19 @@ class Chain(object):
9696
:ivar head_candidate: the block which if mined by our miner would become
9797
the new head
9898
"""
99+
head_candidate = None
99100

100101
def __init__(self, db, genesis=None, new_head_cb=None, coinbase='\x00' * 20):
101102
self.db = self.blockchain = db
102103
self.new_head_cb = new_head_cb
103104
self.index = Index(db)
104-
self.head_candidate = None
105105
self._coinbase = coinbase
106106
if genesis:
107107
self._initialize_blockchain(genesis)
108108
log.debug('chain @', head_hash=self.head)
109109
self.genesis = blocks.genesis(db=db)
110110
log.debug('got genesis', genesis_hash=self.genesis)
111+
self._update_head_candidate()
111112

112113
def _initialize_blockchain(self, genesis=None):
113114
log.info('Initializing new chain')

0 commit comments

Comments
 (0)