Skip to content

Commit

Permalink
fix(backfiller): when querying chain for trees to backfill the merkle…
Browse files Browse the repository at this point in the history
…_tree_get_size errors from not being able to determine the trees size. this immediately ends the loop and logs the error preventing trees from being gathered. instead continue to the next tree and exclude it from the trees to backfill. (#113)
  • Loading branch information
kespinola authored Dec 1, 2023
1 parent 9bb9f8f commit ba20d9d
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions nft_ingester/src/backfiller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,18 +737,31 @@ impl<'a, T: Messenger> Backfiller<'a, T> {
let (mut header_bytes, rest) = account
.data
.split_at_mut(CONCURRENT_MERKLE_TREE_HEADER_SIZE_V1);
let header: ConcurrentMerkleTreeHeader =
ConcurrentMerkleTreeHeader::try_from_slice(&mut header_bytes)
.map_err(|e| IngesterError::RpcGetDataError(e.to_string()))?;
let header = match ConcurrentMerkleTreeHeader::try_from_slice(&mut header_bytes) {
Ok(header) => header,
Err(e) => {
error!("Failed to parse header: {}", e);
continue;
}
};

let auth = Pubkey::find_program_address(&[pubkey.as_ref()], &mpl_bubblegum::ID).0;

let merkle_tree_size = merkle_tree_get_size(&header)
.map_err(|e| IngesterError::RpcGetDataError(e.to_string()))?;
let merkle_tree_size = match merkle_tree_get_size(&header) {
Ok(size) => size,
Err(e) => {
error!("Failed to get size: {}", e);
continue;
}
};
let (tree_bytes, _canopy_bytes) = rest.split_at_mut(merkle_tree_size);
let seq_bytes = tree_bytes[0..8].try_into().map_err(|_e| {
IngesterError::RpcGetDataError("Failed to convert seq bytes to array".to_string())
})?;
let seq_bytes = match tree_bytes[0..8].try_into() {
Ok(bytes) => bytes,
Err(_e) => {
error!("Failed to convert seq bytes to array");
continue;
}
};
let seq = u64::from_le_bytes(seq_bytes);
list.insert(pubkey, SlotSeq(header.get_creation_slot(), seq));

Expand Down

0 comments on commit ba20d9d

Please sign in to comment.