Tentative fix for self-connection discovery issues

This commit is contained in:
Zahary Karadjov 2019-03-20 03:18:49 +02:00
parent 71670ca9c9
commit 6d4284877d
3 changed files with 10 additions and 2 deletions

View File

@ -175,7 +175,14 @@ proc init*(T: type BeaconNode, conf: BeaconNodeConf): Future[BeaconNode] {.async
result.network.saveConnectionAddressFile(addressFile)
proc connectToNetwork(node: BeaconNode) {.async.} =
var bootstrapNodes = node.networkMetadata.bootstrapNodes
let localKeys = ensureNetworkKeys(node.config)
var bootstrapNodes = newSeq[BootstrapAddr]()
for bootNode in node.networkMetadata.bootstrapNodes:
if bootNode.pubkey == localKeys.pubKey:
node.isBootstrapNode = true
else:
bootstrapNodes.add bootNode
for bootNode in node.config.bootstrapNodes:
bootstrapNodes.add BootstrapAddr.init(bootNode)

View File

@ -26,6 +26,7 @@ type
BeaconNode* = ref object
network*: EthereumNode
networkMetadata*: NetworkMetadata
isBootstrapNode*: bool
db*: BeaconChainDB
config*: BeaconNodeConf
keys*: KeyPair

View File

@ -30,7 +30,7 @@ when useRLPx:
else:
parseIpAddress("127.0.0.1")
proc ensureNetworkKeys(conf: BeaconNodeConf): KeyPair =
proc ensureNetworkKeys*(conf: BeaconNodeConf): KeyPair =
let privateKeyFile = conf.dataDir / "network.privkey"
var privKey: PrivateKey
if not fileExists(privateKeyFile):