-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Address
-derived vs. AccountId
-derived NoteTag
The tag derived from an Address
is (potentially) different than the tag derived from an AccountId
.
Currently, when we add a new account to the client store, we fall back to AccountId
-derived tag (via Account
-> NoteTagRecord
conversion):
self.store.add_note_tag(account.into()).await?; |
But, client.add_account
doesn't provide any option to specify the Address
as a parameter.
There are two paths:
- Easy path: inside
add_account
, derive the "default"Address::AccountIdAddress
by passing in theAccountId
andAddressInterface::Unspecified
. - New interface: let users add
Address
es, for example by exposing a newadd_address
method, similar toadd_account
. Potentially deprecateadd_account
. - Change the interface of
add_account
to acceptAccountIdAddress
instead ofAccountId
. This is akin to what @PhilippGackstatter suggested increate_p2id_note
should takeAddress
as parameter (or should it?) miden-base#1837 (comment). - Other ideas?
These approaches would further require adding a new enum variant Address
to NoteTagSource
(or potentially change NoteTagSource::Account
to NoteTagSource::AccountIdAddress
if we choose option 3).
Query the store for NoteTag
s based on the source.
This part could be potentially to be split out into a separate issue, depending on the decisions above^.
It would also be great if we could query the store for tags coming from a specific source.
This would allow us to limit the amount of notes downloaded from the note transport layer to only Address
-derived tags. So in Fetch notes section here, instead of:
let note_tags: BTreeSet<NoteTag> = self.store.get_unique_note_tags().await?;
// query the gRPC node for these note_tags AND query the transport layer for these tags
we could define a new store-querying source interface: NoteTagStoreSource
:
pub enum NoteTagStoreSource { // name TBD
Address(AddressSource),
Note(NoteSource),
User(UserSource),
}
pub enum AddressSource {
All,
Exact(Address)
}
// etc. for NoteSource, UserSource
And then query as:
let public_note_tags: BTreeSet<NoteTag> = self.store.get_unique_note_tags().await?; // this doesn't change, gets all note tags
// query the gRPC node for public_note_tags
let public_note_tags: BTreeSet<NoteTag> = self.store.get_unique_note_tags_from_source(
NoteTagStoreSource::Address(AddressSource:All)
).await?;
// query the transport layer for private note tags