diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-15 21:42:12 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-15 21:42:12 +0800 |
commit | 33a0dec8a157b9687ca6038f4deb011f3f1f7bdc (patch) | |
tree | 197b792e06dc3952df93957a39fdf6e44582ac96 /ethchain/state_manager.go | |
parent | 2f614900e82036e3e8f6f6a714efc43e09aca830 (diff) | |
download | go-tangerine-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar go-tangerine-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.gz go-tangerine-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.bz2 go-tangerine-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.lz go-tangerine-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.xz go-tangerine-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.zst go-tangerine-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.zip |
Improved catching up and refactored
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r-- | ethchain/state_manager.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index a165ed79d..1ccaa560f 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -217,13 +217,13 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) { return err } - // I'm not sure, but I don't know if there should be thrown - // any errors at this time. if err = sm.AccumelateRewards(state, block, parent); err != nil { statelogger.Errorln("Error accumulating reward", err) return err } + state.Update() + if !block.State().Cmp(state) { err = fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().Trie.Root, state.Trie.Root) return @@ -335,7 +335,7 @@ func (sm *StateManager) ValidateBlock(block *Block) error { } func (sm *StateManager) AccumelateRewards(state *ethstate.State, block, parent *Block) error { - reward := new(big.Int) + reward := new(big.Int).Set(BlockReward) knownUncles := ethutil.Set(parent.Uncles) nonces := ethutil.NewSet(block.Nonce) @@ -358,6 +358,8 @@ func (sm *StateManager) AccumelateRewards(state *ethstate.State, block, parent * return UncleError("Uncle in chain") } + nonces.Insert(uncle.Nonce) + r := new(big.Int) r.Mul(BlockReward, big.NewInt(15)).Div(r, big.NewInt(16)) |