aboutsummaryrefslogtreecommitdiffstats
path: root/block_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-05 19:32:47 +0800
committerobscuren <geffobscura@gmail.com>2014-12-05 19:32:47 +0800
commitd80f8bda940a8ae8f6dab1502a46054c06cee5cc (patch)
tree3397c3d58bcef44840de4098c23d5ef93056a7f3 /block_pool.go
parent3cf0477c21376b16492cb0b8705b9c7b951e2fb8 (diff)
downloaddexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.gz
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.zst
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.zip
Fixed issue in VM where LOG didn't pop anything of the stack
Diffstat (limited to 'block_pool.go')
-rw-r--r--block_pool.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/block_pool.go b/block_pool.go
index 595400c79..02eb65d47 100644
--- a/block_pool.go
+++ b/block_pool.go
@@ -99,11 +99,7 @@ func (self *BlockPool) FetchHashes(peer *Peer) bool {
self.td = peer.td
if !self.HasLatestHash() {
- peer.doneFetchingHashes = false
-
- const amount = 256
- peerlogger.Debugf("Fetching hashes (%d) %x...\n", amount, peer.lastReceivedHash[0:4])
- peer.QueueMessage(wire.NewMessage(wire.MsgGetBlockHashesTy, []interface{}{peer.lastReceivedHash, uint32(amount)}))
+ self.fetchHashes()
}
return true
@@ -112,6 +108,16 @@ func (self *BlockPool) FetchHashes(peer *Peer) bool {
return false
}
+func (self *BlockPool) fetchHashes() {
+ peer := self.peer
+
+ peer.doneFetchingHashes = false
+
+ const amount = 256
+ peerlogger.Debugf("Fetching hashes (%d) %x...\n", amount, peer.lastReceivedHash[0:4])
+ peer.QueueMessage(wire.NewMessage(wire.MsgGetBlockHashesTy, []interface{}{peer.lastReceivedHash, uint32(amount)}))
+}
+
func (self *BlockPool) AddHash(hash []byte, peer *Peer) {
self.mut.Lock()
defer self.mut.Unlock()
@@ -259,6 +265,13 @@ out:
self.ChainLength = len(self.hashes)
}
+ if self.peer != nil &&
+ !self.peer.doneFetchingHashes &&
+ time.Since(self.peer.lastHashAt) > 10*time.Second &&
+ time.Since(self.peer.lastHashRequestedAt) > 5*time.Second {
+ self.fetchHashes()
+ }
+
/*
if !self.fetchingHashes {
blocks := self.Blocks()