From 4b2e323728f2300e7bd75040dfcd4da0134f4924 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 8 Jul 2019 13:32:08 +0400 Subject: [PATCH] remove extra comments in lite/commit --- lite/commit.go | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lite/commit.go b/lite/commit.go index 92253261d..a03651b56 100644 --- a/lite/commit.go +++ b/lite/commit.go @@ -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 }