shard

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareBlsPublicKey

func CompareBlsPublicKey(k1, k2 BlsPublicKey) int

CompareBlsPublicKey compares two BlsPublicKey, lexicographically.

func CompareCommittee

func CompareCommittee(c1, c2 *Committee) int

CompareCommittee compares two committees and their leader/node list.

func CompareNodeID

func CompareNodeID(id1, id2 *NodeID) int

CompareNodeID compares two node IDs.

func CompareNodeIDByBLSKey

func CompareNodeIDByBLSKey(n1 NodeID, n2 NodeID) int

CompareNodeIDByBLSKey compares two nodes by their ID; used to sort node list

func CompareNodeIDList

func CompareNodeIDList(l1, l2 NodeIDList) int

CompareNodeIDList compares two node ID lists.

func CompareShardState

func CompareShardState(s1, s2 State) int

CompareShardState compares two State instances.

func GetHashFromNodeList

func GetHashFromNodeList(nodeList []NodeID) []byte

GetHashFromNodeList will sort the list, then use Keccak256 to hash the list NOTE: do not modify the underlining content for hash

Types

type BlsPublicKey

type BlsPublicKey [48]byte

BlsPublicKey defines the bls public key

func (*BlsPublicKey) FromLibBLSPublicKey

func (pk *BlsPublicKey) FromLibBLSPublicKey(key *bls.PublicKey) error

FromLibBLSPublicKey replaces the key contents with the given key,

func (BlsPublicKey) Hex

func (pk BlsPublicKey) Hex() string

Hex returns the hex string of bls public key

func (BlsPublicKey) IsEmpty

func (pk BlsPublicKey) IsEmpty() bool

IsEmpty returns whether the bls public key is empty 0 bytes

func (*BlsPublicKey) ToLibBLSPublicKey

func (pk *BlsPublicKey) ToLibBLSPublicKey(key *bls.PublicKey) error

ToLibBLSPublicKey copies the key contents into the given key.

type Committee

type Committee struct {
	ShardID  uint32     `json:"shard_id"`
	NodeList NodeIDList `json:"node_list"`
}

Committee contains the active nodes in one shard

func (Committee) DeepCopy

func (c Committee) DeepCopy() Committee

DeepCopy returns a deep copy of the receiver.

type EpochShardState

type EpochShardState struct {
	Epoch      uint64
	ShardState State
}

EpochShardState is the shard state of an epoch

type NodeID

type NodeID struct {
	EcdsaAddress common.Address `json:"ecdsa_address"`
	BlsPublicKey BlsPublicKey   `json:"bls_pubkey"`
}

NodeID represents node id (BLS address)

func (NodeID) Serialize

func (n NodeID) Serialize() []byte

Serialize serialize NodeID into bytes

func (NodeID) String

func (n NodeID) String() string

type NodeIDList

type NodeIDList []NodeID

NodeIDList is a list of NodeIDList.

func (NodeIDList) DeepCopy

func (l NodeIDList) DeepCopy() NodeIDList

DeepCopy returns a deep copy of the receiver.

type State

type State []Committee

State is the collection of all committees

func (State) DeepCopy

func (ss State) DeepCopy() State

DeepCopy returns a deep copy of the receiver.

func (State) FindCommitteeByID

func (ss State) FindCommitteeByID(shardID uint32) *Committee

FindCommitteeByID returns the committee configuration for the given shard, or nil if the given shard is not found.

func (State) Hash

func (ss State) Hash() (h common.Hash)

Hash is the root hash of State

Jump to

Keyboard shortcuts

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