Documentation ¶
Overview ¶
Package address contains the types used by ruvchain to represent IPv6 addresses or prefixes, as well as functions for working with these types. Of particular importance are the functions used to derive addresses or subnets from a NodeID, or to get the NodeID and bitmask of the bits visible from an address, which is needed for DHT searches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPrefix ¶
func GetPrefix() [1]byte
GetPrefix returns the address prefix used by ruvchain. The current implementation requires this to be a multiple of 8 bits + 7 bits. The 8th bit of the last byte is used to signal nodes (0) or /64 prefixes (1). Nodes that configure this differently will be unable to communicate with each other using IP packets, though routing and the DHT machinery *should* still work.
Types ¶
type Address ¶
type Address [16]byte
Address represents an IPv6 address in the ruvchain address range.
func AddrForKey ¶
AddrForKey takes an ed25519.PublicKey as an argument and returns an *Address. This function returns nil if the key length is not ed25519.PublicKeySize. This address begins with the contents of GetPrefix(), with the last bit set to 0 to indicate an address. The following 8 bits are set to the number of leading 1 bits in the bitwise inverse of the public key. The bitwise inverse of the key, excluding the leading 1 bits and the first leading 0 bit, is truncated to the appropriate length and makes up the remainder of the address.
type Subnet ¶
type Subnet [8]byte
Subnet represents an IPv6 /64 subnet in the ruvchain subnet range.
func SubnetForKey ¶
SubnetForKey takes an ed25519.PublicKey as an argument and returns a *Subnet. This function returns nil if the key length is not ed25519.PublicKeySize. The subnet begins with the address prefix, with the last bit set to 1 to indicate a prefix. The following 8 bits are set to the number of leading 1 bits in the bitwise inverse of the key. The bitwise inverse of the key, excluding the leading 1 bits and the first leading 0 bit, is truncated to the appropriate length and makes up the remainder of the subnet.