utils

package
v0.0.0-...-d578c97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2014 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const NodeIDPrefix = 144

Variables

View Source
var DefaultConfig = Config{
	P: "9200-9210",
	B: []string{
		"localhost:9200-9210",
		"h2so5.net:9200-9210",
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	P string
	B []string
}

func (Config) Bootstrap

func (c Config) Bootstrap() []net.UDPAddr

func (Config) Ports

func (c Config) Ports() []int

type Namespace

type Namespace [4]byte

func (Namespace) Match

func (n Namespace) Match(m Namespace) bool

type NodeID

type NodeID struct {
	Digest PublicKeyDigest
	NS     Namespace
}

NodeID represents a 160-bit node identifier.

func NewNodeID

func NewNodeID(ns Namespace, data PublicKeyDigest) NodeID

NewNodeID generates NodeID from the given namespace and publickey digest.

func NewNodeIDFromBytes

func NewNodeIDFromBytes(b []byte) (NodeID, error)

NewNodeIDFromBytes generates NodeID from the given big-endian byte array.

func NewNodeIDFromString

func NewNodeIDFromString(str string) (NodeID, error)

NewNodeIDFromString generates NodeID from the given base58-encoded string.

func NewRandomNodeID

func NewRandomNodeID(ns Namespace) NodeID

func (NodeID) Bytes

func (id NodeID) Bytes() []byte

Bytes returns identifier as a big-endian byte array.

func (NodeID) String

func (id NodeID) String() string

String returns identifier as a base58-encoded byte array.

type NodeInfo

type NodeInfo struct {
	ID   NodeID
	Addr net.Addr
}

type NodeInfoSorter

type NodeInfoSorter struct {
	Nodes []NodeInfo
	ID    NodeID
}

func (NodeInfoSorter) Len

func (p NodeInfoSorter) Len() int

func (NodeInfoSorter) Less

func (p NodeInfoSorter) Less(i, j int) bool

func (NodeInfoSorter) Swap

func (p NodeInfoSorter) Swap(i, j int)

type PrivateKey

type PrivateKey struct {
	PublicKey
	// contains filtered or unexported fields
}

PrivateKey represents an ECDSA private key.

func GeneratePrivateKey

func GeneratePrivateKey() *PrivateKey

GeneratePrivateKey generates new ECDSA key pair.

func PrivateKeyFromString

func PrivateKeyFromString(str string) *PrivateKey

PrivateKeyFromString generates PrivateKey from the given base58-encoded string.

func (*PrivateKey) MarshalText

func (p *PrivateKey) MarshalText() (text []byte, err error)

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(data []byte) *Signature

func (*PrivateKey) String

func (p *PrivateKey) String() string

String returns the private key as a base58-encoded byte array.

func (*PrivateKey) UnmarshalText

func (p *PrivateKey) UnmarshalText(text []byte) error

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents an ECDSA public key.

func (*PublicKey) Digest

func (p *PublicKey) Digest() PublicKeyDigest

Digest returns a SHA-1 digest for the public key.

func (*PublicKey) IsZero

func (p *PublicKey) IsZero() bool

func (*PublicKey) MarshalText

func (p *PublicKey) MarshalText() (text []byte, err error)

func (*PublicKey) UnmarshalText

func (p *PublicKey) UnmarshalText(text []byte) error

func (*PublicKey) Verify

func (p *PublicKey) Verify(data []byte, sign *Signature) bool

type PublicKeyDigest

type PublicKeyDigest [20]byte

func (PublicKeyDigest) Bit

func (d PublicKeyDigest) Bit(i int) uint

func (PublicKeyDigest) BitLen

func (d PublicKeyDigest) BitLen() int

func (PublicKeyDigest) Cmp

func (PublicKeyDigest) Log2int

func (d PublicKeyDigest) Log2int() int

func (PublicKeyDigest) String

func (p PublicKeyDigest) String() string

func (PublicKeyDigest) Xor

type Signature

type Signature struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL