aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-06 15:53:00 +0800
committerobscuren <geffobscura@gmail.com>2014-08-06 15:53:00 +0800
commitda50c751480da32036f41ccbeb1f292694ca0286 (patch)
treed83eb84c684d0c86d4fcdc20b8acb525b8f923de /ethchain
parent4edf7cfb0543555921a79f572c749615c4997ea7 (diff)
downloaddexon-da50c751480da32036f41ccbeb1f292694ca0286.tar.gz
dexon-da50c751480da32036f41ccbeb1f292694ca0286.tar.zst
dexon-da50c751480da32036f41ccbeb1f292694ca0286.zip
Added state dump method
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/block_chain.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go
index 736fe52c7..3eba90fca 100644
--- a/ethchain/block_chain.go
+++ b/ethchain/block_chain.go
@@ -290,7 +290,6 @@ func (bc *BlockChain) setLastBlock() {
data, _ := ethutil.Config.Db.Get([]byte("LastBlock"))
if len(data) != 0 {
block := NewBlockFromBytes(data)
- //info := bc.BlockInfo(block)
bc.CurrentBlock = block
bc.LastBlockHash = block.Hash()
bc.LastBlockNumber = block.Number.Uint64()
@@ -301,9 +300,6 @@ func (bc *BlockChain) setLastBlock() {
bc.genesisBlock.state.Trie.Sync()
// Prepare the genesis block
bc.Add(bc.genesisBlock)
-
- //chainlogger.Infof("root %x\n", bm.bc.genesisBlock.State().Root)
- //bm.bc.genesisBlock.PrintHash()
}
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
@@ -339,6 +335,18 @@ func (bc *BlockChain) GetBlock(hash []byte) *Block {
return NewBlockFromBytes(data)
}
+func (self *BlockChain) GetBlockByNumber(num uint64) *Block {
+ block := self.CurrentBlock
+ for ; block.Number.Uint64() != num; block = self.GetBlock(block.PrevHash) {
+ }
+
+ if block.Number.Uint64() == 0 && num != 0 {
+ return nil
+ }
+
+ return block
+}
+
func (bc *BlockChain) BlockInfoByHash(hash []byte) BlockInfo {
bi := BlockInfo{}
data, _ := ethutil.Config.Db.Get(append(hash, []byte("Info")...))