aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-20 07:33:52 +0800
committerzelig <viktor.tron@gmail.com>2015-03-20 18:41:41 +0800
commitd7564a9a25c06f0c9ad9440f02b09e20e0ca30bc (patch)
tree351e6660b9d70a2badb4a010eccf76357ecf6dd7
parent8987750a369e4906f8d5301473cd4df8433177f3 (diff)
downloaddexon-d7564a9a25c06f0c9ad9440f02b09e20e0ca30bc.tar.gz
dexon-d7564a9a25c06f0c9ad9440f02b09e20e0ca30bc.tar.zst
dexon-d7564a9a25c06f0c9ad9440f02b09e20e0ca30bc.zip
fix common.Hash conversion
-rw-r--r--blockpool/peers.go2
-rw-r--r--blockpool/peers_test.go4
-rw-r--r--blockpool/section.go2
3 files changed, 5 insertions, 3 deletions
diff --git a/blockpool/peers.go b/blockpool/peers.go
index 1ace01fdf..80168b206 100644
--- a/blockpool/peers.go
+++ b/blockpool/peers.go
@@ -7,6 +7,7 @@ import (
"sync"
"time"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/errs"
)
@@ -471,6 +472,7 @@ func (self *peer) getBlockHashes() {
}
}
headKey := self.parentHash.Str()
+ height := self.bp.status.chain[headKey] + 1
self.bp.status.chain[self.currentBlockHash.Str()] = height
if height > self.bp.status.values.LongestChain {
self.bp.status.values.LongestChain = height
diff --git a/blockpool/peers_test.go b/blockpool/peers_test.go
index 0e4c40e87..beeb0ad1d 100644
--- a/blockpool/peers_test.go
+++ b/blockpool/peers_test.go
@@ -170,8 +170,8 @@ func TestPeerPromotionByOptionalTdOnBlock(t *testing.T) {
hashes := blockPoolTester.hashPool.IndexesToHashes([]int{2, 3})
peer1.waitBlocksRequests(3)
blockPool.AddBlock(&types.Block{
- HeaderHash: common.Bytes(hashes[1]),
- ParentHeaderHash: common.Bytes(hashes[0]),
+ HeaderHash: common.Hash(hashes[1]),
+ ParentHeaderHash: common.Hash(hashes[0]),
Td: common.Big3,
}, "peer1")
diff --git a/blockpool/section.go b/blockpool/section.go
index 0304c9a04..18a27377d 100644
--- a/blockpool/section.go
+++ b/blockpool/section.go
@@ -117,7 +117,7 @@ func (self *section) addSectionToBlockChain(p *peer) {
break
}
self.poolRootIndex--
- keys = append(keys, node.hash.Str())
+ keys = append(keys, n.hash.Str())
blocks = append(blocks, block)
nodes = append(nodes, n)
}