diff --git a/lib/parachain/statement.go b/lib/parachain/statement.go index 09412e2a98..168b8f0f59 100644 --- a/lib/parachain/statement.go +++ b/lib/parachain/statement.go @@ -10,13 +10,13 @@ import ( // Statement is a result of candidate validation. It could be either `Valid` or `Seconded`. type Statement scale.VaryingDataType -// NewStatement returns a new Statement VaryingDataType +// NewStatement returns a new statement varying data type func NewStatement() Statement { vdt := scale.MustNewVaryingDataType(Seconded{}, Valid{}) return Statement(vdt) } -// Set will set a VaryingDataTypeValue using the underlying VaryingDataType +// Set will set a value using the underlying varying data type func (s *Statement) Set(val scale.VaryingDataTypeValue) (err error) { vdt := scale.VaryingDataType(*s) err = vdt.Set(val) @@ -28,7 +28,7 @@ func (s *Statement) Set(val scale.VaryingDataTypeValue) (err error) { return nil } -// Value returns the value from the underlying VaryingDataType +// Value returns the value from the underlying varying data type func (s *Statement) Value() (scale.VaryingDataTypeValue, error) { vdt := scale.VaryingDataType(*s) return vdt.Value() @@ -37,16 +37,16 @@ func (s *Statement) Value() (scale.VaryingDataTypeValue, error) { // Seconded represents a statement that a validator seconds a candidate. type Seconded CommittedCandidateReceipt -// Index returns the VaryingDataType Index -func (s Seconded) Index() uint { +// Index returns the index of varying data type +func (Seconded) Index() uint { return 1 } // Valid represents a statement that a validator has deemed a candidate valid. type Valid CandidateHash -// Index returns the VaryingDataType Index -func (v Valid) Index() uint { +// Index returns the index of varying data type +func (Valid) Index() uint { return 2 } diff --git a/lib/parachain/statement_distribution_message.go b/lib/parachain/statement_distribution_message.go index 8690fcaa61..68eb3707f2 100644 --- a/lib/parachain/statement_distribution_message.go +++ b/lib/parachain/statement_distribution_message.go @@ -10,13 +10,13 @@ import ( // StatementDistributionMessage represents network messages used by the statement distribution subsystem type StatementDistributionMessage scale.VaryingDataType -// NewStatementDistributionMessage returns a new StatementDistributionMessage VaryingDataType +// NewStatementDistributionMessage returns a new statement distribution message varying data type func NewStatementDistributionMessage() StatementDistributionMessage { vdt := scale.MustNewVaryingDataType(SignedFullStatement{}, SecondedStatementWithLargePayload{}) return StatementDistributionMessage(vdt) } -// Set will set a VaryingDataTypeValue using the underlying VaryingDataType +// Set will set a value using the underlying varying data type func (sdm *StatementDistributionMessage) Set(val scale.VaryingDataTypeValue) (err error) { vdt := scale.VaryingDataType(*sdm) err = vdt.Set(val) @@ -28,7 +28,7 @@ func (sdm *StatementDistributionMessage) Set(val scale.VaryingDataTypeValue) (er return nil } -// Value returns the value from the underlying VaryingDataType +// Value returns the value from the underlying varying data type func (sdm *StatementDistributionMessage) Value() (scale.VaryingDataTypeValue, error) { vdt := scale.VaryingDataType(*sdm) return vdt.Value() @@ -40,19 +40,20 @@ type SignedFullStatement struct { UncheckedSignedFullStatement UncheckedSignedFullStatement `scale:"2"` } -// Index returns the VaryingDataType Index -func (s SignedFullStatement) Index() uint { +// Index returns the index of varying data type +func (SignedFullStatement) Index() uint { return 0 } -// Seconded statement with large payload (e.g. containing a runtime upgrade). +// SecondedStatementWithLargePayload represents Seconded statement with large payload +// (e.g. containing a runtime upgrade). // // We only gossip the hash in that case, actual payloads can be fetched from sending node // via request/response. type SecondedStatementWithLargePayload StatementMetadata -// Index returns the VaryingDataType Index -func (l SecondedStatementWithLargePayload) Index() uint { +// Index returns the index of varying data type +func (SecondedStatementWithLargePayload) Index() uint { return 1 }