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

Commit bd67d03

Browse files
linter
1 parent 0c8a5da commit bd67d03

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

vm/chain_vm.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,19 @@ func (vm *VM) ExecutionContext(currTime int64, lastBlock *chain.StatelessBlock)
8989
// compute new block cost
9090
secondsSinceLast := currTime - lastBlock.Tmstmp
9191
nextCost := lastBlock.Cost
92-
if g.BlockCostEnabled {
93-
if secondsSinceLast < g.TargetBlockRate {
94-
nextCost += uint64(g.TargetBlockRate - secondsSinceLast)
92+
if secondsSinceLast < g.TargetBlockRate {
93+
nextCost += uint64(g.TargetBlockRate - secondsSinceLast)
94+
} else {
95+
possibleDiff := uint64(secondsSinceLast - g.TargetBlockRate)
96+
if nextCost >= chain.MinBlockCost && possibleDiff < nextCost-chain.MinBlockCost {
97+
nextCost -= possibleDiff
9598
} else {
96-
possibleDiff := uint64(secondsSinceLast - g.TargetBlockRate)
97-
if nextCost >= chain.MinBlockCost && possibleDiff < nextCost-chain.MinBlockCost {
98-
nextCost -= possibleDiff
99-
} else {
100-
nextCost = chain.MinBlockCost
101-
}
99+
nextCost = chain.MinBlockCost
102100
}
103101
}
102+
if !g.BlockCostEnabled {
103+
nextCost = lastBlock.Cost
104+
}
104105

105106
// compute new min difficulty
106107
nextPrice := lastBlock.Price

0 commit comments

Comments
 (0)