Skip to content

Commit

Permalink
add copyWithoutPatch helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
pnowosie committed Nov 25, 2024
1 parent 9309fb4 commit c9d38b5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,22 @@ func checkBlockVersion(protocolVersion string) error {
}

// We ignore changes in patch part of the version
blockVerMM, suportedVerMM := blockVer.IncMinor(), SupportedStarknetVersion.IncMinor()
if blockVerMM.GreaterThan(&suportedVerMM) {
blockVerMM, supportedVerMM := copyWithoutPatch(blockVer), copyWithoutPatch(SupportedStarknetVersion)
if blockVerMM.GreaterThan(supportedVerMM) {
return errors.New("unsupported block version")
}

return nil
}

func copyWithoutPatch(v *semver.Version) *semver.Version {
if v == nil {
return nil
}

Check warning on line 77 in blockchain/blockchain.go

View check run for this annotation

Codecov / codecov/patch

blockchain/blockchain.go#L76-L77

Added lines #L76 - L77 were not covered by tests

return semver.New(v.Major(), v.Minor(), 0, v.Prerelease(), v.Metadata())
}

var _ Reader = (*Blockchain)(nil)

// Blockchain is responsible for keeping track of all things related to the Starknet blockchain
Expand Down

0 comments on commit c9d38b5

Please sign in to comment.