Skip to content

Commit 35d757a

Browse files
msmouselarry-aptos
andauthored
internal indexer: parse tables in resource groups (aptos-labs#9061)
Co-authored-by: larry-aptos <[email protected]>
1 parent 8323f6e commit 35d757a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

storage/indexer/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use move_core_types::{
3535
};
3636
use move_resource_viewer::{AnnotatedMoveValue, MoveValueAnnotator};
3737
use std::{
38-
collections::HashMap,
38+
collections::{BTreeMap, HashMap},
3939
convert::TryInto,
4040
sync::{atomic::Ordering, Arc},
4141
};
@@ -166,7 +166,7 @@ impl<'a> TableInfoParser<'a> {
166166
match path {
167167
Path::Code(_) => (),
168168
Path::Resource(struct_tag) => self.parse_struct(struct_tag, bytes)?,
169-
Path::ResourceGroup(_struct_tag) => (),
169+
Path::ResourceGroup(_struct_tag) => self.parse_resource_group(bytes)?,
170170
}
171171
},
172172
StateKeyInner::TableItem { handle, .. } => self.parse_table_item(*handle, bytes)?,
@@ -184,6 +184,15 @@ impl<'a> TableInfoParser<'a> {
184184
)
185185
}
186186

187+
fn parse_resource_group(&mut self, bytes: &[u8]) -> Result<()> {
188+
type ResourceGroup = BTreeMap<StructTag, Vec<u8>>;
189+
190+
for (struct_tag, bytes) in bcs::from_bytes::<ResourceGroup>(bytes)? {
191+
self.parse_struct(struct_tag, &bytes)?;
192+
}
193+
Ok(())
194+
}
195+
187196
fn parse_table_item(&mut self, handle: TableHandle, bytes: &'a [u8]) -> Result<()> {
188197
match self.get_table_info(handle)? {
189198
Some(table_info) => {

0 commit comments

Comments
 (0)