aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/simulation/node.go
diff options
context:
space:
mode:
authorlash <nolash@users.noreply.github.com>2019-03-15 18:27:17 +0800
committerViktor TrĂ³n <viktor.tron@gmail.com>2019-03-15 18:27:17 +0800
commit4b4f03ca3788e16bc40737376f593623ac3f2cd8 (patch)
tree32876a858821d03529d2375b4184be1e07e03455 /swarm/network/simulation/node.go
parentdf488975bd4bc514a01a3157d52dafd0118a4a05 (diff)
downloadgo-tangerine-4b4f03ca3788e16bc40737376f593623ac3f2cd8.tar
go-tangerine-4b4f03ca3788e16bc40737376f593623ac3f2cd8.tar.gz
go-tangerine-4b4f03ca3788e16bc40737376f593623ac3f2cd8.tar.bz2
go-tangerine-4b4f03ca3788e16bc40737376f593623ac3f2cd8.tar.lz
go-tangerine-4b4f03ca3788e16bc40737376f593623ac3f2cd8.tar.xz
go-tangerine-4b4f03ca3788e16bc40737376f593623ac3f2cd8.tar.zst
go-tangerine-4b4f03ca3788e16bc40737376f593623ac3f2cd8.zip
swarm, p2p: Prerequities for ENR replacing handshake (#19275)
* swarm/api, swarm/network, p2p/simulations: Prerequisites for handshake remove * swarm, p2p: Add full sim node configs for protocoltester * swarm/network: Make stream package pass tests * swarm/network: Extract peer and addr types out of protocol file * p2p, swarm: Make p2p/protocols tests pass + rename types.go * swarm/network: Deactivate ExecAdapter test until binary ENR prep * swarm/api: Remove comments * swarm/network: Uncomment bootnode record load
Diffstat (limited to 'swarm/network/simulation/node.go')
-rw-r--r--swarm/network/simulation/node.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/swarm/network/simulation/node.go b/swarm/network/simulation/node.go
index 4c3834de3..1ab9ddfd0 100644
--- a/swarm/network/simulation/node.go
+++ b/swarm/network/simulation/node.go
@@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/simulations"
"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
+ "github.com/ethereum/go-ethereum/swarm/network"
)
// NodeIDs returns NodeIDs for all nodes in the network.
@@ -96,10 +97,28 @@ func (s *Simulation) AddNode(opts ...AddNodeOption) (id enode.ID, err error) {
if len(conf.Services) == 0 {
conf.Services = s.serviceNames
}
+
+ // add ENR records to the underlying node
+ // most importantly the bzz overlay address
+ //
+ // for now we have no way of setting bootnodes or lightnodes in sims
+ // so we just set them as false
+ // they should perhaps be possible to override them with AddNodeOption
+ bzzKey := network.PrivateKeyToBzzKey(conf.PrivateKey)
+ bzzAddr := network.NewENRAddrEntry(bzzKey)
+
+ var lightnode network.ENRLightNodeEntry
+ var bootnode network.ENRBootNodeEntry
+ conf.Record.Set(bzzAddr)
+ conf.Record.Set(&lightnode)
+ conf.Record.Set(&bootnode)
+
+ // Add the bzz address to the node config
node, err := s.Net.NewNodeWithConfig(conf)
if err != nil {
return id, err
}
+
return node.ID(), s.Net.Start(node.ID())
}