Skip to content

Commit

Permalink
Merge Tangle into MsTangle (#766)
Browse files Browse the repository at this point in the history
* remove unused methods

* merge `Tangle` into `MsTangle`

* Rename MsTangle to Tangle

Co-authored-by: Thibault Martinez <thibault@iota.org>
  • Loading branch information
pvdrz and thibault-martinez committed Oct 11, 2021
1 parent c5d7800 commit 57d46f8
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 493 deletions.
6 changes: 3 additions & 3 deletions bee-ledger/src/workers/consensus/white_flag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use bee_message::{
unlock::{UnlockBlock, UnlockBlocks},
Message, MessageId,
};
use bee_tangle::{ConflictReason, MsTangle};
use bee_tangle::{ConflictReason, Tangle};

use crypto::hashes::blake2b::Blake2b256;

Expand Down Expand Up @@ -205,7 +205,7 @@ fn apply_message<B: StorageBackend>(
}

async fn traverse_past_cone<B: StorageBackend>(
tangle: &MsTangle<B>,
tangle: &Tangle<B>,
storage: &B,
mut message_ids: Vec<MessageId>,
metadata: &mut WhiteFlagMetadata,
Expand Down Expand Up @@ -246,7 +246,7 @@ async fn traverse_past_cone<B: StorageBackend>(
/// Computes the ledger state according to the White Flag method.
/// RFC: https://github.com/iotaledger/protocol-rfcs/blob/master/text/0005-white-flag/0005-white-flag.md
pub async fn white_flag<B: StorageBackend>(
tangle: &MsTangle<B>,
tangle: &Tangle<B>,
storage: &B,
message_ids: &[MessageId],
metadata: &mut WhiteFlagMetadata,
Expand Down
6 changes: 3 additions & 3 deletions bee-ledger/src/workers/consensus/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use bee_message::{
MessageId,
};
use bee_runtime::{event::Bus, node::Node, shutdown_stream::ShutdownStream, worker::Worker};
use bee_tangle::{ConflictReason, MsTangle, TangleWorker};
use bee_tangle::{ConflictReason, Tangle, TangleWorker};

use async_trait::async_trait;
use futures::{channel::oneshot, stream::StreamExt};
Expand Down Expand Up @@ -88,7 +88,7 @@ pub(crate) async fn migration_from_milestone(
}

async fn confirm<N: Node>(
tangle: &MsTangle<N::Backend>,
tangle: &Tangle<N::Backend>,
storage: &N::Backend,
bus: &Bus<'static>,
message_id: MessageId,
Expand Down Expand Up @@ -280,7 +280,7 @@ where
async fn start(node: &mut N, config: Self::Config) -> Result<Self, Self::Error> {
let (snapshot_config, pruning_config) = config;
let (tx, rx) = mpsc::unbounded_channel();
let tangle = node.resource::<MsTangle<N::Backend>>();
let tangle = node.resource::<Tangle<N::Backend>>();
let storage = node.storage();
let bus = node.bus();

Expand Down
8 changes: 4 additions & 4 deletions bee-ledger/src/workers/pruning/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use bee_message::{
};
use bee_storage::access::{Batch, Fetch};
use bee_tangle::{
metadata::MessageMetadata, solid_entry_point::SolidEntryPoint, unreferenced_message::UnreferencedMessage, MsTangle,
metadata::MessageMetadata, solid_entry_point::SolidEntryPoint, unreferenced_message::UnreferencedMessage, Tangle,
};

use hashbrown::{HashMap, HashSet};
Expand All @@ -44,7 +44,7 @@ pub struct Edge {
}

pub async fn prune_confirmed_data<S: StorageBackend>(
tangle: &MsTangle<S>,
tangle: &Tangle<S>,
storage: &S,
batch: &mut S::Batch,
prune_index: MilestoneIndex,
Expand Down Expand Up @@ -180,7 +180,7 @@ pub async fn prune_confirmed_data<S: StorageBackend>(
// message happens to be the one with the highest confirmation index, then the SEP created from the
// current message would be removed too early, i.e. before all of its referrers, and pruning would
// fail without a way to ever recover. We suspect the bug to be a race condition in the
// `update_metadata` method of the `MsTangle` implementation.
// `update_metadata` method of the `Tangle` implementation.
//
// Mitigation strategy:
// We rely on the coordinator to not confirm something that attaches to a message that was confirmed
Expand Down Expand Up @@ -265,7 +265,7 @@ pub async fn prune_unconfirmed_data<S: StorageBackend>(
// In very rare situations the `referenced` flag has not been set for a confirmed message. This
// would lead to it being removed as an unconfirmed message causing the past-cone traversal of a
// milestone to fail. That would cause pruning to fail without a way to ever recover. We suspect the
// bug to be a race condition in the `update_metadata` method of the `MsTangle` implementation.
// bug to be a race condition in the `update_metadata` method of the `Tangle` implementation.
//
// Mitigation strategy:
// To make occurring this scenario sufficiently unlikely, we only prune a message with
Expand Down
4 changes: 2 additions & 2 deletions bee-ledger/src/workers/pruning/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::{types::LedgerIndex, workers::pruning::config::PruningConfig};

use bee_message::milestone::MilestoneIndex;
use bee_tangle::{storage::StorageBackend, MsTangle};
use bee_tangle::{storage::StorageBackend, Tangle};

const PRUNING_BATCH_SIZE_MAX: u32 = 200;

Expand All @@ -18,7 +18,7 @@ pub enum PruningSkipReason {
}

pub(crate) fn should_prune<B: StorageBackend>(
tangle: &MsTangle<B>,
tangle: &Tangle<B>,
ledger_index: LedgerIndex,
pruning_delay: u32,
config: &PruningConfig,
Expand Down
4 changes: 2 additions & 2 deletions bee-ledger/src/workers/pruning/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::workers::{
use bee_message::milestone::MilestoneIndex;
use bee_runtime::event::Bus;
use bee_storage::access::{Batch, Truncate};
use bee_tangle::{solid_entry_point::SolidEntryPoint, MsTangle};
use bee_tangle::{solid_entry_point::SolidEntryPoint, Tangle};

use log::{debug, info};

Expand All @@ -30,7 +30,7 @@ static NUM_PRUNINGS: AtomicUsize = AtomicUsize::new(0);

/// Performs pruning of data from `start_index` to `target_index`.
pub async fn prune<S: StorageBackend>(
tangle: &MsTangle<S>,
tangle: &Tangle<S>,
storage: &S,
bus: &Bus<'_>,
start_index: MilestoneIndex,
Expand Down
4 changes: 2 additions & 2 deletions bee-ledger/src/workers/snapshot/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{types::LedgerIndex, workers::snapshot::config::SnapshotConfig};

use bee_tangle::{storage::StorageBackend, MsTangle};
use bee_tangle::{storage::StorageBackend, Tangle};

/// Reasons for skipping snapshotting.
#[derive(Debug)]
Expand All @@ -15,7 +15,7 @@ pub enum SnapshottingSkipReason {
}

pub(crate) fn should_snapshot<B: StorageBackend>(
tangle: &MsTangle<B>,
tangle: &Tangle<B>,
ledger_index: LedgerIndex,
snapshot_depth: u32,
snapshot_config: &SnapshotConfig,
Expand Down
4 changes: 2 additions & 2 deletions bee-ledger/src/workers/snapshot/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::workers::{
use bee_message::milestone::MilestoneIndex;
use bee_runtime::{node::Node, worker::Worker};
use bee_storage::{access::AsIterator, backend::StorageBackend as _, system::StorageHealth};
use bee_tangle::{solid_entry_point::SolidEntryPoint, MsTangle, TangleWorker};
use bee_tangle::{solid_entry_point::SolidEntryPoint, Tangle, TangleWorker};

use async_trait::async_trait;

Expand All @@ -35,7 +35,7 @@ where

async fn start(node: &mut N, config: Self::Config) -> Result<Self, Self::Error> {
let (network_id, snapshot_config) = config;
let tangle = node.resource::<MsTangle<N::Backend>>();
let tangle = node.resource::<Tangle<N::Backend>>();
let storage = node.storage();

if let Some(info) = storage::fetch_snapshot_info(&*storage)? {
Expand Down
4 changes: 4 additions & 0 deletions bee-tangle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## 0.2.0 - 2021-XX-XX

### Changed

- Merged `Tangle` and `MsTangle`;

### Removed

- Tangle genericity over metadata type;
Expand Down
6 changes: 2 additions & 4 deletions bee-tangle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub mod event;
pub mod flags;
/// Message data, including message flags.
pub mod metadata;
/// Milestone-enabled tangle type.
pub mod ms_tangle;
/// Types used to represent SEPs (Solid Entry Points).
pub mod solid_entry_point;
/// Types used for interoperation with a node's storage layer.
pub mod storage;
/// Milestone-enabled tangle type.
pub mod tangle;
/// The overall `TangleWorker` type. Used as part of the bee runtime in a node.
pub mod tangle_worker;
/// A worker that periodically cleans the tip pool.
Expand All @@ -31,12 +31,10 @@ pub mod unreferenced_message;
pub mod urts;

mod conflict;
mod tangle;
mod vec_set;
mod vertex;

pub use conflict::ConflictReason;
pub use ms_tangle::MsTangle;
pub use tangle::Tangle;
pub use tangle_worker::TangleWorker;

Expand Down
Loading

0 comments on commit 57d46f8

Please sign in to comment.