From 563f4d13b1e1428dbb4a8a51b439d5af706d17b5 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 16 Nov 2016 16:57:45 -0500 Subject: [PATCH] blockchain: LogBlockHeight only needs a wire.MsgBlock.. (#471) --- blockchain/indexers/manager.go | 2 +- blockchain/internal/progresslog/blocklogger.go | 13 +++++++------ blockchain/upgrade.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/blockchain/indexers/manager.go b/blockchain/indexers/manager.go index cb9b6e01..ee9afd2c 100644 --- a/blockchain/indexers/manager.go +++ b/blockchain/indexers/manager.go @@ -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) diff --git a/blockchain/internal/progresslog/blocklogger.go b/blockchain/internal/progresslog/blocklogger.go index e73dc482..4b2f1226 100644 --- a/blockchain/internal/progresslog/blocklogger.go +++ b/blockchain/internal/progresslog/blocklogger.go @@ -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 diff --git a/blockchain/upgrade.go b/blockchain/upgrade.go index 3dfca3c1..d7de41db 100644 --- a/blockchain/upgrade.go +++ b/blockchain/upgrade.go @@ -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 }