Documentation
¶
Index ¶
- type JSONPeerSet
- type Peer
- type PeerSet
- func (peerSet *PeerSet) Hash() ([]byte, error)
- func (peerSet *PeerSet) Hex() string
- func (peerSet *PeerSet) IDs() []uint32
- func (peerSet *PeerSet) Len() int
- func (peerSet *PeerSet) Marshal() ([]byte, error)
- func (peerSet *PeerSet) PubKeys() []string
- func (peerSet *PeerSet) SuperMajority() int
- func (peerSet *PeerSet) TrustCount() int
- func (peerSet *PeerSet) WithNewPeer(peer *Peer) *PeerSet
- func (peerSet *PeerSet) WithRemovedPeer(peer *Peer) *PeerSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONPeerSet ¶ added in v0.4.1
type JSONPeerSet struct {
// contains filtered or unexported fields
}
JSONPeerSet is used to provide peer persistence on disk in the form of a JSON file.
func NewJSONPeerSet ¶ added in v0.4.1
func NewJSONPeerSet(base string, isCurrent bool) *JSONPeerSet
NewJSONPeerSet creates a new JSONPeerSet.
func (*JSONPeerSet) PeerSet ¶ added in v0.4.1
func (j *JSONPeerSet) PeerSet() (*PeerSet, error)
PeerSet creates a PeerSet from the JSONPeerSet
func (*JSONPeerSet) Write ¶ added in v0.4.1
func (j *JSONPeerSet) Write(peers []*Peer) error
Write persists a PeerSet to a JSON file in path
type Peer ¶
type Peer struct { NetAddr string PubKeyHex string Moniker string // contains filtered or unexported fields }
Peer is a struct that holds Peer data
func ExcludePeer ¶
ExcludePeer is used to exclude a single peer from a list of peers.
func (*Peer) Marshal ¶ added in v0.4.1
Marshal marshals the json representation of the peer. Note that this excludes the id field, forcing consumers to recalculate it.
func (*Peer) PubKeyBytes ¶
PubKeyBytes converts hex string representation of the public key and returns a byte array
func (*Peer) PubKeyString ¶ added in v0.5.0
PubKeyString returns the upper-case version of PubKeyHex. It is used for indexing in maps with string keys.
type PeerSet ¶ added in v0.4.1
type PeerSet struct { Peers []*Peer `json:"peers"` ByPubKey map[string]*Peer `json:"-"` ByID map[uint32]*Peer `json:"-"` // contains filtered or unexported fields }
PeerSet is a set of Peers forming a consensus network
func NewPeerSet ¶ added in v0.4.1
NewPeerSet creates a new PeerSet from a list of Peers
func NewPeerSetFromPeerSliceBytes ¶ added in v0.4.1
NewPeerSetFromPeerSliceBytes creates a new PeerSet from a peerSlice in Bytes format
func (*PeerSet) Hash ¶ added in v0.4.1
Hash uniquely identifies a PeerSet. It is computed by hashing (SHA256) their public keys together, one by one.
func (*PeerSet) SuperMajority ¶ added in v0.4.1
SuperMajority return the number of peers that forms a strong majortiy (+2/3) in the PeerSet
func (*PeerSet) TrustCount ¶ added in v0.4.1
TrustCount calculates the Trust Count for a peerset
func (*PeerSet) WithNewPeer ¶ added in v0.4.1
WithNewPeer returns a new PeerSet with a list of peers including the new one.
func (*PeerSet) WithRemovedPeer ¶ added in v0.4.1
WithRemovedPeer returns a new PeerSet with a list of peers excluding the provided one