From de51409185ba88420b41f61e0a96964323305383 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Mon, 14 Apr 2014 10:29:51 -0500 Subject: [PATCH] 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. --- rpcserver.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 2b68920b4..2e53decf2 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1454,19 +1454,21 @@ func handleSubmitBlock(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) { } func verifyChain(db btcdb.Db, level, depth int32) error { - _, curheight64, err := db.NewestSha() + _, curHeight64, err := db.NewestSha() if err != nil { rpcsLog.Errorf("Verify is unable to fetch current block "+ "height: %v", err) } + curHeight := int32(curHeight64) - curheight := int32(curheight64) - - if depth > curheight { - depth = curheight + finishHeight := curHeight - depth + if finishHeight < 0 { + finishHeight = 0 } + 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. sha, err := db.FetchBlockShaByHeight(int64(height)) if err != nil {