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

Commit 52a2ab8

Browse files
vubvub
authored andcommitted
Added starting account nonce feature
1 parent 19f562e commit 52a2ab8

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ethereum/blocks.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -852,15 +852,10 @@ def increment_nonce(self, address):
852852
:param address: the address of the account (binary or hex string)
853853
:returns: `True` if successful, otherwise `False`
854854
"""
855-
return self._delta_item(address, 'nonce', 1)
856-
857-
def decrement_nonce(self, address):
858-
"""Decrement the nonce of an account.
859-
860-
:param address: the address of the account (binary or hex string)
861-
:returns: `True` if successful, otherwise `False`
862-
"""
863-
return self._delta_item(address, 'nonce', -1)
855+
if self.get_nonce(address) == 0:
856+
return self._delta_item(address, 'nonce', self.config['STARTING_ACCT_NONCE'] + 1)
857+
else:
858+
return self._delta_item(address, 'nonce', 1)
864859

865860
def get_balance(self, address):
866861
"""Get the balance of an account.

ethereum/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
MAX_EXTRADATA_LENGTH=32,
4141
# Exponential difficulty timebomb period
4242
EXPDIFF_PERIOD=100000,
43-
EXPDIFF_FREE_PERIODS=2
43+
EXPDIFF_FREE_PERIODS=2,
44+
# Starting nonce
45+
STARTING_ACCT_NONCE=0
4446
)
4547
assert default_config['NEPHEW_REWARD'] == \
4648
default_config['BLOCK_REWARD'] // 32

0 commit comments

Comments
 (0)