connectBlockChunk - handling height over bitcoind best block height

This commit is contained in:
Martin Boehm 2018-01-25 16:24:27 +01:00
parent b12c8cfae6
commit 2f73f6f81b

View File

@ -295,7 +295,10 @@ func connectBlocksParallel(
} }
err := connectBlockChunk(chain, index, low, high) err := connectBlockChunk(chain, index, low, high)
if err != nil { if err != nil {
log.Fatalf("connectBlocksParallel %d-%d %v", low, high, err) // TODO if e, ok := err.(*bitcoin.RPCError); ok && (e.Message == "Block height out of range" || e.Message == "Block not found") {
break
}
log.Fatalf("connectBlocksParallel %d-%d %v", low, high, err)
} }
} }
} }
@ -316,7 +319,10 @@ func connectBlockChunk(
) error { ) error {
connected, err := isBlockConnected(chain, index, higher) connected, err := isBlockConnected(chain, index, higher)
if err != nil || connected { if err != nil || connected {
return err // if higher is over the best block, continue with lower block, otherwise return error
if e, ok := err.(*bitcoin.RPCError); !ok || e.Message != "Block height out of range" {
return err
}
} }
height := lower height := lower