Brian Picciano
8c3e6a2845
In a world where the daemon can manage more than one network, the Daemon is really responsible only for knowing which networks are currently joined, creating/joining/leaving networks, and routing incoming RPC requests to the correct network handler as needed. The new network package, with its Network interface, inherits most of the logic that Daemon used to have, leaving Daemon only the parts needed for the functionality just described. There's a lot of cleanup done here in order to really nail down the separation of concerns between the two, especially around directory creation.
29 lines
875 B
Go
29 lines
875 B
Go
package network
|
|
|
|
import (
|
|
"isle/daemon/daecommon"
|
|
"isle/daemon/jsonrpc2"
|
|
)
|
|
|
|
const (
|
|
errCodeInitializing = daecommon.ErrorCodeRangeNetwork + iota
|
|
errCodeInvalidConfig
|
|
errCodeHostNotFound
|
|
)
|
|
|
|
var (
|
|
// ErrInitializing is returned when a network is unavailable due to still
|
|
// being initialized.
|
|
ErrInitializing = jsonrpc2.NewError(errCodeInitializing, "Network is being initialized")
|
|
|
|
// ErrInvalidConfig is returned when the daemon's configuration is invalid
|
|
// for an operation being attempted.
|
|
//
|
|
// The Data field will be a string containing further details.
|
|
ErrInvalidConfig = jsonrpc2.NewError(errCodeInvalidConfig, "Invalid daemon config")
|
|
|
|
// ErrHostNotFound is returned when performing an operation which expected a
|
|
// host to exist in the network, but that host wasn't found.
|
|
ErrHostNotFound = jsonrpc2.NewError(errCodeHostNotFound, "Host not found")
|
|
)
|