Skip to content

Commit

Permalink
fix(db): use _id instead of metadata.output_id (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
grtlr committed Sep 22, 2022
1 parent 1c43dba commit fec5b66
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/bin/inx-chronicle/api/stardust/core/routes.rs
Expand Up @@ -312,10 +312,7 @@ async fn transaction_included_block(
}

async fn receipts(database: Extension<MongoDb>) -> ApiResult<ReceiptsResponse> {
let mut receipts_at = database
.collection::<MilestoneCollection>()
.stream_all_receipts()
.await?;
let mut receipts_at = database.collection::<MilestoneCollection>().get_all_receipts().await?;
let mut receipts = Vec::new();
while let Some((receipt, at)) = receipts_at.try_next().await? {
let receipt: &bee_block_stardust::payload::milestone::MilestoneOption = &receipt.try_into()?;
Expand All @@ -336,7 +333,7 @@ async fn receipts(database: Extension<MongoDb>) -> ApiResult<ReceiptsResponse> {
async fn receipts_migrated_at(database: Extension<MongoDb>, Path(index): Path<u32>) -> ApiResult<ReceiptsResponse> {
let mut receipts_at = database
.collection::<MilestoneCollection>()
.stream_receipts_migrated_at(index.into())
.get_receipts_migrated_at(index.into())
.await?;
let mut receipts = Vec::new();
while let Some((receipt, at)) = receipts_at.try_next().await? {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/inx-chronicle/api/stardust/explorer/routes.rs
Expand Up @@ -51,7 +51,7 @@ async fn ledger_updates_by_address(

let mut record_stream = database
.collection::<LedgerUpdateCollection>()
.stream_ledger_updates_by_address(
.get_ledger_updates_by_address(
&address_dto,
// Get one extra record so that we can create the cursor.
page_size + 1,
Expand Down Expand Up @@ -99,7 +99,7 @@ async fn ledger_updates_by_milestone(

let mut record_stream = database
.collection::<LedgerUpdateCollection>()
.stream_ledger_updates_by_milestone(milestone_index, page_size + 1, cursor)
.get_ledger_updates_by_milestone(milestone_index, page_size + 1, cursor)
.await?;

// Take all of the requested records first
Expand Down
4 changes: 2 additions & 2 deletions src/db/collections/ledger_update.rs
Expand Up @@ -169,7 +169,7 @@ impl LedgerUpdateCollection {
}

/// Streams updates to the ledger for a given address.
pub async fn stream_ledger_updates_by_address(
pub async fn get_ledger_updates_by_address(
&self,
address: &Address,
page_size: usize,
Expand Down Expand Up @@ -216,7 +216,7 @@ impl LedgerUpdateCollection {
}

/// Streams updates to the ledger for a given milestone index (sorted by [`OutputId`]).
pub async fn stream_ledger_updates_by_milestone(
pub async fn get_ledger_updates_by_milestone(
&self,
milestone_index: MilestoneIndex,
page_size: usize,
Expand Down
4 changes: 2 additions & 2 deletions src/db/collections/milestone.rs
Expand Up @@ -260,7 +260,7 @@ impl MilestoneCollection {
}

/// Streams all available receipt milestone options together with their corresponding `MilestoneIndex`.
pub async fn stream_all_receipts(
pub async fn get_all_receipts(
&self,
) -> Result<impl Stream<Item = Result<(MilestoneOption, MilestoneIndex), Error>>, Error> {
#[derive(Deserialize)]
Expand Down Expand Up @@ -290,7 +290,7 @@ impl MilestoneCollection {

/// Streams all available receipt milestone options together with their corresponding `MilestoneIndex` that were
/// migrated at the given index.
pub async fn stream_receipts_migrated_at(
pub async fn get_receipts_migrated_at(
&self,
migrated_at: MilestoneIndex,
) -> Result<impl Stream<Item = Result<(MilestoneOption, MilestoneIndex), Error>>, Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/db/collections/outputs/indexer/mod.rs
Expand Up @@ -164,7 +164,7 @@ impl OutputCollection {
doc! { "$sort": sort },
doc! { "$limit": page_size as i64 },
doc! { "$replaceWith": {
"output_id": "$metadata.output_id",
"output_id": "$_id",
"booked_index": "$metadata.booked.milestone_index"
} },
],
Expand Down

0 comments on commit fec5b66

Please sign in to comment.