Add debug print for chain verify.

Since a chain verification can take a long time depending on the
parameters, this commit adds a debug print to the RPC server at the info
level for how many blocks are being verified and at what level.

The logic was also slightly modified so the number of blocks being checked
can easily be calculated and shown.
This commit is contained in:
Dave Collins 2014-04-14 10:29:51 -05:00
parent 3937c1a67c
commit de51409185

View file

@ -1454,19 +1454,21 @@ func handleSubmitBlock(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
} }
func verifyChain(db btcdb.Db, level, depth int32) error { func verifyChain(db btcdb.Db, level, depth int32) error {
_, curheight64, err := db.NewestSha() _, curHeight64, err := db.NewestSha()
if err != nil { if err != nil {
rpcsLog.Errorf("Verify is unable to fetch current block "+ rpcsLog.Errorf("Verify is unable to fetch current block "+
"height: %v", err) "height: %v", err)
} }
curHeight := int32(curHeight64)
curheight := int32(curheight64) finishHeight := curHeight - depth
if finishHeight < 0 {
if depth > curheight { finishHeight = 0
depth = curheight
} }
rpcsLog.Infof("Verifying chain for %d blocks at level %d",
curHeight-finishHeight, level)
for height := curheight; height > (curheight - depth); height-- { for height := curHeight; height > finishHeight; height-- {
// Level 0 just looks up the block. // Level 0 just looks up the block.
sha, err := db.FetchBlockShaByHeight(int64(height)) sha, err := db.FetchBlockShaByHeight(int64(height))
if err != nil { if err != nil {