Closed ASuciuX closed 22 hours ago
Hi @ASuciuX, the best place to do this is actually in PeerNetwork::register_peer()
and PeerNetwork::deregister_peer()
. The neighbor walk state machine is only one of several state machines that can add or remove neighbors.
Thank you! I will update it. How can I test a removal of a neighbor? I was running a mainnet instance but I could set up anything else if needed.
@ASuciuX Check out struct P2PSession
in stackslib/src/main.rs
. It sets up a p2p session with a running node (getting you to register_peer()
). Simply dropping the PeerSession
instance will trigger a call to deregister_peer()
since the socket will close.
@jcnelson I've moved them to p2p session, the output is the following:
For new neighbor accepted. The public key is an optional, which was always none
in what I've run. Can this be Some(public_key)
if the node is a miner or in what context would that be not none
when adding a neighbor?
INFO [1731696282.438126] [stackslib/src/net/p2p.rs:1811] [p2p-(0.0.0.0:20444,0.0.0.0:20443)] Neighbor accepted! public key: None address: 00000000000000000000ffff8fc63cb8
For neighbor removed.
INFO [1731696340.243120] [stackslib/src/net/p2p.rs:1906] [p2p-(0.0.0.0:20444,0.0.0.0:20443)] Dropping neighbor! event id: 7 public address: b8db004e2928a10bf85d84071c0c9d398cee7dcf public key: 00000000000000000000ffff225662f3
I got the display from adding a new neighbor. How could I reproduce the removal of a neighbor in order to check it is displayed as intended?
New neighbor added