forked from TrueCloudLab/neoneo-go
network: fix requestTx() behaviour for consensus service
It wasn't actually requesting transactions but rather sending an inventory message telling everyone that we have them which is completely wrong and easily leads to ChangeView that could be avoided.
This commit is contained in:
parent
0420d48e56
commit
7d4d57351e
1 changed files with 8 additions and 7 deletions
|
@ -664,7 +664,7 @@ func (s *Server) handleMessage(peer Peer, msg *Message) error {
|
|||
}
|
||||
|
||||
func (s *Server) handleNewPayload(p *consensus.Payload) {
|
||||
s.relayInventory(payload.ConsensusType, p.Hash())
|
||||
s.relayInventoryCmd(CMDInv, payload.ConsensusType, p.Hash())
|
||||
}
|
||||
|
||||
func (s *Server) requestTx(hashes ...util.Uint256) {
|
||||
|
@ -672,24 +672,25 @@ func (s *Server) requestTx(hashes ...util.Uint256) {
|
|||
return
|
||||
}
|
||||
|
||||
s.relayInventory(payload.TXType, hashes...)
|
||||
s.relayInventoryCmd(CMDGetData, payload.TXType, hashes...)
|
||||
}
|
||||
|
||||
func (s *Server) relayInventory(t payload.InventoryType, hashes ...util.Uint256) {
|
||||
func (s *Server) relayInventoryCmd(cmd CommandType, t payload.InventoryType, hashes ...util.Uint256) {
|
||||
payload := payload.NewInventory(t, hashes)
|
||||
msg := NewMessage(s.Net, CMDInv, payload)
|
||||
msg := NewMessage(s.Net, cmd, payload)
|
||||
|
||||
for peer := range s.Peers() {
|
||||
if !peer.Handshaked() || !peer.Version().Relay {
|
||||
continue
|
||||
}
|
||||
peer.WriteMsg(msg)
|
||||
// Who cares about these messages anyway?
|
||||
_ = peer.WriteMsg(msg)
|
||||
}
|
||||
}
|
||||
|
||||
// relayBlock tells all the other connected nodes about the given block.
|
||||
func (s *Server) relayBlock(b *core.Block) {
|
||||
s.relayInventory(payload.BlockType, b.Hash())
|
||||
s.relayInventoryCmd(CMDInv, payload.BlockType, b.Hash())
|
||||
}
|
||||
|
||||
// RelayTxn a new transaction to the local node and the connected peers.
|
||||
|
@ -711,7 +712,7 @@ func (s *Server) RelayTxn(t *transaction.Transaction) RelayReason {
|
|||
return RelayOutOfMemory
|
||||
}
|
||||
|
||||
s.relayInventory(payload.TXType, t.Hash())
|
||||
s.relayInventoryCmd(CMDInv, payload.TXType, t.Hash())
|
||||
|
||||
return RelaySucceed
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue