The settings below are for a backup block producer which I want to only connect with 2 other specific relays.
In the config file, ensure the target number of peers is at least as high as the number you want. In this case I left it much higher at 10 for established and active peers.
"EnableP2P": true,
"PeerSharingDisabled": true,
"TargetNumberOfRootPeers": 30,
"TargetNumberOfKnownPeers": 30,
"TargetNumberOfEstablishedPeers": 10,
"TargetNumberOfActivePeers": 10,
Then in your topology file provide only the accessPoints you want and set the hotValency to the specific number. If you want to set warmValency then this should be the same or higher.
{
"localRoots": [
{ "accessPoints": [
{ "address": "10.0.0.28", "port": 3001 }
, { "address": "10.0.0.29", "port": 3001 }
]
, "advertise": false
, "trustable": true
, "hotValency": 2
}
]
, "publicRoots" : []
, "useLedgerAfterSlot": -1
}
Nb. There is no bootstrapPeers section, useLedgerAfterSlot is -1, and I have marked those 2 particular localRoots as “trustable”. This is because I want this node to run as a backup block producer, so if it gets too out of sync (eg. if I leave it disconnected for a while which I sometimes do), I only want it to bootstrap from those trusted local relays.
See: cardano-node-wiki/docs/getting-started/understanding-config-files.md at main · input-output-hk/cardano-node-wiki · GitHub
This is what the connections look like for this backup BP:
curl -s -H 'Accept: application/json' http://localhost:12788 | jq -jr '.cardano.node.metrics.connectionManager'
{
"duplexConns": {
"type": "g",
"val": 2
},
"incomingConns": {
"type": "g",
"val": 0
},
"outgoingConns": {
"type": "g",
"val": 2
},
"prunableConns": {
"type": "g",
"val": 0
},
"unidirectionalConns": {
"type": "g",
"val": 0
}
}
Note outgoingConns is only 2 and duplexConns is only 2. There are no incomingConns because neither of the configured relays in my topology file know about this backup block producer. IE: They are not configured to specifically connect to it as a localRoot.
Note: Normally you would configure your relays to connect to your block producer as a localRoot in their topology files. Thus, in that normal case, you would see incomingConns as 2 also.