Documentation ¶
Index ¶
Constants ¶
const DiscoveryPortParam = "disc"
const SCHEME = "spacemesh"
Variables ¶
var ErrFailedToCreate = errors.New("failed to create local test node")
ErrFailedToCreate is returned when we fail to create a node
Functions ¶
func GenerateTestNode ¶
GenerateTestNode generates a local test node without persisting data to local store and with default config value.
func GenerateTestNodeWithConfig ¶
GenerateTestNodeWithConfig creates a local test node without persisting data to local store.
func GetUnboundedPort ¶
GetUnboundedPort returns a port that is for sure unbounded or an error.
Types ¶
type LocalNode ¶
type LocalNode struct {
// contains filtered or unexported fields
}
LocalNode implementation.
func LoadIdentity ¶
func NewNodeIdentity ¶
NewNodeIdentity creates a new local node without attempting to restore node from local store.
func ReadFirstNodeData ¶
Read node data from the data folder. Reads a random node from the data folder if more than one node data file is persisted. To load a specific node on startup - users need to pass the node id using a cli arg.
func (*LocalNode) PersistData ¶
Persist node's data to local store.
func (LocalNode) PrivateKey ¶
func (n LocalNode) PrivateKey() p2pcrypto.PrivateKey
PrivateKey returns this node's private key.
type NodeInfo ¶
NodeInfo is a discovery parsed structure to store a node's address and key.
func GenerateRandomNodeData ¶
func GenerateRandomNodeData() *NodeInfo
GenerateRandomNodeData generates a remote random node data for testing.
func GenerateRandomNodesData ¶
GenerateRandomNodesData generates remote nodes data for testing.
func ParseNode ¶
ParseNode parses a node designator.
There are two basic forms of node designators
- incomplete nodes, which only have the public key (node ID)
- complete nodes, which contain the public key and IP/Port information
For incomplete nodes, the designator must look like one of these
spacemesh://<base58 node id> <hex node id>
For complete nodes, the node ID is encoded in the username portion of the URL, separated from the host by an @ sign. The hostname can only be given as an IP address, DNS domain names are not allowed. The port in the host name section is the TCP listening port. If the TCP and UDP (discovery) ports differ, the UDP port is specified as query parameter "disc".
In the following example, the node URL describes a node with IP address 10.3.58.6, TCP listening port 7513 and UDP discovery port 7513.
spacemesh://<base58 node id>@10.3.58.6:7513?disc=7513