@@ -74,7 +74,7 @@ def calc_difficulty(parent, timestamp):
74
74
period_count = (parent .number + 1 ) // config ['EXPDIFF_PERIOD' ]
75
75
if period_count >= config ['EXPDIFF_FREE_PERIODS' ]:
76
76
o = max (o + 2 ** (period_count - config ['EXPDIFF_FREE_PERIODS' ]), config ['MIN_DIFF' ])
77
- # print 'Calculating difficulty of block %d, timestamp difference %d, parent diff %d, child diff %d' % (parent.number + 1, timestamp - parent.timestamp, parent.difficulty, o)
77
+ # print( 'Calculating difficulty of block %d, timestamp difference %d, parent diff %d, child diff %d' % (parent.number + 1, timestamp - parent.timestamp, parent.difficulty, o) )
78
78
return o
79
79
80
80
@@ -676,8 +676,8 @@ def validate_uncles(self):
676
676
return False
677
677
if uncle .prevhash not in eligible_ancestor_hashes :
678
678
log .error ("Uncle does not have a valid ancestor" , block = self ,
679
- eligible = [x . encode ( 'hex' ) for x in eligible_ancestor_hashes ],
680
- uncle_prevhash = uncle .prevhash . encode ( 'hex' ))
679
+ eligible = [encode_hex ( x ) for x in eligible_ancestor_hashes ],
680
+ uncle_prevhash = encode_hex ( uncle .prevhash ))
681
681
return False
682
682
if uncle in ineligible :
683
683
log .error ("Duplicate uncle" , block = self ,
@@ -1035,7 +1035,7 @@ def commit_state(self):
1035
1035
# except:
1036
1036
# pass
1037
1037
# sys.stderr.write("pre: %r\n" % self.account_to_dict(addr)['storage'])
1038
- # sys.stderr.write("pre: %r\n" % self.get_storage(addr).root_hash.encode('hex' ))
1038
+ # sys.stderr.write("pre: %r\n" % encode_hex( self.get_storage(addr).root_hash))
1039
1039
# sys.stderr.write("changed: %s %s %s\n" % (encode_hex(addr), encode_hex(enckey), encode_hex(val)))
1040
1040
if v :
1041
1041
t .update (enckey , val )
@@ -1168,11 +1168,12 @@ def finalize(self):
1168
1168
self .delta_balance (self .coinbase , delta )
1169
1169
self .ether_delta += delta
1170
1170
1171
+ br = self .config ['BLOCK_REWARD' ]
1172
+ udpf = self .config ['UNCLE_DEPTH_PENALTY_FACTOR' ]
1173
+
1171
1174
for uncle in self .uncles :
1172
- r = self .config ['BLOCK_REWARD' ] * \
1173
- (self .config ['UNCLE_DEPTH_PENALTY_FACTOR' ] + uncle .number - self .number ) \
1174
- / self .config ['UNCLE_DEPTH_PENALTY_FACTOR' ]
1175
- r = int (r )
1175
+ r = int (br * (udpf + uncle .number - self .number ) // udpf )
1176
+
1176
1177
self .delta_balance (uncle .coinbase , r )
1177
1178
self .ether_delta += r
1178
1179
self .commit_state ()
@@ -1307,7 +1308,7 @@ def calc_gaslimit(parent):
1307
1308
1308
1309
def check_gaslimit (parent , gas_limit ):
1309
1310
config = parent .config
1310
- # block.gasLimit - parent.gasLimit <= parent.gasLimit / GasLimitBoundDivisor
1311
+ # block.gasLimit - parent.gasLimit <= parent.gasLimit // GasLimitBoundDivisor
1311
1312
gl = parent .gas_limit // config ['GASLIMIT_ADJMAX_FACTOR' ]
1312
1313
a = bool (abs (gas_limit - parent .gas_limit ) <= gl )
1313
1314
b = bool (gas_limit >= config ['MIN_GAS_LIMIT' ])
0 commit comments