Update for recent btcwire API changes.

This commit is contained in:
Dave Collins 2014-01-18 21:10:36 -06:00
parent 7ad6e235ad
commit 33bb455365
3 changed files with 5 additions and 7 deletions

View file

@ -481,12 +481,12 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
// are in the memory pool (either the main pool or orphan pool). // are in the memory pool (either the main pool or orphan pool).
func (b *blockManager) haveInventory(invVect *btcwire.InvVect) bool { func (b *blockManager) haveInventory(invVect *btcwire.InvVect) bool {
switch invVect.Type { switch invVect.Type {
case btcwire.InvVect_Block: case btcwire.InvTypeBlock:
// Ask chain if the block is known to it in any form (main // Ask chain if the block is known to it in any form (main
// chain, side chain, or orphan). // chain, side chain, or orphan).
return b.blockChain.HaveBlock(&invVect.Hash) return b.blockChain.HaveBlock(&invVect.Hash)
case btcwire.InvVect_Tx: case btcwire.InvTypeTx:
// Ask the transaction memory pool if the transaction is known // Ask the transaction memory pool if the transaction is known
// to it in any form (main pool or orphan). // to it in any form (main pool or orphan).
if b.server.txMemPool.HaveTransaction(&invVect.Hash) { if b.server.txMemPool.HaveTransaction(&invVect.Hash) {
@ -604,7 +604,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) {
imsg.peer.requestQueue.Remove(e) imsg.peer.requestQueue.Remove(e)
switch iv.Type { switch iv.Type {
case btcwire.InvVect_Block: case btcwire.InvTypeBlock:
// Request the block if there is not already a pending // Request the block if there is not already a pending
// request. // request.
if _, exists := b.requestedBlocks[iv.Hash]; !exists { if _, exists := b.requestedBlocks[iv.Hash]; !exists {
@ -614,7 +614,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) {
numRequested++ numRequested++
} }
case btcwire.InvVect_Tx: case btcwire.InvTypeTx:
// Request the transaction if there is not already a // Request the transaction if there is not already a
// pending request. // pending request.
if _, exists := b.requestedTxns[iv.Hash]; !exists { if _, exists := b.requestedTxns[iv.Hash]; !exists {

2
log.go
View file

@ -286,7 +286,7 @@ func messageSummary(msg btcwire.Message) string {
header := &msg.Header header := &msg.Header
hash, _ := msg.BlockSha() hash, _ := msg.BlockSha()
return fmt.Sprintf("hash %s, ver %d, %d tx, %s", hash, return fmt.Sprintf("hash %s, ver %d, %d tx, %s", hash,
header.Version, header.TxnCount, header.Timestamp) header.Version, len(msg.Transactions), header.Timestamp)
case *btcwire.MsgInv: case *btcwire.MsgInv:
return invSummary(msg.InvList) return invSummary(msg.InvList)

View file

@ -740,7 +740,6 @@ func (p *peer) handleGetHeadersMsg(msg *btcwire.MsgGetHeaders) {
// Send the requested block header. // Send the requested block header.
headersMsg := btcwire.NewMsgHeaders() headersMsg := btcwire.NewMsgHeaders()
hdr := block.MsgBlock().Header // copy hdr := block.MsgBlock().Header // copy
hdr.TxnCount = 0
headersMsg.AddBlockHeader(&hdr) headersMsg.AddBlockHeader(&hdr)
p.QueueMessage(headersMsg, nil) p.QueueMessage(headersMsg, nil)
return return
@ -796,7 +795,6 @@ func (p *peer) handleGetHeadersMsg(msg *btcwire.MsgGetHeaders) {
continue continue
} }
hdr := block.MsgBlock().Header // copy hdr := block.MsgBlock().Header // copy
hdr.TxnCount = 0
headersMsg.AddBlockHeader(&hdr) headersMsg.AddBlockHeader(&hdr)
} }