diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-08 23:37:06 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-08 23:37:06 +0800 |
commit | b25126a277da5253e4ce175dec5b68ccdf1b9b0f (patch) | |
tree | ea076157ad8304145228f2483ba3c955fa646120 | |
parent | db4aaedcbdb409e17ea3de161e7b24a80ba0a58c (diff) | |
download | dexon-b25126a277da5253e4ce175dec5b68ccdf1b9b0f.tar dexon-b25126a277da5253e4ce175dec5b68ccdf1b9b0f.tar.gz dexon-b25126a277da5253e4ce175dec5b68ccdf1b9b0f.tar.bz2 dexon-b25126a277da5253e4ce175dec5b68ccdf1b9b0f.tar.lz dexon-b25126a277da5253e4ce175dec5b68ccdf1b9b0f.tar.xz dexon-b25126a277da5253e4ce175dec5b68ccdf1b9b0f.tar.zst dexon-b25126a277da5253e4ce175dec5b68ccdf1b9b0f.zip |
Minor fixed and additions for block proc
* Path check length
* Genesis include TD
* Output TD on last block
-rw-r--r-- | core/chain_manager.go | 4 | ||||
-rw-r--r-- | core/genesis.go | 1 | ||||
-rw-r--r-- | ethutil/path.go | 2 | ||||
-rw-r--r-- | ethutil/rlp.go | 2 |
4 files changed, 5 insertions, 4 deletions
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{}) diff --git a/ethutil/path.go b/ethutil/path.go index f64e3849e..e545c8731 100644 --- a/ethutil/path.go +++ b/ethutil/path.go @@ -12,7 +12,7 @@ func ExpandHomePath(p string) (path string) { path = p // Check in case of paths like "/something/~/something/" - if path[:2] == "~/" { + if len(path) > 1 && path[:2] == "~/" { usr, _ := user.Current() dir := usr.HomeDir diff --git a/ethutil/rlp.go b/ethutil/rlp.go index 1bc1a58a7..0cb0d611c 100644 --- a/ethutil/rlp.go +++ b/ethutil/rlp.go @@ -137,7 +137,7 @@ func Encode(object interface{}) []byte { case byte: buff.Write(Encode(big.NewInt(int64(t)))) case *big.Int: - // Not sure how this is possible while we check for + // Not sure how this is possible while we check for nil if t == nil { buff.WriteByte(0xc0) } else { |