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

[cherry-pick] fn: remove object IDs from transactions_to_addr index (#11314) #11927

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/sui-storage/src/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ impl IndexStore {
&self.tables.transactions_to_addr,
mutated_objects.filter_map(|(_, owner)| {
owner
.get_owner_address()
.get_address_owner_address()
.ok()
.map(|addr| ((addr, sequence), digest))
}),
Expand Down
13 changes: 13 additions & 0 deletions crates/sui-types/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,19 @@ pub enum Owner {
}

impl Owner {
// NOTE: only return address of AddressOwner, otherwise return error,
// ObjectOwner's address is converted from object id, thus we will skip it.
pub fn get_address_owner_address(&self) -> SuiResult<SuiAddress> {
match self {
Self::AddressOwner(address) => Ok(*address),
Self::Shared { .. } | Self::Immutable | Self::ObjectOwner(_) => {
Err(SuiError::UnexpectedOwnerType)
}
}
}

// NOTE: this function will return address of both AddressOwner and ObjectOwner,
// address of ObjectOwner is converted from object id, even though the type is SuiAddress.
pub fn get_owner_address(&self) -> SuiResult<SuiAddress> {
match self {
Self::AddressOwner(address) | Self::ObjectOwner(address) => Ok(*address),
Expand Down