Skip to content

Commit

Permalink
Remove legacy error downcasting from miner actor
Browse files Browse the repository at this point in the history
  • Loading branch information
anorth committed Jun 27, 2023
1 parent b712d1e commit acc6d0d
Show file tree
Hide file tree
Showing 14 changed files with 1,064 additions and 1,487 deletions.
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

0 comments on commit acc6d0d

Please sign in to comment.