|
|
@ -20,6 +20,7 @@ import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"maps" |
|
|
|
"math" |
|
|
|
"math" |
|
|
|
"net" |
|
|
|
"net" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
@ -215,10 +216,7 @@ func (sn *SimNode) ServeRPC(conn *websocket.Conn) error { |
|
|
|
// simulation_snapshot RPC method
|
|
|
|
// simulation_snapshot RPC method
|
|
|
|
func (sn *SimNode) Snapshots() (map[string][]byte, error) { |
|
|
|
func (sn *SimNode) Snapshots() (map[string][]byte, error) { |
|
|
|
sn.lock.RLock() |
|
|
|
sn.lock.RLock() |
|
|
|
services := make(map[string]node.Lifecycle, len(sn.running)) |
|
|
|
services := maps.Clone(sn.running) |
|
|
|
for name, service := range sn.running { |
|
|
|
|
|
|
|
services[name] = service |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sn.lock.RUnlock() |
|
|
|
sn.lock.RUnlock() |
|
|
|
if len(services) == 0 { |
|
|
|
if len(services) == 0 { |
|
|
|
return nil, errors.New("no running services") |
|
|
|
return nil, errors.New("no running services") |
|
|
@ -315,11 +313,7 @@ func (sn *SimNode) Services() []node.Lifecycle { |
|
|
|
func (sn *SimNode) ServiceMap() map[string]node.Lifecycle { |
|
|
|
func (sn *SimNode) ServiceMap() map[string]node.Lifecycle { |
|
|
|
sn.lock.RLock() |
|
|
|
sn.lock.RLock() |
|
|
|
defer sn.lock.RUnlock() |
|
|
|
defer sn.lock.RUnlock() |
|
|
|
services := make(map[string]node.Lifecycle, len(sn.running)) |
|
|
|
return maps.Clone(sn.running) |
|
|
|
for name, service := range sn.running { |
|
|
|
|
|
|
|
services[name] = service |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return services |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Server returns the underlying p2p.Server
|
|
|
|
// Server returns the underlying p2p.Server
|
|
|
|