add Network.Init method
This commit is contained in:
		| @@ -144,6 +144,18 @@ func newNetwork(opts ...Option) Network { | |||||||
| 	return 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 | // Options returns network options | ||||||
| func (n *network) Options() Options { | func (n *network) Options() Options { | ||||||
| 	n.RLock() | 	n.RLock() | ||||||
|   | |||||||
| @@ -38,6 +38,8 @@ type Node interface { | |||||||
| type Network interface { | type Network interface { | ||||||
| 	// Node is network node | 	// Node is network node | ||||||
| 	Node | 	Node | ||||||
|  | 	// Initialise options | ||||||
|  | 	Init(...Option) error | ||||||
| 	// Options returns the network options | 	// Options returns the network options | ||||||
| 	Options() Options | 	Options() Options | ||||||
| 	// Name of the network | 	// Name of the network | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user