kaspad/server/p2p/on_get_block_locator.go
Svarog 369ec449a8 [NOD-509] Change organization name to kaspanet (#524)
* [NOD-509] Change organization name to kaspanet

* [NOD-509] Reorganize imports
2019-12-08 17:33:42 +02:00

26 lines
652 B
Go

package p2p
import (
"github.com/kaspanet/kaspad/peer"
"github.com/kaspanet/kaspad/wire"
)
// OnGetBlockLocator is invoked when a peer receives a getlocator bitcoin
// message.
func (sp *Peer) OnGetBlockLocator(_ *peer.Peer, msg *wire.MsgGetBlockLocator) {
locator := sp.server.DAG.BlockLocatorFromHashes(msg.StartHash, msg.StopHash)
if len(locator) == 0 {
peerLog.Infof("Couldn't build a block locator between blocks %s and %s"+
" that was requested from peer %s",
sp)
return
}
err := sp.PushBlockLocatorMsg(locator)
if err != nil {
peerLog.Errorf("Failed to send block locator message to peer %s: %s",
sp, err)
return
}
}