mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-09-13 04:50:11 +00:00

* [NOD-614] Copy bitcoin-core ban score policy * [NOD-614] Add ban score to disconnects * [NOD-614] Fix wrong branch of AddBanScore * [NOD-614] Add ban score on sending too many addresses * [NOD-614] Add comments * [NOD-614] Remove redundant reject messages * [NOD-614] Fix log message * [NOD-614] Ban every node that sends invalid invs * [NOD-614] Make constants for ban scores
31 lines
948 B
Go
31 lines
948 B
Go
package p2p
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/kaspanet/kaspad/peer"
|
|
"github.com/kaspanet/kaspad/wire"
|
|
)
|
|
|
|
// OnGetBlockLocator is invoked when a peer receives a getlocator kaspa
|
|
// message.
|
|
func (sp *Peer) OnGetBlockLocator(_ *peer.Peer, msg *wire.MsgGetBlockLocator) {
|
|
locator, err := sp.server.DAG.BlockLocatorFromHashes(msg.HighHash, msg.LowHash)
|
|
if err != nil || len(locator) == 0 {
|
|
if err != nil {
|
|
peerLog.Warnf("Couldn't build a block locator between blocks "+
|
|
"%s and %s that was requested from peer %s: %s", msg.HighHash, msg.LowHash, sp, err)
|
|
}
|
|
sp.AddBanScoreAndPushRejectMsg(msg.Command(), wire.RejectInvalid, nil,
|
|
peer.BanScoreInvalidMsgBlockLocator, 0,
|
|
fmt.Sprintf("couldn't build a block locator between blocks %s and %s", msg.HighHash, msg.LowHash))
|
|
return
|
|
}
|
|
|
|
err = sp.PushBlockLocatorMsg(locator)
|
|
if err != nil {
|
|
peerLog.Errorf("Failed to send block locator message to peer %s: %s",
|
|
sp, err)
|
|
return
|
|
}
|
|
}
|