From f4dac3abf0bdcf56a99131411f6b2e03170f9254 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 8 Oct 2013 15:55:07 -0500 Subject: [PATCH] Update to use latest btcwire invtype constants. --- blockmanager.go | 8 ++++---- mempool.go | 2 +- peer.go | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/blockmanager.go b/blockmanager.go index 349f766c..6cecf0ef 100644 --- a/blockmanager.go +++ b/blockmanager.go @@ -329,7 +329,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) { lastBlock := -1 invVects := imsg.inv.InvList for i := len(invVects) - 1; i >= 0; i-- { - if invVects[i].Type == btcwire.InvVect_Block { + if invVects[i].Type == btcwire.InvTypeBlock { lastBlock = i break } @@ -342,7 +342,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) { chain := b.blockChain for i, iv := range invVects { // Ignore unsupported inventory types. - if iv.Type != btcwire.InvVect_Block && iv.Type != btcwire.InvVect_Tx { + if iv.Type != btcwire.InvTypeBlock && iv.Type != btcwire.InvTypeTx { continue } @@ -357,7 +357,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) { continue } - if iv.Type == btcwire.InvVect_Block { + if iv.Type == btcwire.InvTypeBlock { // The block is an orphan block that we already have. // When the existing orphan was processed, it requested // the missing parent blocks. When this scenario @@ -505,7 +505,7 @@ func (b *blockManager) handleNotifyMsg(notification *btcchain.Notification) { hash, _ := block.Sha() // Generate the inventory vector and relay it. - iv := btcwire.NewInvVect(btcwire.InvVect_Block, hash) + iv := btcwire.NewInvVect(btcwire.InvTypeBlock, hash) b.server.RelayInventory(iv) // A block has been connected to the main block chain. diff --git a/mempool.go b/mempool.go index c0b5e76e..92cd9471 100644 --- a/mempool.go +++ b/mempool.go @@ -670,7 +670,7 @@ func (mp *txMemPool) maybeAcceptTransaction(tx *btcwire.MsgTx, isOrphan *bool) e // TODO(davec): Notifications // Generate the inventory vector and relay it. - iv := btcwire.NewInvVect(btcwire.InvVect_Tx, &txHash) + iv := btcwire.NewInvVect(btcwire.InvTypeTx, &txHash) mp.server.RelayInventory(iv) return nil diff --git a/peer.go b/peer.go index 6aa52786..727fcfe3 100644 --- a/peer.go +++ b/peer.go @@ -350,7 +350,7 @@ func (p *peer) pushBlockMsg(sha btcwire.ShaHash) error { hash, _, err := p.server.db.NewestSha() if err == nil { invMsg := btcwire.NewMsgInv() - iv := btcwire.NewInvVect(btcwire.InvVect_Block, hash) + iv := btcwire.NewInvVect(btcwire.InvTypeBlock, hash) invMsg.AddInvVect(iv) p.QueueMessage(invMsg) p.continueHash = nil @@ -410,7 +410,7 @@ func (p *peer) handleMemPoolMsg(msg *btcwire.MsgMemPool) { invMsg := btcwire.NewMsgInv() hashes := p.server.txMemPool.TxShas() for i, hash := range hashes { - iv := btcwire.NewInvVect(btcwire.InvVect_Tx, hash) + iv := btcwire.NewInvVect(btcwire.InvTypeTx, hash) invMsg.AddInvVect(iv) if i+1 >= btcwire.MaxInvPerMsg { break @@ -434,7 +434,7 @@ func (p *peer) handleTxMsg(msg *btcwire.MsgTx) { log.Errorf("Unable to get transaction hash: %v", err) return } - iv := btcwire.NewInvVect(btcwire.InvVect_Tx, &hash) + iv := btcwire.NewInvVect(btcwire.InvTypeTx, &hash) p.addKnownInventory(iv) // Process the transaction. @@ -467,7 +467,7 @@ func (p *peer) handleBlockMsg(msg *btcwire.MsgBlock, buf []byte) { log.Errorf("Unable to get block hash: %v", err) return } - iv := btcwire.NewInvVect(btcwire.InvVect_Block, hash) + iv := btcwire.NewInvVect(btcwire.InvTypeBlock, hash) p.addKnownInventory(iv) // Queue the block up to be handled by the block @@ -502,9 +502,9 @@ out: for _, iv := range msg.InvList { var err error switch iv.Type { - case btcwire.InvVect_Tx: + case btcwire.InvTypeTx: err = p.pushTxMsg(iv.Hash) - case btcwire.InvVect_Block: + case btcwire.InvTypeBlock: err = p.pushBlockMsg(iv.Hash) default: log.Warnf("[PEER] Unknown type in inventory request %d", @@ -579,7 +579,7 @@ func (p *peer) handleGetBlocksMsg(msg *btcwire.MsgGetBlocks) { // Add block inventory to the message. for _, hash := range hashList { hashCopy := hash - iv := btcwire.NewInvVect(btcwire.InvVect_Block, &hashCopy) + iv := btcwire.NewInvVect(btcwire.InvTypeBlock, &hashCopy) invMsg.AddInvVect(iv) } start += int64(len(hashList))