Documentation
¶
Index ¶
- Variables
- type ChainConfig
- type LegacyNetwork
- type Network
- type NetworkKind
- type NetworkManager
- func (nm *NetworkManager) AddNode(ctx context.Context, networkID string, nodeParams *NodeParams) (*Node, error)
- func (nm *NetworkManager) CreateNetwork(ctx context.Context, params *NetworkParams) (*Network, error)
- func (nm *NetworkManager) DeleteNetwork(ctx context.Context, networkID string) error
- func (nm *NetworkManager) GetNetwork(networkID string) (*Network, error)
- func (nm *NetworkManager) GetNodeStatus(ctx context.Context, networkID, nodeID string) (*NodeStatus, error)
- func (nm *NetworkManager) ListNetworks() []*Network
- func (nm *NetworkManager) RemoveNode(ctx context.Context, networkID, nodeID string) error
- func (nm *NetworkManager) StartNetwork(ctx context.Context, networkID string) error
- func (nm *NetworkManager) StopNetwork(ctx context.Context, networkID string) error
- type NetworkParams
- type NetworkStatus
- type NetworkType
- type Node
- type NodeParams
- type NodeStatus
- type NodeType
Constants ¶
This section is empty.
Variables ¶
var ( // UndefinedNetwork is an undefined network UndefinedNetwork = LegacyNetwork{ Kind: Undefined, ID: 0, Name: "undefined", } // MainnetNetwork is the mainnet network MainnetNetwork = LegacyNetwork{ Kind: Mainnet, ID: constants.MainnetID, Endpoint: "https://api.lux.network", Name: constants.MainnetName, } // TestnetNetwork is the testnet network TestnetNetwork = LegacyNetwork{ Kind: Testnet, ID: constants.TestnetID, Endpoint: "https://api-test.lux.network", Name: constants.TestnetName, } // LocalNetwork is the local network LocalNetwork = LegacyNetwork{ Kind: Local, ID: constants.LocalID, Endpoint: "http://127.0.0.1:9630", Name: constants.LocalName, } )
Functions ¶
This section is empty.
Types ¶
type ChainConfig ¶
ChainConfig defines configuration for a chain
type LegacyNetwork ¶ added in v0.2.0
type LegacyNetwork struct {
Kind NetworkKind
ID uint32
Endpoint string
Name string
}
LegacyNetwork represents a network configuration with endpoint This is for compatibility with existing code
func GetNetworkByName ¶ added in v0.2.0
func GetNetworkByName(name string) (LegacyNetwork, error)
GetNetworkByName returns a network by name
func NetworkFromNetworkID ¶ added in v0.2.0
func NetworkFromNetworkID(networkID uint32) LegacyNetwork
NetworkFromNetworkID returns a network from network ID
type Network ¶
type Network struct {
ID string
Name string
Type NetworkType
Status NetworkStatus
Nodes []*Node
ChainIDs []string
CreatedAt time.Time
}
Network represents a managed Lux network
type NetworkKind ¶ added in v0.2.0
type NetworkKind int
NetworkKind represents the kind of network
const ( Undefined NetworkKind = iota Mainnet Testnet Local Devnet )
func (NetworkKind) String ¶ added in v0.2.0
func (k NetworkKind) String() string
String returns string representation of NetworkKind
type NetworkManager ¶
type NetworkManager struct {
// contains filtered or unexported fields
}
NetworkManager handles all network operations using netrunner
func NewNetworkManager ¶
func NewNetworkManager(config *config.NetworkConfig, logger log.Logger) (*NetworkManager, error)
NewNetworkManager creates a new network manager
func (*NetworkManager) AddNode ¶
func (nm *NetworkManager) AddNode(ctx context.Context, networkID string, nodeParams *NodeParams) (*Node, error)
AddNode adds a new node to the network
func (*NetworkManager) CreateNetwork ¶
func (nm *NetworkManager) CreateNetwork(ctx context.Context, params *NetworkParams) (*Network, error)
CreateNetwork creates a new network
func (*NetworkManager) DeleteNetwork ¶
func (nm *NetworkManager) DeleteNetwork(ctx context.Context, networkID string) error
DeleteNetwork deletes a network
func (*NetworkManager) GetNetwork ¶
func (nm *NetworkManager) GetNetwork(networkID string) (*Network, error)
GetNetwork returns a network by ID
func (*NetworkManager) GetNodeStatus ¶
func (nm *NetworkManager) GetNodeStatus(ctx context.Context, networkID, nodeID string) (*NodeStatus, error)
GetNodeStatus returns the status of a node
func (*NetworkManager) ListNetworks ¶
func (nm *NetworkManager) ListNetworks() []*Network
ListNetworks returns all networks
func (*NetworkManager) RemoveNode ¶
func (nm *NetworkManager) RemoveNode(ctx context.Context, networkID, nodeID string) error
RemoveNode removes a node from the network
func (*NetworkManager) StartNetwork ¶
func (nm *NetworkManager) StartNetwork(ctx context.Context, networkID string) error
StartNetwork starts a stopped network
func (*NetworkManager) StopNetwork ¶
func (nm *NetworkManager) StopNetwork(ctx context.Context, networkID string) error
StopNetwork stops a running network
type NetworkParams ¶
type NetworkParams struct {
Name string
Type NetworkType
NumNodes int
BinaryPath string
ConfigPath string
DataDir string
LogLevel string
HTTPPort int
StakingPort int
EnableStaking bool
EnableMonitoring bool
ChainConfigs []ChainConfig
}
NetworkParams defines parameters for creating a network
type NetworkStatus ¶
type NetworkStatus string
NetworkStatus defines the status of a network
const ( NetworkStatusCreating NetworkStatus = "creating" NetworkStatusRunning NetworkStatus = "running" NetworkStatusStopped NetworkStatus = "stopped" NetworkStatusError NetworkStatus = "error" )
type NetworkType ¶
type NetworkType string
NetworkType defines the type of network
const ( NetworkTypeMainnet NetworkType = "mainnet" NetworkTypeTestnet NetworkType = "testnet" NetworkTypeLocal NetworkType = "local" NetworkTypeCustom NetworkType = "custom" )
type Node ¶
type Node struct {
ID string
NodeID string
Type NodeType
Status NodeStatus
Endpoint string
StakeAmount uint64
PublicKey string
}
Node represents a node in the network
type NodeParams ¶
NodeParams defines parameters for adding a node
type NodeStatus ¶
type NodeStatus string
NodeStatus defines the status of a node
const ( NodeStatusBootstrapping NodeStatus = "bootstrapping" NodeStatusHealthy NodeStatus = "healthy" NodeStatusUnhealthy NodeStatus = "unhealthy" NodeStatusStopped NodeStatus = "stopped" )