mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 15:46:43 +00:00
p2p/simulations: Set node ID if not set
Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
parent
f079529445
commit
be95e9ecb3
1 changed files with 5 additions and 0 deletions
|
|
@ -201,6 +201,11 @@ func (self *Network) NewNode() (*Node, error) {
|
|||
func (self *Network) NewNodeWithConfig(conf *adapters.NodeConfig) (*Node, error) {
|
||||
self.lock.Lock()
|
||||
defer self.lock.Unlock()
|
||||
if conf.ID == (discover.NodeID{}) {
|
||||
c := adapters.RandomNodeConfig()
|
||||
conf.ID = c.ID
|
||||
conf.PrivateKey = c.PrivateKey
|
||||
}
|
||||
id := conf.ID
|
||||
if conf.Name == "" {
|
||||
conf.Name = fmt.Sprintf("node%02d", len(self.Nodes)+1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue