Documentation ¶
Index ¶
- Variables
- func CheckUserPort(port uint32) bool
- func GenerateTestNode(t *testing.T) (*LocalNode, Node)
- func GenerateTestNodeWithConfig(t *testing.T, config config.Config) (*LocalNode, Node)
- func GetUnboundedPort() (int, error)
- func StringFromNode(n Node) string
- func XOR(a, b []byte) []byte
- type DhtID
- func (id DhtID) Closer(id1 DhtID, id2 DhtID) bool
- func (id DhtID) CommonPrefixLen(o DhtID) int
- func (id DhtID) Distance(id1 DhtID) *big.Int
- func (id DhtID) Equals(other DhtID) bool
- func (id DhtID) Less(o DhtID) bool
- func (id DhtID) Pretty() string
- func (id DhtID) SortByDistance(ids []DhtID) []DhtID
- func (id DhtID) String() string
- func (id DhtID) Xor(o DhtID) DhtID
- func (id DhtID) ZeroPrefixLen() int
- type LocalNode
- type Node
Constants ¶
This section is empty.
Variables ¶
var ErrFailedToCreate = errors.New("Failed to create local test node")
ErrFailedToCreate is returned when we fail to create a node
Functions ¶
func CheckUserPort ¶
CheckUserPort tries to listen on a port and check whether is usable or not
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.
func StringFromNode ¶
StringFromNode generates a string that represent a node in the network in following format: 126.0.0.1:3572/r9gJRWVB9JVPap2HKnduoFySvHtVTfJdQ4WG8DriUD82.
Types ¶
type DhtID ¶
type DhtID []byte
DhtID is a dht-compatible DhtID using the XOR keyspace.
func NewDhtIDFromBase58 ¶
NewDhtIDFromBase58 creates a new dht DhtID from provided base58 encoded binary data.
func NewDhtIDFromHex ¶
NewDhtIDFromHex creates a new dht DhtID from provided hex-encoded string.
func (DhtID) CommonPrefixLen ¶
CommonPrefixLen returns the common shared prefix length in BITS of the binary numbers represented by the ids. tradeoff the pretty func we had with this more efficient one. (faster than libp2p and eth)
func (DhtID) Less ¶
Less returns true iff the binary number represented by DhtID is less than the number represented by o.
func (DhtID) SortByDistance ¶
SortByDistance ids based on xor-distance from DhtID.
func (DhtID) ZeroPrefixLen ¶
ZeroPrefixLen returns the zero prefix length of the binary number represnted by DhtID in bits.
type LocalNode ¶
type LocalNode struct { Node // contains filtered or unexported fields }
LocalNode implementation.
func NewNodeIdentity ¶
NewNodeIdentity creates a new local node without attempting to restore node from local store.
func (*LocalNode) NetworkID ¶
NetworkID returns the local node's network id (testnet/mainnet, etc..)
func (*LocalNode) PrivateKey ¶
func (n *LocalNode) PrivateKey() crypto.PrivateKey
PrivateKey returns this node's private key.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is the basic node identity struct
var EmptyNode Node
EmptyNode represents an uninitialized node
func GenerateRandomNodeData ¶
func GenerateRandomNodeData() Node
GenerateRandomNodeData generates a remote random node data for testing.
func GenerateRandomNodesData ¶
GenerateRandomNodesData generates remote nodes data for testing.
func NewNodeFromString ¶
NewNodeFromString creates a remote identity from a string in the following format: 126.0.0.1:3572/r9gJRWVB9JVPap2HKnduoFySvHtVTfJdQ4WG8DriUD82 .
func SortByDhtID ¶
SortByDhtID Sorts a Node array by DhtID id, returns a sorted array