本文整理汇总了Golang中github.com/piotrnar/gocoin/lib/btc.Block.LastKnownHeight方法的典型用法代码示例。如果您正苦于以下问题:Golang Block.LastKnownHeight方法的具体用法?Golang Block.LastKnownHeight怎么用?Golang Block.LastKnownHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/piotrnar/gocoin/lib/btc.Block
的用法示例。
在下文中一共展示了Block.LastKnownHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: get_blocks
func get_blocks() {
var bl *btc.Block
DlStartTime = time.Now()
BlocksMutex.Lock()
BlocksComplete = TheBlockChain.BlockTreeEnd.Height
CurrentBlockHeight := BlocksComplete + 1
BlocksMutex.Unlock()
TheBlockChain.DoNotSync = true
tickSec := time.Tick(time.Second)
tickDrop := time.Tick(DROP_PEER_EVERY_SEC * time.Second)
tickStat := time.Tick(6 * time.Second)
for !GlobalExit() && CurrentBlockHeight <= LastBlockHeight {
select {
case <-tickSec:
cc := open_connection_count()
if cc > MaxNetworkConns {
drop_slowest_peers()
} else if cc < MaxNetworkConns {
add_new_connections()
}
case <-tickStat:
print_stats()
usif_prompt()
case <-tickDrop:
if open_connection_count() >= MaxNetworkConns {
drop_slowest_peers()
}
case bl = <-BlockQueue:
bl.Trusted = CurrentBlockHeight <= TrustUpTo
if OnlyStoreBlocks {
TheBlockChain.Blocks.BlockAdd(CurrentBlockHeight, bl)
} else {
er, _, _ := TheBlockChain.CheckBlock(bl)
if er != nil {
fmt.Println("CheckBlock:", er.Error())
return
} else {
bl.LastKnownHeight = CurrentBlockHeight + uint32(len(BlockQueue))
TheBlockChain.AcceptBlock(bl)
}
}
atomic.StoreUint32(&LastStoredBlock, CurrentBlockHeight)
atomic.AddUint64(&DlBytesProcessed, uint64(len(bl.Raw)))
CurrentBlockHeight++
case <-time.After(100 * time.Millisecond):
COUNTER("IDLE")
TheBlockChain.Unspent.Idle()
}
}
TheBlockChain.Sync()
}