-
Notifications
You must be signed in to change notification settings - Fork 125
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
Support group keys for RFQ negotiation flows #1382
base: main
Are you sure you want to change the base?
Changes from 1 commit
9b1a9d0
1044f7f
9f689aa
cffc3b6
3bacc43
7d7cec6
269ad4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package rfq | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
@@ -965,6 +966,33 @@ func (m *Manager) GetAssetGroupKey(ctx context.Context, | |
return groupKeyBytes, nil | ||
} | ||
|
||
// AssetMatchesSpecifier checks if the provided asset satisfies the provided | ||
// specifier. If the specifier includes a group key, we will check if the asset | ||
// belongs to that group. | ||
func (m *Manager) AssetMatchesSpecifier(ctx context.Context, | ||
specifier asset.Specifier, id asset.ID) (bool, error) { | ||
|
||
switch { | ||
case specifier.HasGroupPubKey(): | ||
group, err := m.GetAssetGroupKey(ctx, id) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
specifierGK := specifier.UnwrapGroupKeyToPtr() | ||
|
||
return bytes.Equal(group, specifierGK.SerializeCompressed()), | ||
nil | ||
|
||
case specifier.HasId(): | ||
specifierID := specifier.UnwrapIdToPtr() | ||
|
||
return specifierID.IsEqual(id), nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I guess the |
||
} | ||
|
||
return false, fmt.Errorf("specifier is empty") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style nit: I find it easier to read if a |
||
} | ||
|
||
// publishSubscriberEvent publishes an event to all subscribers. | ||
func (m *Manager) publishSubscriberEvent(event fn.Event) { | ||
// Iterate over the subscribers and deliver the event to each one. | ||
|
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.
Yeah, I think we should return the public key instead of the bytes here. Then can use
.IsEqual()
on it.