mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-30 17:01:29 +00:00
Update to use latest btcwire invtype constants.
This commit is contained in:
parent
c8160a57aa
commit
f4dac3abf0
3 changed files with 12 additions and 12 deletions
|
@ -329,7 +329,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) {
|
||||||
lastBlock := -1
|
lastBlock := -1
|
||||||
invVects := imsg.inv.InvList
|
invVects := imsg.inv.InvList
|
||||||
for i := len(invVects) - 1; i >= 0; i-- {
|
for i := len(invVects) - 1; i >= 0; i-- {
|
||||||
if invVects[i].Type == btcwire.InvVect_Block {
|
if invVects[i].Type == btcwire.InvTypeBlock {
|
||||||
lastBlock = i
|
lastBlock = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) {
|
||||||
chain := b.blockChain
|
chain := b.blockChain
|
||||||
for i, iv := range invVects {
|
for i, iv := range invVects {
|
||||||
// Ignore unsupported inventory types.
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if iv.Type == btcwire.InvVect_Block {
|
if iv.Type == btcwire.InvTypeBlock {
|
||||||
// The block is an orphan block that we already have.
|
// The block is an orphan block that we already have.
|
||||||
// When the existing orphan was processed, it requested
|
// When the existing orphan was processed, it requested
|
||||||
// the missing parent blocks. When this scenario
|
// the missing parent blocks. When this scenario
|
||||||
|
@ -505,7 +505,7 @@ func (b *blockManager) handleNotifyMsg(notification *btcchain.Notification) {
|
||||||
hash, _ := block.Sha()
|
hash, _ := block.Sha()
|
||||||
|
|
||||||
// Generate the inventory vector and relay it.
|
// Generate the inventory vector and relay it.
|
||||||
iv := btcwire.NewInvVect(btcwire.InvVect_Block, hash)
|
iv := btcwire.NewInvVect(btcwire.InvTypeBlock, hash)
|
||||||
b.server.RelayInventory(iv)
|
b.server.RelayInventory(iv)
|
||||||
|
|
||||||
// A block has been connected to the main block chain.
|
// A block has been connected to the main block chain.
|
||||||
|
|
|
@ -670,7 +670,7 @@ func (mp *txMemPool) maybeAcceptTransaction(tx *btcwire.MsgTx, isOrphan *bool) e
|
||||||
// TODO(davec): Notifications
|
// TODO(davec): Notifications
|
||||||
|
|
||||||
// Generate the inventory vector and relay it.
|
// Generate the inventory vector and relay it.
|
||||||
iv := btcwire.NewInvVect(btcwire.InvVect_Tx, &txHash)
|
iv := btcwire.NewInvVect(btcwire.InvTypeTx, &txHash)
|
||||||
mp.server.RelayInventory(iv)
|
mp.server.RelayInventory(iv)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
14
peer.go
14
peer.go
|
@ -350,7 +350,7 @@ func (p *peer) pushBlockMsg(sha btcwire.ShaHash) error {
|
||||||
hash, _, err := p.server.db.NewestSha()
|
hash, _, err := p.server.db.NewestSha()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
invMsg := btcwire.NewMsgInv()
|
invMsg := btcwire.NewMsgInv()
|
||||||
iv := btcwire.NewInvVect(btcwire.InvVect_Block, hash)
|
iv := btcwire.NewInvVect(btcwire.InvTypeBlock, hash)
|
||||||
invMsg.AddInvVect(iv)
|
invMsg.AddInvVect(iv)
|
||||||
p.QueueMessage(invMsg)
|
p.QueueMessage(invMsg)
|
||||||
p.continueHash = nil
|
p.continueHash = nil
|
||||||
|
@ -410,7 +410,7 @@ func (p *peer) handleMemPoolMsg(msg *btcwire.MsgMemPool) {
|
||||||
invMsg := btcwire.NewMsgInv()
|
invMsg := btcwire.NewMsgInv()
|
||||||
hashes := p.server.txMemPool.TxShas()
|
hashes := p.server.txMemPool.TxShas()
|
||||||
for i, hash := range hashes {
|
for i, hash := range hashes {
|
||||||
iv := btcwire.NewInvVect(btcwire.InvVect_Tx, hash)
|
iv := btcwire.NewInvVect(btcwire.InvTypeTx, hash)
|
||||||
invMsg.AddInvVect(iv)
|
invMsg.AddInvVect(iv)
|
||||||
if i+1 >= btcwire.MaxInvPerMsg {
|
if i+1 >= btcwire.MaxInvPerMsg {
|
||||||
break
|
break
|
||||||
|
@ -434,7 +434,7 @@ func (p *peer) handleTxMsg(msg *btcwire.MsgTx) {
|
||||||
log.Errorf("Unable to get transaction hash: %v", err)
|
log.Errorf("Unable to get transaction hash: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
iv := btcwire.NewInvVect(btcwire.InvVect_Tx, &hash)
|
iv := btcwire.NewInvVect(btcwire.InvTypeTx, &hash)
|
||||||
p.addKnownInventory(iv)
|
p.addKnownInventory(iv)
|
||||||
|
|
||||||
// Process the transaction.
|
// 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)
|
log.Errorf("Unable to get block hash: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
iv := btcwire.NewInvVect(btcwire.InvVect_Block, hash)
|
iv := btcwire.NewInvVect(btcwire.InvTypeBlock, hash)
|
||||||
p.addKnownInventory(iv)
|
p.addKnownInventory(iv)
|
||||||
|
|
||||||
// Queue the block up to be handled by the block
|
// Queue the block up to be handled by the block
|
||||||
|
@ -502,9 +502,9 @@ out:
|
||||||
for _, iv := range msg.InvList {
|
for _, iv := range msg.InvList {
|
||||||
var err error
|
var err error
|
||||||
switch iv.Type {
|
switch iv.Type {
|
||||||
case btcwire.InvVect_Tx:
|
case btcwire.InvTypeTx:
|
||||||
err = p.pushTxMsg(iv.Hash)
|
err = p.pushTxMsg(iv.Hash)
|
||||||
case btcwire.InvVect_Block:
|
case btcwire.InvTypeBlock:
|
||||||
err = p.pushBlockMsg(iv.Hash)
|
err = p.pushBlockMsg(iv.Hash)
|
||||||
default:
|
default:
|
||||||
log.Warnf("[PEER] Unknown type in inventory request %d",
|
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.
|
// Add block inventory to the message.
|
||||||
for _, hash := range hashList {
|
for _, hash := range hashList {
|
||||||
hashCopy := hash
|
hashCopy := hash
|
||||||
iv := btcwire.NewInvVect(btcwire.InvVect_Block, &hashCopy)
|
iv := btcwire.NewInvVect(btcwire.InvTypeBlock, &hashCopy)
|
||||||
invMsg.AddInvVect(iv)
|
invMsg.AddInvVect(iv)
|
||||||
}
|
}
|
||||||
start += int64(len(hashList))
|
start += int64(len(hashList))
|
||||||
|
|
Loading…
Add table
Reference in a new issue