Minor fixed and additions for block proc

* Path check length
* Genesis include TD
* Output TD on last block
pull/245/head^2
obscuren 10 years ago
parent db4aaedcbd
commit b25126a277
  1. 4
      core/chain_manager.go
  2. 1
      core/genesis.go
  3. 2
      ethutil/path.go
  4. 2
      ethutil/rlp.go

@ -139,7 +139,7 @@ func (bc *ChainManager) setLastBlock() {
bc.Reset() 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 // Block creation & chain handling
@ -215,7 +215,7 @@ func (bc *ChainManager) insert(block *types.Block) {
func (bc *ChainManager) write(block *types.Block) { func (bc *ChainManager) write(block *types.Block) {
bc.writeBlockInfo(block) bc.writeBlockInfo(block)
encodedBlock := ethutil.Encode(block) encodedBlock := ethutil.Encode(block.RlpDataForStorage())
bc.db.Put(block.Hash(), encodedBlock) bc.db.Put(block.Hash(), encodedBlock)
} }

@ -25,6 +25,7 @@ func GenesisBlock(db ethutil.Database) *types.Block {
genesis.Header().GasLimit = big.NewInt(1000000) genesis.Header().GasLimit = big.NewInt(1000000)
genesis.Header().GasUsed = ethutil.Big0 genesis.Header().GasUsed = ethutil.Big0
genesis.Header().Time = 0 genesis.Header().Time = 0
genesis.Td = ethutil.Big0
genesis.SetUncles([]*types.Header{}) genesis.SetUncles([]*types.Header{})
genesis.SetTransactions(types.Transactions{}) genesis.SetTransactions(types.Transactions{})

@ -12,7 +12,7 @@ func ExpandHomePath(p string) (path string) {
path = p path = p
// Check in case of paths like "/something/~/something/" // Check in case of paths like "/something/~/something/"
if path[:2] == "~/" { if len(path) > 1 && path[:2] == "~/" {
usr, _ := user.Current() usr, _ := user.Current()
dir := usr.HomeDir dir := usr.HomeDir

@ -137,7 +137,7 @@ func Encode(object interface{}) []byte {
case byte: case byte:
buff.Write(Encode(big.NewInt(int64(t)))) buff.Write(Encode(big.NewInt(int64(t))))
case *big.Int: 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 { if t == nil {
buff.WriteByte(0xc0) buff.WriteByte(0xc0)
} else { } else {

Loading…
Cancel
Save