Skip to content

Commit

Permalink
[cherry-pick] fn: remove object IDs from transactions_to_addr index (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gegaowp authored May 11, 2023
1 parent 3efe985 commit 1f46cc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit 1f46cc0

Please sign in to comment.