mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-20 06:52:30 +00:00
remove extra comments in lite/commit
This commit is contained in:
+15
-19
@@ -8,11 +8,11 @@ import (
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// FullCommit contains a SignedHeader (the block header and a commit that signs it),
|
||||
// the validator set which signed the commit, and the next validator set. The
|
||||
// next validator set (which is proven from the block header) allows us to
|
||||
// revert to block-by-block updating of lite Verifier's latest validator set,
|
||||
// even in the face of arbitrarily large power changes.
|
||||
// FullCommit contains a SignedHeader (the block's header and a commit that
|
||||
// signs it), the validator set which signed the commit, and the next validator
|
||||
// set. The next validator set (which is proven from the block header) allows
|
||||
// us to revert to block-by-block updating of lite Verifier's latest validator
|
||||
// set, even in the face of arbitrarily large power changes.
|
||||
type FullCommit struct {
|
||||
SignedHeader types.SignedHeader `json:"signed_header"`
|
||||
Validators *types.ValidatorSet `json:"validator_set"`
|
||||
@@ -28,39 +28,33 @@ func NewFullCommit(signedHeader types.SignedHeader, valset, nextValset *types.Va
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the components and check for consistency.
|
||||
// This also checks to make sure that Validators actually
|
||||
// signed the SignedHeader.Commit.
|
||||
// If > 2/3 did not sign the Commit from fc.Validators, it
|
||||
// is not a valid commit!
|
||||
// ValidateFull validates the components and ensures consistency.
|
||||
// It also checks that Validators actually signed the SignedHeader.Commit.
|
||||
// If > 2/3 did not sign the Commit from fc.Validators, it is not a valid
|
||||
// commit!
|
||||
func (fc FullCommit) ValidateFull(chainID string) error {
|
||||
// Ensure that Validators exists and matches the header.
|
||||
if fc.Validators.Size() == 0 {
|
||||
return errors.New("need FullCommit.Validators")
|
||||
return errors.New("empty FullCommit.Validators")
|
||||
}
|
||||
|
||||
// If the commit ValidatorHash doesn't match the block ValidatorHash return an error
|
||||
if !bytes.Equal(fc.SignedHeader.ValidatorsHash, fc.Validators.Hash()) {
|
||||
return fmt.Errorf("header has vhash %X but valset hash is %X",
|
||||
return fmt.Errorf("header has ValidatorsHash %X but valset hash is %X",
|
||||
fc.SignedHeader.ValidatorsHash,
|
||||
fc.Validators.Hash(),
|
||||
)
|
||||
}
|
||||
|
||||
// Ensure that NextValidators exists and matches the header.
|
||||
if fc.NextValidators.Size() == 0 {
|
||||
return errors.New("need FullCommit.NextValidators")
|
||||
return errors.New("empty FullCommit.NextValidators")
|
||||
}
|
||||
|
||||
// If the commit NextValidatorHash doesn't match the block Next ValidatorHash return an error
|
||||
if !bytes.Equal(fc.SignedHeader.NextValidatorsHash, fc.NextValidators.Hash()) {
|
||||
return fmt.Errorf("header has next vhash %X but next valset hash is %X",
|
||||
return fmt.Errorf("header has next ValidatorsHash %X but next valset hash is %X",
|
||||
fc.SignedHeader.NextValidatorsHash,
|
||||
fc.NextValidators.Hash(),
|
||||
)
|
||||
}
|
||||
|
||||
// Validate the header.
|
||||
err := fc.SignedHeader.ValidateBasic(chainID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -76,6 +70,7 @@ func (fc FullCommit) Height() int64 {
|
||||
if fc.SignedHeader.Header == nil {
|
||||
panic("should not happen")
|
||||
}
|
||||
|
||||
return fc.SignedHeader.Height
|
||||
}
|
||||
|
||||
@@ -84,5 +79,6 @@ func (fc FullCommit) ChainID() string {
|
||||
if fc.SignedHeader.Header == nil {
|
||||
panic("should not happen")
|
||||
}
|
||||
|
||||
return fc.SignedHeader.ChainID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user