Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
blockchain: LogBlockHeight only needs a wire.MsgBlock.. (decred#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi authored and alexlyp committed Nov 16, 2016
1 parent c162fbd commit 563f4d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion blockchain/indexers/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions blockchain/internal/progresslog/blocklogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/btcsuite/btclog"

"github.com/decred/dcrd/wire"
"github.com/decred/dcrutil"
)

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion blockchain/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 563f4d1

Please sign in to comment.