mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
p2p/simulations: Add external networks to HTTP server
Signed-off-by: Lewis Marshall <lewis@lmars.net>
This commit is contained in:
parent
177e720b08
commit
a92a341450
1 changed files with 7 additions and 0 deletions
|
|
@ -255,6 +255,10 @@ type ServerConfig struct {
|
|||
// network
|
||||
NewAdapter func() adapters.NodeAdapter
|
||||
|
||||
// ExternalNetworks are externally defined networks to expose via the
|
||||
// HTTP server
|
||||
ExternalNetworks map[string]*Network
|
||||
|
||||
// Mocker is the function which will be called when a client sends a
|
||||
// POST request to /networks/<netid>/mock and is expected to
|
||||
// generate some mock events in the network
|
||||
|
|
@ -286,6 +290,9 @@ func NewServer(config *ServerConfig) *Server {
|
|||
router: httprouter.New(),
|
||||
networks: make(map[string]*Network),
|
||||
}
|
||||
for name, network := range config.ExternalNetworks {
|
||||
s.networks[name] = network
|
||||
}
|
||||
|
||||
s.OPTIONS("/networks", s.Options)
|
||||
s.POST("/networks", s.CreateNetwork)
|
||||
|
|
|
|||
Loading…
Reference in a new issue