aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/simulations/adapters/inproc.go
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/simulations/adapters/inproc.go')
-rw-r--r--p2p/simulations/adapters/inproc.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/p2p/simulations/adapters/inproc.go b/p2p/simulations/adapters/inproc.go
index b68d08f39..c1b032a0d 100644
--- a/p2p/simulations/adapters/inproc.go
+++ b/p2p/simulations/adapters/inproc.go
@@ -296,6 +296,13 @@ func (sn *SimNode) Stop() error {
return sn.node.Stop()
}
+// Service returns a running service by name
+func (sn *SimNode) Service(name string) node.Service {
+ sn.lock.RLock()
+ defer sn.lock.RUnlock()
+ return sn.running[name]
+}
+
// Services returns a copy of the underlying services
func (sn *SimNode) Services() []node.Service {
sn.lock.RLock()
@@ -307,6 +314,17 @@ func (sn *SimNode) Services() []node.Service {
return services
}
+// ServiceMap returns a map by names of the underlying services
+func (sn *SimNode) ServiceMap() map[string]node.Service {
+ sn.lock.RLock()
+ defer sn.lock.RUnlock()
+ services := make(map[string]node.Service, len(sn.running))
+ for name, service := range sn.running {
+ services[name] = service
+ }
+ return services
+}
+
// Server returns the underlying p2p.Server
func (sn *SimNode) Server() *p2p.Server {
return sn.node.Server()