Skip to content

Commit

Permalink
Merge pull request #790 from The-K-R-O-K/illia-malachyn/make-timeout-…
Browse files Browse the repository at this point in the history
…ceritificate-nullable
  • Loading branch information
turbolent authored Oct 22, 2024
2 parents a0793fd + 1221b62 commit 175b6cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions access/grpc/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ func MessageToBlockHeader(m *entities.BlockHeader) (flow.BlockHeader, error) {
timestamp = m.GetTimestamp().AsTime()
}

tc, err := MessageToTimeoutCertificate(m.GetLastViewTc())
timeoutCertificate, err := MessageToTimeoutCertificate(m.GetLastViewTc())
if err != nil {
return flow.BlockHeader{}, err
return flow.BlockHeader{}, fmt.Errorf("error converting timeout certificate: %w", err)
}

return flow.BlockHeader{
Expand All @@ -285,19 +285,20 @@ func MessageToBlockHeader(m *entities.BlockHeader) (flow.BlockHeader, error) {
ProposerSigData: m.GetProposerSigData(),
ChainID: flow.HashToID([]byte(m.GetChainId())),
ParentVoterIndices: m.GetParentVoterIndices(),
LastViewTimeoutCertificate: tc,
LastViewTimeoutCertificate: timeoutCertificate,
ParentView: m.GetParentView(),
}, nil
}

func MessageToTimeoutCertificate(m *entities.TimeoutCertificate) (flow.TimeoutCertificate, error) {
if m == nil {
return flow.TimeoutCertificate{}, ErrEmptyMessage
// timeout certificate can be nil
return flow.TimeoutCertificate{}, nil
}

qc, err := MessageToQuorumCertificate(m.GetHighestQc())
if err != nil {
return flow.TimeoutCertificate{}, err
return flow.TimeoutCertificate{}, fmt.Errorf("error converting quorum certificate: %w", err)
}

return flow.TimeoutCertificate{
Expand Down Expand Up @@ -326,7 +327,7 @@ func TimeoutCertificateToMessage(tc flow.TimeoutCertificate) (*entities.TimeoutC

func MessageToQuorumCertificate(m *entities.QuorumCertificate) (flow.QuorumCertificate, error) {
if m == nil {
return flow.QuorumCertificate{}, ErrEmptyMessage
return flow.QuorumCertificate{}, fmt.Errorf("quourum certificate is empty: %w", ErrEmptyMessage)
}

return flow.QuorumCertificate{
Expand Down
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.4
replace github.com/onflow/flow-go-sdk => ../

require (
github.com/onflow/cadence v1.0.1-0.20241018173327-2e72919b18ac
github.com/onflow/cadence v1.2.1
github.com/onflow/flow-cli/flowkit v1.11.0
github.com/onflow/flow-go-sdk v0.41.17
github.com/spf13/afero v1.11.0
Expand Down
1 change: 1 addition & 0 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ github.com/onflow/cadence v1.0.0-preview.38/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmp
github.com/onflow/cadence v1.0.0-preview.52/go.mod h1:7wvvecnAZtYOspLOS3Lh+FuAmMeSrXhAWiycC3kQ1UU=
github.com/onflow/cadence v1.0.0/go.mod h1:7wvvecnAZtYOspLOS3Lh+FuAmMeSrXhAWiycC3kQ1UU=
github.com/onflow/cadence v1.0.1-0.20241018173327-2e72919b18ac/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg=
github.com/onflow/cadence v1.2.1/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg=
github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
Expand Down

0 comments on commit 175b6cf

Please sign in to comment.