Documentation ¶
Index ¶
- Variables
- func MajorityCount(validatorCount int) int
- type Block
- func (blk *Block) ExecHeight() uint64
- func (blk *Block) Hash() []byte
- func (blk *Block) Height() uint64
- func (blk *Block) Marshal() ([]byte, error)
- func (blk *Block) MarshalJSON() ([]byte, error)
- func (blk *Block) MerkleRoot() []byte
- func (blk *Block) ParentHash() []byte
- func (blk *Block) Proposer() *PublicKey
- func (blk *Block) QuorumCert() *QuorumCert
- func (blk *Block) SetExecHeight(val uint64) *Block
- func (blk *Block) SetHeight(val uint64) *Block
- func (blk *Block) SetMerkleRoot(val []byte) *Block
- func (blk *Block) SetParentHash(val []byte) *Block
- func (blk *Block) SetQuorumCert(val *QuorumCert) *Block
- func (blk *Block) SetTimestamp(val int64) *Block
- func (blk *Block) SetTransactions(val [][]byte) *Block
- func (blk *Block) SetView(val uint32) *Block
- func (blk *Block) Sign(signer Signer) *Block
- func (blk *Block) Sum() []byte
- func (blk *Block) Timestamp() int64
- func (blk *Block) Transactions() [][]byte
- func (blk *Block) Unmarshal(b []byte) error
- func (blk *Block) UnmarshalJSON(b []byte) error
- func (blk *Block) Validate(rs RoleStore) error
- func (blk *Block) View() uint32
- func (blk *Block) Vote(signer Signer, quota uint64) *Vote
- type BlockCommit
- func (bcm *BlockCommit) ElapsedExec() float64
- func (bcm *BlockCommit) ElapsedMerkle() float64
- func (bcm *BlockCommit) Hash() []byte
- func (bcm *BlockCommit) LeafCount() []byte
- func (bcm *BlockCommit) Marshal() ([]byte, error)
- func (bcm *BlockCommit) MerkleRoot() []byte
- func (bcm *BlockCommit) OldBlockTxs() [][]byte
- func (bcm *BlockCommit) SetElapsedExec(val float64) *BlockCommit
- func (bcm *BlockCommit) SetElapsedMerkle(val float64) *BlockCommit
- func (bcm *BlockCommit) SetHash(val []byte) *BlockCommit
- func (bcm *BlockCommit) SetLeafCount(val []byte) *BlockCommit
- func (bcm *BlockCommit) SetMerkleRoot(val []byte) *BlockCommit
- func (bcm *BlockCommit) SetOldBlockTxs(val [][]byte) *BlockCommit
- func (bcm *BlockCommit) SetStateChanges(val []*StateChange) *BlockCommit
- func (bcm *BlockCommit) StateChanges() []*StateChange
- func (bcm *BlockCommit) Unmarshal(b []byte) error
- type PrivateKey
- type PublicKey
- type QuorumCert
- func (qc *QuorumCert) BlockHash() []byte
- func (qc *QuorumCert) Build(signer Signer, votes []*Vote) *QuorumCert
- func (qc *QuorumCert) FindVote(signer Signer) uint64
- func (qc *QuorumCert) Marshal() ([]byte, error)
- func (qc *QuorumCert) Proposer() *PublicKey
- func (qc *QuorumCert) Quotas() []uint64
- func (qc *QuorumCert) Signatures() []*Signature
- func (qc *QuorumCert) SumQuota() uint64
- func (qc *QuorumCert) Unmarshal(b []byte) error
- func (qc *QuorumCert) Validate(rs RoleStore) error
- func (qc *QuorumCert) View() uint32
- type RoleStore
- type Signature
- type Signer
- type StateChange
- func (sc *StateChange) Key() []byte
- func (sc *StateChange) Marshal() ([]byte, error)
- func (sc *StateChange) PrevTreeIndex() []byte
- func (sc *StateChange) PrevValue() []byte
- func (sc *StateChange) SetKey(val []byte) *StateChange
- func (sc *StateChange) SetPrevTreeIndex(val []byte) *StateChange
- func (sc *StateChange) SetPrevValue(val []byte) *StateChange
- func (sc *StateChange) SetTreeIndex(val []byte) *StateChange
- func (sc *StateChange) SetValue(val []byte) *StateChange
- func (sc *StateChange) TreeIndex() []byte
- func (sc *StateChange) Unmarshal(b []byte) error
- func (sc *StateChange) Value() []byte
- type Transaction
- func (tx *Transaction) CodeAddr() []byte
- func (tx *Transaction) Expiry() uint64
- func (tx *Transaction) Hash() []byte
- func (tx *Transaction) Input() []byte
- func (tx *Transaction) Marshal() ([]byte, error)
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) Nonce() int64
- func (tx *Transaction) Sender() *PublicKey
- func (tx *Transaction) SetCodeAddr(val []byte) *Transaction
- func (tx *Transaction) SetExpiry(val uint64) *Transaction
- func (tx *Transaction) SetInput(val []byte) *Transaction
- func (tx *Transaction) SetNonce(val int64) *Transaction
- func (tx *Transaction) Sign(signer Signer) *Transaction
- func (tx *Transaction) Sum() []byte
- func (tx *Transaction) Unmarshal(b []byte) error
- func (tx *Transaction) UnmarshalJSON(b []byte) error
- func (tx *Transaction) Validate() error
- type TxCommit
- func (txc *TxCommit) BlockHash() []byte
- func (txc *TxCommit) BlockHeight() uint64
- func (txc *TxCommit) Elapsed() float64
- func (txc *TxCommit) Error() string
- func (txc *TxCommit) Hash() []byte
- func (txc *TxCommit) Marshal() ([]byte, error)
- func (txc *TxCommit) MarshalJSON() ([]byte, error)
- func (txc *TxCommit) SetBlockHash(val []byte) *TxCommit
- func (txc *TxCommit) SetBlockHeight(val uint64) *TxCommit
- func (txc *TxCommit) SetElapsed(val float64) *TxCommit
- func (txc *TxCommit) SetError(val string) *TxCommit
- func (txc *TxCommit) SetHash(val []byte) *TxCommit
- func (txc *TxCommit) Unmarshal(b []byte) error
- func (txc *TxCommit) UnmarshalJSON(b []byte) error
- type TxList
- type Vote
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidBlockHash = errors.New("invalid block hash") ErrNilBlock = errors.New("nil block") )
errors
View Source
var ( ErrNilQC = errors.New("nil qc") ErrNilSig = errors.New("nil signature") ErrNotEnoughSig = errors.New("not enough signatures in qc") ErrDuplicateSig = errors.New("duplicate signature in qc") ErrInvalidSig = errors.New("invalid signature") ErrInvalidValidator = errors.New("invalid validator") )
errors
View Source
var ( ErrInvalidTxHash = errors.New("invalid tx hash") ErrNilTx = errors.New("nil tx") )
errors
View Source
var ErrInvalidKeySize = errors.New("invalid key size")
View Source
var (
ErrNilVote = errors.New("nil vote")
)
errors
Functions ¶
func MajorityCount ¶
MajorityCount returns 2f + 1 members
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block type
func (*Block) ExecHeight ¶
func (*Block) MarshalJSON ¶
func (*Block) MerkleRoot ¶
func (*Block) ParentHash ¶
func (*Block) QuorumCert ¶
func (blk *Block) QuorumCert() *QuorumCert
func (*Block) SetExecHeight ¶
func (*Block) SetMerkleRoot ¶
func (*Block) SetParentHash ¶
func (*Block) SetQuorumCert ¶
func (blk *Block) SetQuorumCert(val *QuorumCert) *Block
func (*Block) SetTimestamp ¶
func (*Block) SetTransactions ¶
func (*Block) Transactions ¶
func (*Block) UnmarshalJSON ¶
type BlockCommit ¶
type BlockCommit struct {
// contains filtered or unexported fields
}
func NewBlockCommit ¶
func NewBlockCommit() *BlockCommit
func (*BlockCommit) ElapsedExec ¶
func (bcm *BlockCommit) ElapsedExec() float64
func (*BlockCommit) ElapsedMerkle ¶
func (bcm *BlockCommit) ElapsedMerkle() float64
func (*BlockCommit) Hash ¶
func (bcm *BlockCommit) Hash() []byte
func (*BlockCommit) LeafCount ¶
func (bcm *BlockCommit) LeafCount() []byte
func (*BlockCommit) Marshal ¶
func (bcm *BlockCommit) Marshal() ([]byte, error)
func (*BlockCommit) MerkleRoot ¶
func (bcm *BlockCommit) MerkleRoot() []byte
func (*BlockCommit) OldBlockTxs ¶
func (bcm *BlockCommit) OldBlockTxs() [][]byte
func (*BlockCommit) SetElapsedExec ¶
func (bcm *BlockCommit) SetElapsedExec(val float64) *BlockCommit
func (*BlockCommit) SetElapsedMerkle ¶
func (bcm *BlockCommit) SetElapsedMerkle(val float64) *BlockCommit
func (*BlockCommit) SetHash ¶
func (bcm *BlockCommit) SetHash(val []byte) *BlockCommit
func (*BlockCommit) SetLeafCount ¶
func (bcm *BlockCommit) SetLeafCount(val []byte) *BlockCommit
func (*BlockCommit) SetMerkleRoot ¶
func (bcm *BlockCommit) SetMerkleRoot(val []byte) *BlockCommit
func (*BlockCommit) SetOldBlockTxs ¶
func (bcm *BlockCommit) SetOldBlockTxs(val [][]byte) *BlockCommit
func (*BlockCommit) SetStateChanges ¶
func (bcm *BlockCommit) SetStateChanges(val []*StateChange) *BlockCommit
func (*BlockCommit) StateChanges ¶
func (bcm *BlockCommit) StateChanges() []*StateChange
func (*BlockCommit) Unmarshal ¶
func (bcm *BlockCommit) Unmarshal(b []byte) error
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey type
func GenerateKey ¶
func GenerateKey(rand io.Reader) *PrivateKey
func NewPrivateKey ¶
func NewPrivateKey(b []byte) (*PrivateKey, error)
NewPrivateKey creates PrivateKey from bytes
func (*PrivateKey) PublicKey ¶
func (priv *PrivateKey) PublicKey() *PublicKey
PublicKey returns corresponding public key
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(msg []byte) *Signature
Sign signs the message
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey type
func NewPublicKey ¶
NewPublicKey creates PublicKey from bytes
func StringToPubKey ¶
type QuorumCert ¶
type QuorumCert struct {
// contains filtered or unexported fields
}
QuorumCert type
func NewQuorumCert ¶
func NewQuorumCert() *QuorumCert
func (*QuorumCert) BlockHash ¶
func (qc *QuorumCert) BlockHash() []byte
func (*QuorumCert) Build ¶
func (qc *QuorumCert) Build(signer Signer, votes []*Vote) *QuorumCert
func (*QuorumCert) FindVote ¶
func (qc *QuorumCert) FindVote(signer Signer) uint64
func (*QuorumCert) Marshal ¶
func (qc *QuorumCert) Marshal() ([]byte, error)
Marshal encodes quorum cert as bytes
func (*QuorumCert) Proposer ¶
func (qc *QuorumCert) Proposer() *PublicKey
func (*QuorumCert) Quotas ¶
func (qc *QuorumCert) Quotas() []uint64
func (*QuorumCert) Signatures ¶
func (qc *QuorumCert) Signatures() []*Signature
func (*QuorumCert) SumQuota ¶
func (qc *QuorumCert) SumQuota() uint64
func (*QuorumCert) Unmarshal ¶
func (qc *QuorumCert) Unmarshal(b []byte) error
Unmarshal decodes quorum cert from bytes
func (*QuorumCert) Validate ¶
func (qc *QuorumCert) Validate(rs RoleStore) error
func (*QuorumCert) View ¶
func (qc *QuorumCert) View() uint32
type RoleStore ¶
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
Signature type
type StateChange ¶
type StateChange struct {
// contains filtered or unexported fields
}
func NewStateChange ¶
func NewStateChange() *StateChange
func (*StateChange) Key ¶
func (sc *StateChange) Key() []byte
func (*StateChange) Marshal ¶
func (sc *StateChange) Marshal() ([]byte, error)
func (*StateChange) PrevTreeIndex ¶
func (sc *StateChange) PrevTreeIndex() []byte
func (*StateChange) PrevValue ¶
func (sc *StateChange) PrevValue() []byte
func (*StateChange) SetKey ¶
func (sc *StateChange) SetKey(val []byte) *StateChange
func (*StateChange) SetPrevTreeIndex ¶
func (sc *StateChange) SetPrevTreeIndex(val []byte) *StateChange
func (*StateChange) SetPrevValue ¶
func (sc *StateChange) SetPrevValue(val []byte) *StateChange
func (*StateChange) SetTreeIndex ¶
func (sc *StateChange) SetTreeIndex(val []byte) *StateChange
func (*StateChange) SetValue ¶
func (sc *StateChange) SetValue(val []byte) *StateChange
func (*StateChange) TreeIndex ¶
func (sc *StateChange) TreeIndex() []byte
func (*StateChange) Unmarshal ¶
func (sc *StateChange) Unmarshal(b []byte) error
func (*StateChange) Value ¶
func (sc *StateChange) Value() []byte
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction type
func NewTransaction ¶
func NewTransaction() *Transaction
func (*Transaction) CodeAddr ¶
func (tx *Transaction) CodeAddr() []byte
func (*Transaction) Expiry ¶
func (tx *Transaction) Expiry() uint64
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() []byte
func (*Transaction) Input ¶
func (tx *Transaction) Input() []byte
func (*Transaction) Marshal ¶
func (tx *Transaction) Marshal() ([]byte, error)
Marshal encodes transaction as bytes
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) Nonce ¶
func (tx *Transaction) Nonce() int64
func (*Transaction) Sender ¶
func (tx *Transaction) Sender() *PublicKey
func (*Transaction) SetCodeAddr ¶
func (tx *Transaction) SetCodeAddr(val []byte) *Transaction
func (*Transaction) SetExpiry ¶
func (tx *Transaction) SetExpiry(val uint64) *Transaction
func (*Transaction) SetInput ¶
func (tx *Transaction) SetInput(val []byte) *Transaction
func (*Transaction) SetNonce ¶
func (tx *Transaction) SetNonce(val int64) *Transaction
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(signer Signer) *Transaction
func (*Transaction) Unmarshal ¶
func (tx *Transaction) Unmarshal(b []byte) error
Unmarshal decodes transaction from bytes
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(b []byte) error
type TxCommit ¶
type TxCommit struct {
// contains filtered or unexported fields
}
func NewTxCommit ¶
func NewTxCommit() *TxCommit
func (*TxCommit) BlockHeight ¶
func (*TxCommit) MarshalJSON ¶
func (*TxCommit) SetBlockHash ¶
func (*TxCommit) SetBlockHeight ¶
func (*TxCommit) SetElapsed ¶
func (*TxCommit) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.