Documentation
¶
Overview ¶
kbn runs a bootstrap node for the Klaytn Node Discovery Protocol.
A bootstrap node is a kind of registry service which has every nodes' information and delivers it to a querying node to help the node to join the network.
Source Files ¶
Each file contains the following contents
- api.go : Provides various APIs to use bootnode services
- backend.go : Provides supporting functions for APIs
- config.go : Provides `bootnodeConfig` which contains a configuration and accompanying setter and parser functions
- main.go : Main entry point of the application
- node.go : Provides `Node` struct which defines what kind of APIs can be provided through which port and protocols
Index ¶
- Constants
- Variables
- func DefaultIPCEndpoint(clientIdentifier string) string
- func SetAuthorizedNodes(ctx *cli.Context, cfg *GuardianConfig)
- func SetIPC(ctx *cli.Context, cfg *GuardianConfig)
- func SetP2PConfig(ctx *cli.Context, cfg *GuardianConfig)
- func SplitAndTrim(input string) []string
- type GuardianConfig
- type Node
- func (n *Node) APIs() []rpc.API
- func (n *Node) Attach() (*rpc.Client, error)
- func (n *Node) DataDir() string
- func (n *Node) IPCEndpoint() string
- func (n *Node) RPCHandler() (*rpc.Server, error)
- func (n *Node) Restart() error
- func (n *Node) Server() p2p.Server
- func (n *Node) Start() error
- func (n *Node) Stop() error
- func (n *Node) Wait()
- type PrivateGuardianAdminAPI
- type PublicGuardianAdminAPI
Constants ¶
const ( GenerateNodeKeySpecified = iota NoPrivateKeyPathSpecified NodeKeyDuplicated WriteOutAddress GoodToGo )
Variables ¶
Functions ¶
func DefaultIPCEndpoint ¶
func SetAuthorizedNodes ¶
func SetAuthorizedNodes(ctx *cli.Context, cfg *GuardianConfig)
func SetIPC ¶
func SetIPC(ctx *cli.Context, cfg *GuardianConfig)
setIPC creates an IPC path configuration from the set command line flags, returning an empty string if IPC was explicitly disabled, or the set path.
func SetP2PConfig ¶
func SetP2PConfig(ctx *cli.Context, cfg *GuardianConfig)
func SplitAndTrim ¶
splitAndTrim splits input separated by a comma and trims excessive white space from the substrings.
Types ¶
type GuardianConfig ¶
type GuardianConfig struct {
// Authorized Nodes are used as pre-configured nodes list which are only
// bonded with this bootnode.
AuthorizedNodes []*discover.Node
// DataDir is the file system folder the node should use for any data storage
// requirements. The configured data directory will not be directly shared with
// registered services, instead those can use utility methods to create/access
// databases or flat files. This enables ephemeral nodes which can fully reside
// in memory.
DataDir string
// IPCPath is the requested location to place the IPC endpoint. If the path is
// a simple file name, it is placed inside the data directory (or on the root
// pipe path on Windows), whereas if it's a resolvable path name (absolute or
// relative), then that specific path is enforced. An empty path disables IPC.
IPCPath string `toml:",omitempty"`
// Logger is a custom logger to use with the p2p.Server.
Logger log.Logger `toml:",omitempty"`
// contains filtered or unexported fields
}
func NewGuardianConfig ¶
func NewGuardianConfig(ctx *cli.Context) *GuardianConfig
func (*GuardianConfig) CheckCMDState ¶
func (cfg *GuardianConfig) CheckCMDState() int
func (*GuardianConfig) DoWriteOutAddress ¶
func (cfg *GuardianConfig) DoWriteOutAddress()
func (*GuardianConfig) GenerateNodeKey ¶
func (cfg *GuardianConfig) GenerateNodeKey()
func (*GuardianConfig) IPCEndpoint ¶
func (c *GuardianConfig) IPCEndpoint() string
IPCEndpoint resolves an IPC endpoint based on a configured value, taking into account the set data folders as well as the designated platform we're currently running on.
func (*GuardianConfig) ReadNodeKey ¶
func (cfg *GuardianConfig) ReadNodeKey() error
func (*GuardianConfig) ValidateNetworkParameter ¶
func (cfg *GuardianConfig) ValidateNetworkParameter() error
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a container on which services can be registered.
func New ¶
func New(conf *GuardianConfig) (*Node, error)
New creates a new P2P node, ready for protocol registration.
func (*Node) DataDir ¶
DataDir retrieves the current datadir used by the protocol stack. Deprecated: No files should be stored in this directory, use InstanceDir instead.
func (*Node) IPCEndpoint ¶
IPCEndpoint retrieves the current IPC endpoint used by the protocol stack.
func (*Node) RPCHandler ¶
RPCHandler returns the in-process RPC request handler.
func (*Node) Restart ¶
Restart terminates a running node and boots up a new one in its place. If the node isn't running, an error is returned.
func (*Node) Server ¶
Server retrieves the currently running P2P network layer. This method is meant only to inspect fields of the currently running server, life cycle management should be left to this Node entity.
type PrivateGuardianAdminAPI ¶
type PrivateGuardianAdminAPI struct {
// contains filtered or unexported fields
}
PrivateAdminAPI is the collection of administrative API methods exposed only over a secure RPC channel.
func NewPrivateGuardianAdminAPI ¶
func NewPrivateGuardianAdminAPI(node *Node) *PrivateGuardianAdminAPI
NewPrivateAdminAPI creates a new API definition for the private admin methods of the node itself.
func (*PrivateGuardianAdminAPI) AddPeer ¶
func (api *PrivateGuardianAdminAPI) AddPeer(url string) (bool, error)
AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.
func (*PrivateGuardianAdminAPI) PeerEvents ¶
func (api *PrivateGuardianAdminAPI) PeerEvents(ctx context.Context) (*rpc.Subscription, error)
PeerEvents creates an RPC subscription which receives peer events from the node's p2p.Server
func (*PrivateGuardianAdminAPI) RemovePeer ¶
func (api *PrivateGuardianAdminAPI) RemovePeer(url string) (bool, error)
RemovePeer disconnects from a a remote node if the connection exists
type PublicGuardianAdminAPI ¶
type PublicGuardianAdminAPI struct {
// contains filtered or unexported fields
}
PublicAdminAPI is the collection of administrative API methods exposed over both secure and unsecure RPC channels.
func NewPublicGuardianAdminAPI ¶
func NewPublicGuardianAdminAPI(node *Node) *PublicGuardianAdminAPI
NewPublicAdminAPI creates a new API definition for the public admin methods of the node itself.
func (*PublicGuardianAdminAPI) Datadir ¶
func (api *PublicGuardianAdminAPI) Datadir() string
Datadir retrieves the current data directory the node is using.