gracefully handle syncing zcashd (no REORG)

This commit is contained in:
Larry Ruane 2020-06-25 14:32:28 -06:00 committed by Larry Ruane
parent 32fe002a21
commit 1c6d8a46f7
2 changed files with 15 additions and 1 deletions

View File

@ -37,6 +37,13 @@ func (c *BlockCache) GetNextHeight() int {
return c.nextBlock
}
// GetFirstHeight returns the height of the lowest block (usually Sapling activation).
func (c *BlockCache) GetFirstHeight() int {
c.mutex.RLock()
defer c.mutex.RUnlock()
return c.firstBlock
}
// GetLatestHash returns the hash (block ID) of the most recent (highest) known block.
func (c *BlockCache) GetLatestHash() []byte {
c.mutex.RLock()

View File

@ -215,11 +215,18 @@ func BlockIngestor(c *BlockCache, rep int) {
retryCount = 0
if block == nil {
// No block at this height.
if height == c.GetFirstHeight() {
Log.Info("Waiting for zcashd height to reach Sapling activation height ",
"(", c.GetFirstHeight(), ")...")
reorgCount = 0
Sleep(20 * time.Second)
continue
}
if wait {
// Wait a bit then retry the same height.
c.Sync()
if lastHeightLogged+1 != height {
Log.Info("Ingestor: waiting for block: ", height)
Log.Info("Ingestor waiting for block: ", height)
lastHeightLogged = height - 1
}
Sleep(2 * time.Second)