Commit 8f8ae28f authored by caopingcp's avatar caopingcp

tendermint wait block

parent 95a394d8
......@@ -567,17 +567,20 @@ func (client *Client) CommitBlock(block *types.Block) error {
// WaitBlock by height
func (client *Client) WaitBlock(height int64) bool {
retry := 0
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
beg := time.Now()
for {
select {
case <-ticker.C:
tendermintlog.Info("Still waiting block......", "height", height, "cost", time.Since(beg))
default:
newHeight, err := client.getLastHeight()
if err == nil && newHeight >= height {
return true
}
retry++
time.Sleep(100 * time.Millisecond)
if retry >= 100 {
tendermintlog.Error("Wait block fail", "height", height, "CurrentHeight", newHeight)
return false
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment