mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-05 21:56:50 +00:00

* [NOD-616] Remove unused methods from BlockDAG. * [NOD-616] Remove Height from GetRawMempoolVerboseResult and TxDesc. * [NOD-616] Replaced BlockDAG.ChainHeight with SelectedTipBlueScore. * [NOD-616] Remove the unused BlockChainHeightByHash. * [NOD-616] Remove the unused blockChainHeight from checkBlockHeaderContext. * [NOD-616] Remove chainHeight from util.Block. * [NOD-616] Remove TestChainHeight. * [NOD-616] Update unknown rule activation warning to use blueScore. * [NOD-616] Update thresholdState to use blueScore instead of chainHeight. * [NOD-616] Update blockLocator to use blueScore instead of chainHeight. * [NOD-616] Remove blockNode.chainHeight. * [NOD-616] Fix comments and variable names. * [NOD-616] Replace a weird for loop with a while loop. * [NOD-616] Fix a comment. * [NOD-616] Remove pre-allocation in blockLocator. * [NOD-616] Coalesce checks that startHash and stopHash are not the same into the same condition. * [NOD-616] Fix a comment. * [NOD-616] Remove weird blueScore logic around childHashStrings. * [NOD-616] Fix hash pointer comparison. * [NOD-616] Fix a comment. * [NOD-616] Add ban score to peers misusing GetBlockLocator. * [NOD-616] Replace adding ban score with disconnecting. * [NOD-616] Add blueScore to FilteredBlockAddedNtfn.
31 lines
824 B
Go
31 lines
824 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.StartHash, msg.StopHash)
|
|
if err != nil || len(locator) == 0 {
|
|
warning := fmt.Sprintf("Couldn't build a block locator between blocks "+
|
|
"%s and %s that was requested from peer %s", msg.StartHash, msg.StopHash, sp)
|
|
if err != nil {
|
|
warning = fmt.Sprintf("%s: %s", warning, err)
|
|
}
|
|
peerLog.Warnf(warning)
|
|
sp.Disconnect()
|
|
return
|
|
}
|
|
|
|
err = sp.PushBlockLocatorMsg(locator)
|
|
if err != nil {
|
|
peerLog.Errorf("Failed to send block locator message to peer %s: %s",
|
|
sp, err)
|
|
return
|
|
}
|
|
}
|