Update to use latest btcwire invtype constants.

This commit is contained in:
Dave Collins 2013-10-08 15:55:07 -05:00
parent c8160a57aa
commit f4dac3abf0
3 changed files with 12 additions and 12 deletions

View file

@ -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.

View file

@ -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

14
peer.go
View file

@ -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))