cmd/hivechain: use GetBalance() method for tx generation#462
Merged
fjl merged 10 commits intoethereum:masterfrom Apr 8, 2021
Merged
cmd/hivechain: use GetBalance() method for tx generation#462fjl merged 10 commits intoethereum:masterfrom
fjl merged 10 commits intoethereum:masterfrom
Conversation
fjl
reviewed
Mar 29, 2021
| if gbal.Sub(gbal, spent).Cmp(txCost) < 0 { | ||
| continue // no funds left in this account | ||
| if gen.GetBalance(addr).Cmp(txCost) > 0 { | ||
| tx := generateTx(txType, key, &cfg.genesis, gen) |
Collaborator
There was a problem hiding this comment.
You can do it better by always creating the tx, then comparing against tx.Cost()
fjl
reviewed
Mar 30, 2021
| gopkg.in/yaml.v2 v2.3.0 | ||
| ) | ||
|
|
||
| replace github.com/ethereum/go-ethereum => github.com/renaynay/go-ethereum v1.9.12-0.20210326162836-ac99fed7c3f0 |
fjl
reviewed
Mar 30, 2021
| // check tx count to make sure it doesn't exceed max, set to max if exceeds | ||
| if cfg.txCount > 2000 { | ||
| cfg.txCount = 2000 | ||
| } |
Collaborator
There was a problem hiding this comment.
I think the limit here is not necessary. But the generator should check if enough gas is available in the block to add the transaction. That way, the limit would be enforced by the block gas limit instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is dependent on this PR to add a
GetBalance()method to block generation in geth, and now allows the hivechain tool to generate chains with a given number of transactions per block (capped at 2000 @todo this is arbitrary, should we increase the cap?) instead of just 1.