mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
overlay sim fix
This commit is contained in:
parent
7c0a205335
commit
01fb8ed943
2 changed files with 9 additions and 14 deletions
|
|
@ -328,12 +328,6 @@ func (self *Conn) nodesUp() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// sa := node.Adapter()
|
||||
// err := sa.Stop()
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// Start(id) starts up the node (relevant only for instance with own p2p or remote)
|
||||
func (self *Network) Start(id *adapters.NodeId) error {
|
||||
node := self.GetNode(id)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ type Network struct {
|
|||
|
||||
// SimNode is the adapter used by Swarm simulations.
|
||||
type SimNode struct {
|
||||
connect func(s string) error
|
||||
hive *network.Hive
|
||||
adapters.NodeAdapter
|
||||
}
|
||||
|
|
@ -41,11 +42,7 @@ func af() <-chan time.Time {
|
|||
// Start() starts up the hive
|
||||
// makes SimNode implement *NodeAdapter
|
||||
func (self *SimNode) Start() error {
|
||||
connect := func(s string) error {
|
||||
id := network.HexToBytes(s)
|
||||
return self.Connect(id)
|
||||
}
|
||||
return self.hive.Start(connect, af)
|
||||
return self.hive.Start(self.connect, af)
|
||||
}
|
||||
|
||||
// Stop() shuts down the hive
|
||||
|
|
@ -71,7 +68,11 @@ func (self *Network) NewSimNode(conf *simulations.NodeConfig) adapters.NodeAdapt
|
|||
// bzz protocol Run function. messaging through SimPipe
|
||||
ct := network.BzzCodeMap(network.HiveMsgs...) // bzz protocol code map
|
||||
na.Run = network.Bzz(addr.OverlayAddr(), pp, na, ct, nil).Run
|
||||
connect := func(s string) error {
|
||||
return self.Connect(id, adapters.NewNodeIdFromHex(s))
|
||||
}
|
||||
return &SimNode{
|
||||
connect: connect,
|
||||
hive: pp,
|
||||
NodeAdapter: na,
|
||||
}
|
||||
|
|
@ -106,7 +107,7 @@ func NewSessionController() (*simulations.ResourceController, chan bool) {
|
|||
if parent != nil {
|
||||
parent.SetResource(conf.Id, c)
|
||||
}
|
||||
ids := p2ptest.RandomNodeIds(5)
|
||||
ids := p2ptest.RandomNodeIds(50)
|
||||
for _, id := range ids {
|
||||
ppnet.NewNode(&simulations.NodeConfig{Id: id})
|
||||
ppnet.Start(id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue