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

Remove legacy error downcasting from miner actor #1322

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
11 changes: 6 additions & 5 deletions actors/miner/src/bitfield_queue.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use anyhow::Context;
use std::convert::TryInto;

use cid::Cid;
use fil_actors_runtime::{ActorDowncast, Array};
use fil_actors_runtime::Array;
use fvm_ipld_amt::Error as AmtError;
use fvm_ipld_bitfield::BitField;
use fvm_ipld_blockstore::Blockstore;
Expand Down Expand Up @@ -35,13 +36,13 @@ impl<'db, BS: Blockstore> BitFieldQueue<'db, BS> {
let bitfield = self
.amt
.get(epoch)
.map_err(|e| e.downcast_wrap(format!("failed to lookup queue epoch {}", epoch)))?
.with_context(|| format!("failed to lookup queue epoch {}", epoch))?
.cloned()
.unwrap_or_default();

self.amt
.set(epoch, &bitfield | values)
.map_err(|e| e.downcast_wrap(format!("failed to set queue epoch {}", epoch)))?;
.with_context(|| format!("failed to set queue epoch {}", epoch))?;

Ok(())
}
Expand Down Expand Up @@ -73,11 +74,11 @@ impl<'db, BS: Blockstore> BitFieldQueue<'db, BS> {

Ok(())
})
.map_err(|e| e.downcast_wrap("failed to cut from bitfield queue"))?;
.context("failed to cut from bitfield queue")?;

self.amt
.batch_delete(epochs_to_remove, true)
.map_err(|e| e.downcast_wrap("failed to remove empty epochs from bitfield queue"))?;
.context("failed to remove empty epochs from bitfield queue")?;

Ok(())
}
Expand Down
Loading