change some more code over to using newer btcdb apis.

This commit is contained in:
Owain G. Ainsworth 2014-01-29 01:24:05 +00:00
parent 8d930ceed1
commit 042d9206a1
2 changed files with 6 additions and 6 deletions

View file

@ -284,9 +284,9 @@ func (b *blockManager) logBlockHeight(numTx, height int64, latestHash *btcwire.S
// Attempt to get the timestamp of the latest block. // Attempt to get the timestamp of the latest block.
blockTimeStr := "" blockTimeStr := ""
block, err := b.server.db.FetchBlockBySha(latestHash) header, err := b.server.db.FetchBlockHeaderBySha(latestHash)
if err == nil { if err == nil {
blockTimeStr = fmt.Sprintf(", %s", block.MsgBlock().Header.Timestamp) blockTimeStr = fmt.Sprintf(", %s", header.Timestamp)
} }
// Log information about new block height. // Log information about new block height.

View file

@ -645,9 +645,9 @@ func (p *peer) handleGetBlocksMsg(msg *btcwire.MsgGetBlocks) {
// Attempt to find the ending index of the stop hash if specified. // Attempt to find the ending index of the stop hash if specified.
endIdx := btcdb.AllShas endIdx := btcdb.AllShas
if !msg.HashStop.IsEqual(&zeroHash) { if !msg.HashStop.IsEqual(&zeroHash) {
block, err := p.server.db.FetchBlockBySha(&msg.HashStop) height, err := p.server.db.FetchBlockHeightBySha(&msg.HashStop)
if err == nil { if err == nil {
endIdx = block.Height() + 1 endIdx = height + 1
} }
} }
@ -658,10 +658,10 @@ func (p *peer) handleGetBlocksMsg(msg *btcwire.MsgGetBlocks) {
// This mirrors the behavior in the reference implementation. // This mirrors the behavior in the reference implementation.
startIdx := int64(1) startIdx := int64(1)
for _, hash := range msg.BlockLocatorHashes { for _, hash := range msg.BlockLocatorHashes {
block, err := p.server.db.FetchBlockBySha(hash) height, err := p.server.db.FetchBlockHeightBySha(hash)
if err == nil { if err == nil {
// Start with the next hash since we know this one. // Start with the next hash since we know this one.
startIdx = block.Height() + 1 startIdx = height + 1
break break
} }
} }