convert getdifficulty to getBlockHeaderBySha to save some cycles.

This commit is contained in:
Owain G. Ainsworth 2014-01-29 01:09:42 +00:00
parent 970c0cdb30
commit 8d930ceed1

View file

@ -930,13 +930,11 @@ func handleGetDifficulty(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
rpcsLog.Errorf("Error getting sha: %v", err)
return nil, btcjson.ErrDifficulty
}
blk, err := s.server.db.FetchBlockBySha(sha)
blockHeader, err := s.server.db.FetchBlockHeaderBySha(sha)
if err != nil {
rpcsLog.Errorf("Error getting block: %v", err)
return nil, btcjson.ErrDifficulty
}
blockHeader := &blk.MsgBlock().Header
return getDifficultyRatio(blockHeader.Bits), nil
}