diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-08-17 20:01:41 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-09-22 02:33:28 +0800 |
commit | eaa4473dbd4ad404b85f8f0f63b0418a782351b4 (patch) | |
tree | 27eabb671346c279969caafe28d25a44aef0f9a0 /core/genesis.go | |
parent | 12c0afe4fe9f284dd10a80af7744102dac8bf06b (diff) | |
download | go-tangerine-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar.gz go-tangerine-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.tar.zst go-tangerine-eaa4473dbd4ad404b85f8f0f63b0418a782351b4.zip |
core, core/types: readd transactions after chain re-org
Added a `Difference` method to `types.Transactions` which sets the
receiver to the difference of a to b (NOTE: not a **and** b).
Transaction pool subscribes to RemovedTransactionEvent adding back to
those potential missing from the chain.
When a chain re-org occurs remove any transactions that were removed
from the canonical chain during the re-org as well as the receipts that
were generated in the process.
Closes #1746
Diffstat (limited to 'core/genesis.go')
-rw-r--r-- | core/genesis.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/core/genesis.go b/core/genesis.go index 727e2c75f..b2346da65 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -125,15 +125,27 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big return block } -func WriteGenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block { +type GenesisAccount struct { + Address common.Address + Balance *big.Int +} + +func WriteGenesisBlockForTesting(db ethdb.Database, accounts ...GenesisAccount) *types.Block { + accountJson := "{" + for i, account := range accounts { + if i != 0 { + accountJson += "," + } + accountJson += fmt.Sprintf(`"0x%x":{"balance":"0x%x"}`, account.Address, account.Balance.Bytes()) + } + accountJson += "}" + testGenesis := fmt.Sprintf(`{ "nonce":"0x%x", "gasLimit":"0x%x", "difficulty":"0x%x", - "alloc": { - "0x%x":{"balance":"0x%x"} - } -}`, types.EncodeNonce(0), params.GenesisGasLimit.Bytes(), params.GenesisDifficulty.Bytes(), addr, balance.Bytes()) + "alloc": %s +}`, types.EncodeNonce(0), params.GenesisGasLimit.Bytes(), params.GenesisDifficulty.Bytes(), accountJson) block, _ := WriteGenesisBlock(db, strings.NewReader(testGenesis)) return block } |