Skip to content

Commit

Permalink
fix(artifact_pool): Remove warning if unvalidated artifact to be remo…
Browse files Browse the repository at this point in the history
…ved doesn't exist
  • Loading branch information
eichhorl committed Feb 6, 2024
1 parent 293b694 commit 4025498
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
9 changes: 3 additions & 6 deletions rs/artifact_pool/src/consensus_pool.rs
Expand Up @@ -272,15 +272,12 @@ impl UncachedConsensusPoolImpl {
crate::lmdb_pool::PersistentHeightIndexedPool::new_consensus_pool(
lmdb_config,
config.persistent_pool_read_only,
log.clone(),
log,
),
) as Box<_>,
#[cfg(feature = "rocksdb_backend")]
PersistentPoolBackend::RocksDB(config) => Box::new(
crate::rocksdb_pool::PersistentHeightIndexedPool::new_consensus_pool(
config,
log.clone(),
),
crate::rocksdb_pool::PersistentHeightIndexedPool::new_consensus_pool(config, log),
) as Box<_>,
#[allow(unreachable_patterns)]
cfg => {
Expand All @@ -290,7 +287,7 @@ impl UncachedConsensusPoolImpl {

UncachedConsensusPoolImpl {
validated,
unvalidated: Box::new(InMemoryPoolSection::new(log)),
unvalidated: Box::new(InMemoryPoolSection::new()),
}
}
}
Expand Down
13 changes: 4 additions & 9 deletions rs/artifact_pool/src/inmemory_pool.rs
Expand Up @@ -6,7 +6,6 @@ use crate::{
use ic_interfaces::consensus_pool::{
HeightIndexedPool, HeightRange, OnlyError, PoolSection, PurgeableArtifactType,
};
use ic_logger::{warn, ReplicaLogger};
use ic_types::{
artifact::ConsensusMessageId,
consensus::*,
Expand All @@ -18,15 +17,13 @@ use std::collections::BTreeMap;
pub struct InMemoryPoolSection<T: IntoInner<ConsensusMessage>> {
indexes: Indexes,
artifacts: BTreeMap<CryptoHash, T>,
log: ReplicaLogger,
}

impl<T: IntoInner<ConsensusMessage> + HasTimestamp + Clone> InMemoryPoolSection<T> {
pub fn new(log: ReplicaLogger) -> InMemoryPoolSection<T> {
pub fn new() -> InMemoryPoolSection<T> {
InMemoryPoolSection {
artifacts: BTreeMap::new(),
indexes: Indexes::new(),
log,
}
}

Expand Down Expand Up @@ -279,9 +276,7 @@ impl<T: IntoInner<ConsensusMessage> + HasTimestamp + Clone> MutablePoolSection<T
match op {
PoolSectionOp::Insert(artifact) => self.insert(artifact),
PoolSectionOp::Remove(msg_id) => {
if self.remove(&msg_id).is_none() {
warn!(self.log, "Error removing artifact {:?}", &msg_id)
} else {
if self.remove(&msg_id).is_some() {
purged.push(msg_id)
}
}
Expand Down Expand Up @@ -334,7 +329,7 @@ pub mod test {
assert!(ic_test_utilities_time::with_timeout(
std::time::Duration::new(12, 0),
|| {
let mut pool = InMemoryPoolSection::new(ic_logger::replica_logger::no_op_logger());
let mut pool = InMemoryPoolSection::new();
let min = Height::from(1);
let max = Height::from(std::u64::MAX);
pool.insert(make_artifact(fake_random_beacon(min)));
Expand All @@ -358,7 +353,7 @@ pub mod test {
.collect::<Vec<_>>();
let ids = beacons.iter().map(|b| b.get_id()).collect::<HashSet<_>>();

let mut pool = InMemoryPoolSection::new(ic_logger::replica_logger::no_op_logger());
let mut pool = InMemoryPoolSection::new();
beacons
.into_iter()
.for_each(|b| pool.insert(make_artifact(b)));
Expand Down

0 comments on commit 4025498

Please sign in to comment.