blockchain: LogBlockHeight only needs a wire.MsgBlock.. (#471)

This commit is contained in:
David Hill 2016-11-16 16:57:45 -05:00 committed by Alex Yocom-Piatt
parent c162fbde71
commit 563f4d13b1
3 changed files with 9 additions and 8 deletions

View File

@ -457,7 +457,7 @@ func (m *Manager) Init(chain *blockchain.BlockChain) error {
if err != nil {
return err
}
progressLogger.LogBlockHeight(block, parent)
progressLogger.LogBlockHeight(block.MsgBlock(), parent.MsgBlock())
}
log.Infof("Indexes caught up to height %d", bestHeight)

View File

@ -11,6 +11,7 @@ import (
"github.com/btcsuite/btclog"
"github.com/decred/dcrd/wire"
"github.com/decred/dcrutil"
)
@ -42,16 +43,16 @@ func NewBlockProgressLogger(progressMessage string, logger btclog.Logger) *Block
// LogBlockHeight logs a new block height as an information message to show
// progress to the user. In order to prevent spam, it limits logging to one
// message every 10 seconds with duration and totals included.
func (b *BlockProgressLogger) LogBlockHeight(block, parent *dcrutil.Block) {
func (b *BlockProgressLogger) LogBlockHeight(block, parent *wire.MsgBlock) {
b.Lock()
defer b.Unlock()
b.receivedLogBlocks++
regularTxTreeValid := dcrutil.IsFlagSet16(block.MsgBlock().Header.VoteBits,
regularTxTreeValid := dcrutil.IsFlagSet16(block.Header.VoteBits,
dcrutil.BlockValid)
if regularTxTreeValid {
b.receivedLogTx += int64(len(parent.MsgBlock().Transactions))
b.receivedLogTx += int64(len(parent.Transactions))
}
b.receivedLogTx += int64(len(block.MsgBlock().STransactions))
b.receivedLogTx += int64(len(block.STransactions))
now := time.Now()
duration := now.Sub(b.lastBlockLogTime)
@ -74,8 +75,8 @@ func (b *BlockProgressLogger) LogBlockHeight(block, parent *dcrutil.Block) {
}
b.subsystemLogger.Infof("%s %d %s in the last %s (%d %s, height %d, %s)",
b.progressAction, b.receivedLogBlocks, blockStr, tDuration,
b.receivedLogTx, txStr, block.Height(),
block.MsgBlock().Header.Timestamp)
b.receivedLogTx, txStr, block.Header.Height,
block.Header.Timestamp)
b.receivedLogBlocks = 0
b.receivedLogTx = 0

View File

@ -81,7 +81,7 @@ func (b *BlockChain) upgradeToVersion2() error {
b.bestNode.ticketsRevoked = ticketsRevokedInBlock(block)
}
progressLogger.LogBlockHeight(block, parent)
progressLogger.LogBlockHeight(block.MsgBlock(), parent.MsgBlock())
parent = block
}