Skip to content

Commit

Permalink
chore(parachain): improve comments of statement and statement distrib…
Browse files Browse the repository at this point in the history
…ution message (#3355)
  • Loading branch information
axaysagathiya authored and kishansagathiya committed Jan 24, 2024
1 parent 118753d commit 6eb42c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
14 changes: 7 additions & 7 deletions lib/parachain/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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
}

Expand Down
17 changes: 9 additions & 8 deletions lib/parachain/statement_distribution_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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
}

Expand Down

0 comments on commit 6eb42c8

Please sign in to comment.