Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(parachain): improve comments of statement and statement distribution message #3355

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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