From 01492997ea65653d4934e6d3fa0b35c95d8ca95e Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 13 Oct 2019 12:38:13 +0100 Subject: [PATCH] add Network.Init method --- network/default.go | 12 ++++++++++++ network/network.go | 2 ++ 2 files changed, 14 insertions(+) diff --git a/network/default.go b/network/default.go index 8000255d..b1dfd8d9 100644 --- a/network/default.go +++ b/network/default.go @@ -144,6 +144,18 @@ func newNetwork(opts ...Option) Network { return network } +func (n *network) Init(opts ...Option) error { + n.Lock() + defer n.Unlock() + + // TODO: maybe only allow reinit of certain opts + for _, o := range opts { + o(&n.options) + } + + return nil +} + // Options returns network options func (n *network) Options() Options { n.RLock() diff --git a/network/network.go b/network/network.go index ef303992..e927241b 100644 --- a/network/network.go +++ b/network/network.go @@ -38,6 +38,8 @@ type Node interface { type Network interface { // Node is network node Node + // Initialise options + Init(...Option) error // Options returns the network options Options() Options // Name of the network