Documentation
¶
Index ¶
- Variables
- func Has1FP1Power(totalPower, signedPower int64) bool
- func Has2FP1Power(totalPower, signedPower int64) bool
- func Has3FP1Power(totalPower, signedPower int64) bool
- type BasicCheckError
- type Certificate
- func (cert *Certificate) Absentees() []int32
- func (cert *Certificate) AddSignature(valNum int32, sig *bls.Signature)
- func (cert *Certificate) BasicCheck() error
- func (cert *Certificate) Clone() *Certificate
- func (cert *Certificate) Committers() []int32
- func (cert *Certificate) Decode(r io.Reader) error
- func (cert *Certificate) Encode(w io.Writer) error
- func (cert *Certificate) Hash() hash.Hash
- func (cert *Certificate) Height() uint32
- func (cert *Certificate) MarshalCBOR() ([]byte, error)
- func (cert *Certificate) Round() int16
- func (cert *Certificate) SerializeSize() int
- func (cert *Certificate) SetSignature(committers, absentees []int32, signature *bls.Signature)
- func (cert *Certificate) SignBytesCPDecided(blockHash hash.Hash, cpRound int16, cpValue byte) []byte
- func (cert *Certificate) SignBytesCPMainVote(blockHash hash.Hash, cpRound int16, cpValue byte) []byte
- func (cert *Certificate) SignBytesCPPreVote(blockHash hash.Hash, cpRound int16, cpValue byte) []byte
- func (cert *Certificate) SignBytesPrecommit(blockHash hash.Hash) []byte
- func (cert *Certificate) SignBytesPrepare(blockHash hash.Hash) []byte
- func (cert *Certificate) Signature() *bls.Signature
- func (cert *Certificate) UnmarshalCBOR(bs []byte) error
- func (cert *Certificate) ValidateCPMainVote(validators []*validator.Validator, blockHash hash.Hash, cpRound int16, ...) error
- func (cert *Certificate) ValidateCPPreVote(validators []*validator.Validator, blockHash hash.Hash, cpRound int16, ...) error
- func (cert *Certificate) ValidatePrecommit(validators []*validator.Validator, blockHash hash.Hash) error
- func (cert *Certificate) ValidatePrepare(validators []*validator.Validator, blockHash hash.Hash) error
- type InsufficientPowerError
- type RequiredPowerFn
- type UnexpectedCommittersError
Constants ¶
This section is empty.
Variables ¶
var ( ErrTooManyCommitters = errors.New("too many committers in certificate") ErrTooManyAbsentees = errors.New("too many absentees in certificate") )
var Required1FP1Power = func(totalPower int64) int64 {
f := faultyPower(totalPower)
p := (1 * f) + 1
return p
}
var Required2FP1Power = func(power int64) int64 {
f := faultyPower(power)
p := (2 * f) + 1
return p
}
var Required3FP1Power = func(power int64) int64 {
f := faultyPower(power)
p := (3 * f) + 1
return p
}
Functions ¶
func Has1FP1Power ¶ added in v1.10.0
Has1FP1Power checks whether the signed power is greater than or equal to f+1, where f is the maximum faulty power.
func Has2FP1Power ¶ added in v1.10.0
Has2FP1Power checks whether the signed power is greater than or equal to 2f+1, where f is the maximum faulty power.
func Has3FP1Power ¶ added in v1.10.0
Has3FP1Power checks whether the signed power is greater than or equal to 3f+1, where f is the maximum faulty power.
Types ¶
type BasicCheckError ¶
type BasicCheckError struct {
Reason string
}
BasicCheckError is returned when the basic check on the certificate fails.
func (BasicCheckError) Error ¶
func (e BasicCheckError) Error() string
type Certificate ¶
type Certificate struct {
// contains filtered or unexported fields
}
Certificate represents a base structure for both Certificate and Certificate. As a Certificate, it verifies if a block is signed by a majority of validators. As a Certificate, it checks whether a majority of validators have voted in the consensus step.
func NewCertificate ¶
func NewCertificate(height uint32, round int16) *Certificate
NewCertificate creates a new Certificate instance.
func (*Certificate) Absentees ¶
func (cert *Certificate) Absentees() []int32
func (*Certificate) AddSignature ¶
func (cert *Certificate) AddSignature(valNum int32, sig *bls.Signature)
AddSignature adds a new signature to the certificate. It does not check the validity of the signature. The caller should ensure that the signature is valid.
func (*Certificate) BasicCheck ¶
func (cert *Certificate) BasicCheck() error
func (*Certificate) Clone ¶
func (cert *Certificate) Clone() *Certificate
func (*Certificate) Committers ¶
func (cert *Certificate) Committers() []int32
func (*Certificate) Hash ¶
func (cert *Certificate) Hash() hash.Hash
func (*Certificate) Height ¶
func (cert *Certificate) Height() uint32
func (*Certificate) MarshalCBOR ¶
func (cert *Certificate) MarshalCBOR() ([]byte, error)
func (*Certificate) Round ¶
func (cert *Certificate) Round() int16
func (*Certificate) SerializeSize ¶
func (cert *Certificate) SerializeSize() int
SerializeSize returns the number of bytes it would take to serialize the block.
func (*Certificate) SetSignature ¶ added in v1.10.0
func (cert *Certificate) SetSignature(committers, absentees []int32, signature *bls.Signature)
func (*Certificate) SignBytesCPDecided ¶ added in v1.10.0
func (*Certificate) SignBytesCPMainVote ¶ added in v1.10.0
func (*Certificate) SignBytesCPPreVote ¶ added in v1.10.0
func (*Certificate) SignBytesPrecommit ¶ added in v1.10.0
func (cert *Certificate) SignBytesPrecommit(blockHash hash.Hash) []byte
func (*Certificate) SignBytesPrepare ¶ added in v1.10.0
func (cert *Certificate) SignBytesPrepare(blockHash hash.Hash) []byte
func (*Certificate) Signature ¶
func (cert *Certificate) Signature() *bls.Signature
func (*Certificate) UnmarshalCBOR ¶
func (cert *Certificate) UnmarshalCBOR(bs []byte) error
func (*Certificate) ValidateCPMainVote ¶ added in v1.10.0
func (*Certificate) ValidateCPPreVote ¶ added in v1.10.0
func (*Certificate) ValidatePrecommit ¶ added in v1.10.0
func (*Certificate) ValidatePrepare ¶ added in v1.10.0
type InsufficientPowerError ¶
InsufficientPowerError is returned when the accumulated power does not meet the required threshold.
func (InsufficientPowerError) Error ¶
func (e InsufficientPowerError) Error() string
type RequiredPowerFn ¶ added in v1.10.0
type UnexpectedCommittersError ¶
type UnexpectedCommittersError struct {
Committers []int32
}
UnexpectedCommittersError is returned when the list of committers does not match the expectations.
func (UnexpectedCommittersError) Error ¶
func (e UnexpectedCommittersError) Error() string
func (UnexpectedCommittersError) Is ¶
func (e UnexpectedCommittersError) Is(target error) bool