-
Notifications
You must be signed in to change notification settings - Fork 4
Calculator Package Refactoring and Performance Optimizations #1383
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
Conversation
…ing and certified pricing
…ch/tfgrid-sdk-go into development_refactor
…ch/tfgrid-sdk-go into development_refactor
…illing info without unbilled amount
grid-client/calculator/calculate.go
Outdated
if errors.Is(err, ErrContractDeleted) { | ||
return | ||
} | ||
resultChain <- result{err: err} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use sync.Mutex
for both adding the cost and accumulating the error, you can use multierror for example
grid-client/calculator/calculate.go
Outdated
var totalCost int64 = 0 | ||
errList := make([]error, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use "github.com/hashicorp/go-multierror" to accumilate the error instead of a slice of errors
grid-client/calculator/calculate.go
Outdated
if len(errList) > 0 { | ||
if len(errList) == 1 { | ||
return 0, errList[0] | ||
} | ||
totalCost += cost | ||
return 0, fmt.Errorf("multiple errors occurred: %v", errList) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should not skip errors even if you have multiple ones, you need to send them back to the caller, thus using multierr is much easier
… handling in contract calculations
11a074a
to
09f9e03
Compare
Description
This PR contains a comprehensive refactoring of the calculator package in the grid-client to improve performance, readability, and maintainability. The changes focus on optimizing contract cost calculations, simplifying pricing logic, and enhancing test coverage.
Changes
public Ip
on the rented node, and on the name contractRelated Issues
Checklist