From b25126a277da5253e4ce175dec5b68ccdf1b9b0f Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 8 Jan 2015 16:37:06 +0100 Subject: Minor fixed and additions for block proc * Path check length * Genesis include TD * Output TD on last block --- core/chain_manager.go | 4 ++-- core/genesis.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/chain_manager.go b/core/chain_manager.go index 2d4001f0f..5ff3b88c9 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -139,7 +139,7 @@ func (bc *ChainManager) setLastBlock() { bc.Reset() } - chainlogger.Infof("Last block (#%d) %x\n", bc.lastBlockNumber, bc.currentBlock.Hash()) + chainlogger.Infof("Last block (#%d) %x TD=%v\n", bc.lastBlockNumber, bc.currentBlock.Hash(), bc.td) } // Block creation & chain handling @@ -215,7 +215,7 @@ func (bc *ChainManager) insert(block *types.Block) { func (bc *ChainManager) write(block *types.Block) { bc.writeBlockInfo(block) - encodedBlock := ethutil.Encode(block) + encodedBlock := ethutil.Encode(block.RlpDataForStorage()) bc.db.Put(block.Hash(), encodedBlock) } diff --git a/core/genesis.go b/core/genesis.go index 1590818a8..d9edaace2 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -25,6 +25,7 @@ func GenesisBlock(db ethutil.Database) *types.Block { genesis.Header().GasLimit = big.NewInt(1000000) genesis.Header().GasUsed = ethutil.Big0 genesis.Header().Time = 0 + genesis.Td = ethutil.Big0 genesis.SetUncles([]*types.Header{}) genesis.SetTransactions(types.Transactions{}) -- cgit v1.2.3 From e27237a03a3f0ab8dce37705701ed73de252e1f4 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 8 Jan 2015 16:45:51 +0100 Subject: Changed to use hash for comparison DeepReflect would fail on TD since TD isn't included in the original block and thus the test would fail. --- core/chain_manager_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index b384c4926..5bbc2db70 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -1,6 +1,7 @@ package core import ( + "bytes" "fmt" "os" "path" @@ -76,11 +77,11 @@ func TestChainInsertions(t *testing.T) { <-done } - if reflect.DeepEqual(chain2[len(chain2)-1], chainMan.CurrentBlock()) { + if bytes.Equal(chain2[len(chain2)-1].Hash(), chainMan.CurrentBlock().Hash()) { t.Error("chain2 is canonical and shouldn't be") } - if !reflect.DeepEqual(chain1[len(chain1)-1], chainMan.CurrentBlock()) { + if !bytes.Equal(chain1[len(chain1)-1].Hash(), chainMan.CurrentBlock().Hash()) { t.Error("chain1 isn't canonical and should be") } } -- cgit v1.2.3 From 5f958a582d1326ada1cb34b4c6578590a7c40e6c Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 8 Jan 2015 16:48:39 +0100 Subject: fixed other tests to use hashes as well --- core/chain_manager_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'core') diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index 5bbc2db70..725352daf 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path" - "reflect" "runtime" "strconv" "testing" @@ -125,7 +124,7 @@ func TestChainMultipleInsertions(t *testing.T) { <-done } - if !reflect.DeepEqual(chains[longest][len(chains[longest])-1], chainMan.CurrentBlock()) { + if !bytes.Equal(chains[longest][len(chains[longest])-1].Hash(), chainMan.CurrentBlock().Hash()) { t.Error("Invalid canonical chain") } } -- cgit v1.2.3