-
Notifications
You must be signed in to change notification settings - Fork 163
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
pathpol: Do not use policy.Policy directly #3173
pathpol: Do not use policy.Policy directly #3173
Conversation
Instead use interfaces. This way tests no longer need to instantiate actual policies. Also we can much easier refactor the Policy object without breaking anything else. Furthermore remove the Act method instead offer Filter and FilterOpt Fixes scionproto#3087
2b7746c
to
b767b7f
Compare
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.
Reviewed 35 of 35 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @lukedirtwalker)
go/lib/pathdb/helpers.go, line 33 at r1 (raw file):
// NoPolicy should be used instead of nil when inserting policy hashes into // fields which can't be null in the DB. var NoPolicy = PolicyHash{0x44, 0x13, 0x6f, 0xa3, 0x55, 0xb3, 0x67, 0x8a, 0x11, 0x46, 0xad, 0x16,
How to generate this value should be added to its docstring.
go/lib/pathdb/helpers.go, line 39 at r1 (raw file):
// HashPolicy is a default implementation of a policy hash function. It creates // a sha256 hash of the json serialized policy. func HashPolicy(policy *pathpol.Policy) (PolicyHash, error) {
I realized something when looking at Dominik's JSON PRs for the TRC.
The same policy can lead to different hashes, because JSON can represent the same data in multiple ways. Don't know if this would cause problems though.
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.
Reviewable status: 34 of 35 files reviewed, 2 unresolved discussions (waiting on @scrye)
go/lib/pathdb/helpers.go, line 33 at r1 (raw file):
Previously, scrye (Sergiu Costea) wrote…
How to generate this value should be added to its docstring.
Done.
go/lib/pathdb/helpers.go, line 39 at r1 (raw file):
Previously, scrye (Sergiu Costea) wrote…
I realized something when looking at Dominik's JSON PRs for the TRC.
The same policy can lead to different hashes, because JSON can represent the same data in multiple ways. Don't know if this would cause problems though.
Clarified in the comment.
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.
Reviewed 1 of 1 files at r2.
Reviewable status: complete! all files reviewed, all discussions resolved
Instead use interfaces. This way tests no longer need to instantiate actual policies.
Also we can much easier refactor the Policy object without breaking anything else.
Furthermore remove the Act method instead offer Filter and FilterOpt
Fixes #3087
This change is