diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-19 19:25:52 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-19 19:25:52 +0800 |
commit | 14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6 (patch) | |
tree | 7d8b81beb6285eab7dfc8772b35f1d9d8ce1b186 /chain/chain_manager.go | |
parent | 437d79f09418b24693b4e3fc4d2f88e291b5340f (diff) | |
download | dexon-14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6.tar dexon-14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6.tar.gz dexon-14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6.tar.bz2 dexon-14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6.tar.lz dexon-14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6.tar.xz dexon-14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6.tar.zst dexon-14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6.zip |
Added `chain` tests & minor fixes
* Fork tests (equal and larger chains)
* `chain.link` fields are now exported
* moved debug function from state to dump.go
Diffstat (limited to 'chain/chain_manager.go')
-rw-r--r-- | chain/chain_manager.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/chain/chain_manager.go b/chain/chain_manager.go index 970fa5377..11e16fa7d 100644 --- a/chain/chain_manager.go +++ b/chain/chain_manager.go @@ -191,8 +191,8 @@ func (self *ChainManager) GetBlock(hash []byte) *types.Block { if self.workingChain != nil { // Check the temp chain for e := self.workingChain.Front(); e != nil; e = e.Next() { - if bytes.Compare(e.Value.(*link).block.Hash(), hash) == 0 { - return e.Value.(*link).block + if bytes.Compare(e.Value.(*link).Block.Hash(), hash) == 0 { + return e.Value.(*link).Block } } } @@ -275,15 +275,15 @@ func (self *ChainManager) InsertChain(chain *BlockChain, call func(*types.Block, for e := chain.Front(); e != nil; e = e.Next() { link := e.Value.(*link) - self.add(link.block) - self.SetTotalDifficulty(link.td) + self.add(link.Block) + self.SetTotalDifficulty(link.Td) - call(link.block, link.messages) + call(link.Block, link.Messages) } b, e := chain.Front(), chain.Back() if b != nil && e != nil { - front, back := b.Value.(*link).block, e.Value.(*link).block + front, back := b.Value.(*link).Block, e.Value.(*link).Block chainlogger.Infof("Imported %d blocks. #%v (%x) / %#v (%x)", chain.Len(), front.Number, front.Hash()[0:4], back.Number, back.Hash()[0:4]) } } @@ -295,7 +295,7 @@ func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error) for e := chain.Front(); e != nil; e = e.Next() { var ( l = e.Value.(*link) - block = l.block + block = l.Block parent = self.GetBlock(block.PrevHash) ) @@ -314,8 +314,8 @@ func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error) err = fmt.Errorf("incoming chain failed %v\n", err) return } - l.td = td - l.messages = messages + l.Td = td + l.Messages = messages } if td.Cmp(self.TD) <= 0 { @@ -329,9 +329,9 @@ func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error) } type link struct { - block *types.Block - messages state.Messages - td *big.Int + Block *types.Block + Messages state.Messages + Td *big.Int } type BlockChain struct { @@ -351,7 +351,7 @@ func NewChain(blocks types.Blocks) *BlockChain { func (self *BlockChain) RlpEncode() []byte { dat := make([]interface{}, 0) for e := self.Front(); e != nil; e = e.Next() { - dat = append(dat, e.Value.(*link).block.RlpData()) + dat = append(dat, e.Value.(*link).Block.RlpData()) } return ethutil.Encode(dat) |