diff options
author | obscuren <geffobscura@gmail.com> | 2014-08-21 20:47:58 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-08-21 20:47:58 +0800 |
commit | eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb (patch) | |
tree | 9a0c4c4b1bda39560c70147c73862d72eff38dd1 /ethchain | |
parent | 79c64f6bca4fcfb257496be22c64f4b2faed7050 (diff) | |
download | go-tangerine-eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb.tar go-tangerine-eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb.tar.gz go-tangerine-eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb.tar.bz2 go-tangerine-eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb.tar.lz go-tangerine-eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb.tar.xz go-tangerine-eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb.tar.zst go-tangerine-eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb.zip |
PoC 6 networking code.
* Added block pool for gathering blocks from the network (chunks)
* Re wrote syncing
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/block_chain.go | 20 | ||||
-rw-r--r-- | ethchain/genesis.go | 6 |
2 files changed, 24 insertions, 2 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go index 611735707..3445bbb87 100644 --- a/ethchain/block_chain.go +++ b/ethchain/block_chain.go @@ -208,6 +208,26 @@ func (bc *BlockChain) GenesisBlock() *Block { return bc.genesisBlock } +func (self *BlockChain) GetChainHashesFromHash(hash []byte, max uint64) (chain [][]byte) { + block := self.GetBlock(hash) + if block == nil { + return + } + + // XXX Could be optimised by using a different database which only holds hashes (i.e., linked list) + for i := uint64(0); i < max; i++ { + chain = append(chain, block.Hash()) + + if block.Number.Cmp(ethutil.Big0) <= 0 { + break + } + + block = self.GetBlock(block.PrevHash) + } + + return +} + // Get chain return blocks from hash up to max in RLP format func (bc *BlockChain) GetChainFromHash(hash []byte, max uint64) []interface{} { var chain []interface{} diff --git a/ethchain/genesis.go b/ethchain/genesis.go index 54a3bc766..0ce53a6ee 100644 --- a/ethchain/genesis.go +++ b/ethchain/genesis.go @@ -1,9 +1,10 @@ package ethchain import ( + "math/big" + "github.com/ethereum/eth-go/ethcrypto" "github.com/ethereum/eth-go/ethutil" - "math/big" ) /* @@ -26,7 +27,8 @@ var GenesisHeader = []interface{}{ // tx sha "", // Difficulty - ethutil.BigPow(2, 22), + //ethutil.BigPow(2, 22), + big.NewInt(4096), // Number ethutil.Big0, // Block minimum gas price |