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

pathpol: Do not use policy.Policy directly #3173

Merged
merged 2 commits into from
Oct 7, 2019

Conversation

lukedirtwalker
Copy link
Collaborator

@lukedirtwalker lukedirtwalker commented Sep 20, 2019

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 Reviewable

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
Copy link
Contributor

@scrye scrye left a 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.

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a 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.

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@lukedirtwalker lukedirtwalker merged commit 46c1c65 into scionproto:master Oct 7, 2019
@lukedirtwalker lukedirtwalker deleted the pubPolicyUntangle branch October 7, 2019 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pathpol: Do not use pathpol.Policy directly
2 participants