Skip to content

Commit

Permalink
Move MilestoneIndex to milestone payload module
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Apr 27, 2022
1 parent b1a4f45 commit 3a0d0c9
Show file tree
Hide file tree
Showing 94 changed files with 138 additions and 210 deletions.
6 changes: 5 additions & 1 deletion bee-api/bee-rest-api/src/endpoints/path_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

use bee_gossip::PeerId;
use bee_message::{milestone::MilestoneIndex, output::OutputId, payload::transaction::TransactionId, MessageId};
use bee_message::{
output::OutputId,
payload::{milestone::MilestoneIndex, transaction::TransactionId},
MessageId,
};
use warp::{reject, Filter, Rejection};

use crate::endpoints::rejection::CustomRejection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
};

use bee_ledger::workers::consensus::{self, WhiteFlagMetadata};
use bee_message::{milestone::MilestoneIndex, MessageId};
use bee_message::{payload::milestone::MilestoneIndex, MessageId};
use bee_protocol::workers::{event::MessageSolidified, request_message, MessageRequesterWorker, RequestedMessages};
use bee_runtime::{event::Bus, resource::ResourceHandle};
use bee_tangle::Tangle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::net::IpAddr;

use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;
use bee_runtime::resource::ResourceHandle;
use bee_tangle::Tangle;
use warp::{filters::BoxedFilter, reject, Filter, Rejection, Reply};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::net::IpAddr;

use bee_ledger::types::OutputDiff;
use bee_message::{milestone::MilestoneIndex, output::OutputId};
use bee_message::{output::OutputId, payload::milestone::MilestoneIndex};
use bee_runtime::resource::ResourceHandle;
use bee_storage::access::Fetch;
use warp::{filters::BoxedFilter, reject, Filter, Rejection, Reply};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::net::IpAddr;

use bee_ledger::types::Receipt;
use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;
use bee_runtime::resource::ResourceHandle;
use bee_storage::access::AsIterator;
use warp::{filters::BoxedFilter, Filter, Rejection, Reply};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::net::IpAddr;

use bee_ledger::types::Receipt;
use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;
use bee_runtime::resource::ResourceHandle;
use bee_storage::access::Fetch;
use warp::{filters::BoxedFilter, Filter, Rejection, Reply};
Expand Down
2 changes: 1 addition & 1 deletion bee-api/bee-rest-api/src/endpoints/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use bee_ledger::types::{ConsumedOutput, OutputDiff, Receipt};
use bee_message::{address::Ed25519Address, milestone::MilestoneIndex, output::OutputId};
use bee_message::{address::Ed25519Address, output::OutputId, payload::milestone::MilestoneIndex};
use bee_storage::{
access::{AsIterator, Fetch},
backend,
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/types/consumed_output.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use bee_message::{milestone::MilestoneIndex, payload::transaction::TransactionId};
use bee_message::payload::{milestone::MilestoneIndex, transaction::TransactionId};

/// Represents a newly consumed output.
#[derive(Clone, Debug, Eq, PartialEq, packable::Packable)]
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/types/created_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use core::ops::Deref;

use bee_message::{milestone::MilestoneIndex, output::Output, MessageId};
use bee_message::{output::Output, payload::milestone::MilestoneIndex, MessageId};

use crate::types::error::Error;

Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/types/ledger_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use core::ops::Deref;

use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;

/// A wrapper type to represent the current ledger index.
#[derive(Debug, Clone, Copy, Default, Eq, Hash, Ord, PartialEq, PartialOrd, packable::Packable)]
Expand Down
5 changes: 4 additions & 1 deletion bee-ledger/src/types/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use bee_message::{constant::TOKEN_SUPPLY, milestone::MilestoneIndex, payload::milestone::ReceiptMilestoneOption};
use bee_message::{
constant::TOKEN_SUPPLY,
payload::milestone::{MilestoneIndex, ReceiptMilestoneOption},
};

use crate::types::{error::Error, TreasuryOutput};

Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/types/snapshot/header.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use bee_message::{milestone::MilestoneIndex, payload::milestone::MilestoneId};
use bee_message::payload::milestone::{MilestoneId, MilestoneIndex};
use packable::{
error::{UnpackError, UnpackErrorExt},
packer::Packer,
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/types/snapshot/info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;

/// Snapshot information to be stored.
#[derive(Clone, Debug, Eq, PartialEq, packable::Packable)]
Expand Down
5 changes: 4 additions & 1 deletion bee-ledger/src/workers/consensus/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
use std::collections::HashMap;

use bee_message::{
milestone::MilestoneIndex, output::OutputId, payload::milestone::MilestoneId, semantic::ConflictReason, MessageId,
output::OutputId,
payload::milestone::{MilestoneId, MilestoneIndex},
semantic::ConflictReason,
MessageId,
};

use crate::types::{ConsumedOutput, CreatedOutput};
Expand Down
3 changes: 1 addition & 2 deletions bee-ledger/src/workers/consensus/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use std::any::TypeId;

use async_trait::async_trait;
use bee_message::{
milestone::MilestoneIndex,
output::{unlock_condition::AddressUnlockCondition, BasicOutput, Output, OutputId},
payload::{
milestone::{MilestoneId, ReceiptMilestoneOption},
milestone::{MilestoneId, MilestoneIndex, ReceiptMilestoneOption},
transaction::TransactionId,
Payload,
},
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use std::convert::Infallible;

use bee_message::{milestone::MilestoneIndex, Error as MessageError, MessageId};
use bee_message::{payload::milestone::MilestoneIndex, Error as MessageError, MessageId};
use packable::error::UnpackError;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use std::collections::HashMap;

use bee_message::{
milestone::MilestoneIndex,
output::{Output, OutputId},
payload::milestone::MilestoneIndex,
semantic::ConflictReason,
MessageId,
};
Expand Down
6 changes: 1 addition & 5 deletions bee-ledger/src/workers/pruning/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

use std::collections::VecDeque;

use bee_message::{
milestone::{Milestone, MilestoneIndex},
output::OutputId,
Message, MessageId,
};
use bee_message::{milestone::Milestone, output::OutputId, payload::milestone::MilestoneIndex, Message, MessageId};
use bee_storage::access::{Batch, Fetch};
use bee_tangle::{
metadata::MessageMetadata, solid_entry_point::SolidEntryPoint, unreferenced_message::UnreferencedMessage, Tangle,
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/pruning/condition.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

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

use crate::{types::LedgerIndex, workers::pruning::config::PruningConfig};
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/pruning/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use bee_message::{milestone::MilestoneIndex, MessageId};
use bee_message::{payload::milestone::MilestoneIndex, MessageId};

#[derive(Debug, thiserror::Error)]
pub enum Error {
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/pruning/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
time::{Instant, SystemTime},
};

use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;
use bee_runtime::event::Bus;
use bee_storage::access::{Batch, Truncate};
use bee_tangle::{solid_entry_point::SolidEntryPoint, Tangle};
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/snapshot/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::{io::Read, path::Path};

use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;
use bytes::Buf;
use futures::{future::join_all, StreamExt};
use log::{debug, info, warn};
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/snapshot/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use bee_message::milestone::MilestoneIndex;
use bee_message::payload::milestone::MilestoneIndex;
use thiserror::Error;

use crate::types::{snapshot::SnapshotKind, Error as TypesError};
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/snapshot/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{
};

use bee_message::{
milestone::MilestoneIndex,
output::{self, OutputId},
payload::milestone::MilestoneIndex,
};
use bee_storage::access::{Insert, Truncate};
use bee_tangle::solid_entry_point::SolidEntryPoint;
Expand Down
2 changes: 1 addition & 1 deletion bee-ledger/src/workers/snapshot/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::{any::TypeId, collections::HashMap};

use async_trait::async_trait;
use bee_message::milestone::MilestoneIndex;
use bee_message::payload::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, Tangle, TangleWorker};
Expand Down
6 changes: 1 addition & 5 deletions bee-ledger/src/workers/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

use std::collections::HashMap;

use bee_message::{
milestone::{Milestone, MilestoneIndex},
output::OutputId,
Message, MessageId,
};
use bee_message::{milestone::Milestone, output::OutputId, payload::milestone::MilestoneIndex, Message, MessageId};
use bee_storage::{
access::{AsIterator, Batch, BatchBuilder, Exist, Fetch, Insert, Truncate},
backend,
Expand Down
2 changes: 1 addition & 1 deletion bee-message/src/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use primitive_types::U256;
use serde::{Deserialize, Serialize};

use crate::milestone::MilestoneIndex;
use crate::payload::milestone::MilestoneIndex;

/// Describes a U256.
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
Expand Down
3 changes: 0 additions & 3 deletions bee-message/src/milestone/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

mod index;

pub use self::index::MilestoneIndex;
use crate::MessageId;

/// Defines a coordinator milestone.
Expand Down
2 changes: 1 addition & 1 deletion bee-message/src/output/byte_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use core::mem::size_of;

use crate::{milestone::MilestoneIndex, output::OutputId, MessageId};
use crate::{output::OutputId, payload::milestone::MilestoneIndex, MessageId};

const DEFAULT_BYTE_COST: u64 = 500;
const DEFAULT_BYTE_COST_FACTOR_KEY: u64 = 10;
Expand Down
4 changes: 2 additions & 2 deletions bee-message/src/output/unlock_condition/expiration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use packable::{
Packable,
};

use crate::{address::Address, milestone::MilestoneIndex, Error};
use crate::{address::Address, payload::milestone::MilestoneIndex, Error};

/// Defines a milestone index and/or unix time until which only Address, defined in Address Unlock Condition, is allowed
/// to unlock the output. After the milestone index and/or unix time, only Return Address can unlock it.
Expand Down Expand Up @@ -127,7 +127,7 @@ pub mod dto {
use crate::{
address::dto::AddressDto,
dto::{is_zero, is_zero_milestone},
milestone::MilestoneIndex,
payload::milestone::MilestoneIndex,
};

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion bee-message/src/output/unlock_condition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub use self::{
state_controller_address::StateControllerAddressUnlockCondition,
storage_deposit_return::StorageDepositReturnUnlockCondition, timelock::TimelockUnlockCondition,
};
use crate::{address::Address, create_bitflags, milestone::MilestoneIndex, Error};
use crate::{address::Address, create_bitflags, payload::milestone::MilestoneIndex, Error};

///
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, From, Packable)]
Expand Down
4 changes: 2 additions & 2 deletions bee-message/src/output/unlock_condition/timelock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use packable::{
Packable,
};

use crate::{milestone::MilestoneIndex, Error};
use crate::{payload::milestone::MilestoneIndex, Error};

/// Defines a milestone index and/or unix timestamp until which the output can not be unlocked.
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, From)]
Expand Down Expand Up @@ -92,7 +92,7 @@ pub mod dto {

use crate::{
dto::{is_zero, is_zero_milestone},
milestone::MilestoneIndex,
payload::milestone::MilestoneIndex,
};

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down
3 changes: 1 addition & 2 deletions bee-message/src/payload/milestone/essence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ use packable::{
};

use crate::{
milestone::MilestoneIndex,
parent::Parents,
payload::milestone::{MilestoneId, MilestoneOptions},
payload::milestone::{MilestoneId, MilestoneIndex, MilestoneOptions},
Error,
};

Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion bee-message/src/payload/milestone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! Module describing the milestone payload.

mod essence;
mod index;
mod milestone_id;

///
Expand All @@ -20,6 +21,7 @@ use packable::{bounded::BoundedU8, prefix::VecPrefix, Packable};
pub(crate) use self::essence::MilestoneMetadataLength;
pub use self::{
essence::MilestoneEssence,
index::MilestoneIndex,
milestone_id::MilestoneId,
option::{MilestoneOption, MilestoneOptions, PowMilestoneOption, ReceiptMilestoneOption},
};
Expand Down Expand Up @@ -161,7 +163,8 @@ pub mod dto {
use self::option::dto::MilestoneOptionDto;
use super::*;
use crate::{
error::dto::DtoError, milestone::MilestoneIndex, parent::Parents, signature::dto::SignatureDto, MessageId,
error::dto::DtoError, parent::Parents, payload::milestone::MilestoneIndex, signature::dto::SignatureDto,
MessageId,
};

/// The payload type to define a milestone.
Expand Down
3 changes: 1 addition & 2 deletions bee-message/src/payload/milestone/option/receipt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ pub(crate) use self::migrated_funds_entry::MigratedFundsAmount;
pub use self::{migrated_funds_entry::MigratedFundsEntry, tail_transaction_hash::TailTransactionHash};
use crate::{
constant::TOKEN_SUPPLY,
milestone::MilestoneIndex,
output::OUTPUT_COUNT_RANGE,
payload::{Payload, TreasuryTransactionPayload},
payload::{milestone::MilestoneIndex, Payload, TreasuryTransactionPayload},
Error,
};

Expand Down
6 changes: 4 additions & 2 deletions bee-message/src/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ use primitive_types::U256;
use crate::{
address::Address,
error::Error,
milestone::MilestoneIndex,
output::{create_inputs_commitment, ChainId, NativeTokens, Output, OutputId, TokenId, UnlockCondition},
payload::transaction::{RegularTransactionEssence, TransactionEssence, TransactionId},
payload::{
milestone::MilestoneIndex,
transaction::{RegularTransactionEssence, TransactionEssence, TransactionId},
},
unlock_block::UnlockBlocks,
};

Expand Down
Loading

0 comments on commit 3a0d0c9

Please sign in to comment.