Skip to content

Commit

Permalink
refactor(common-types): move waiting_requests, remove tokio dep (#6150)
Browse files Browse the repository at this point in the history
Description
---

Removes waiting requests which is used internally in the base node and
mempool services into core (not exposed publicly)

Motivation and Context
---
Common types should have minimal dependencies since it is a dependancy
of many L1 and L2 crates.
The tokio dependency prevents compilation to WASM. 

How Has This Been Tested?
---
Lints

What process can a PR reviewer use to test or verify this change?
---
CI - module moved and imports updated

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
sdbondi committed Feb 16, 2024
1 parent 529446f commit 506e59c
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 18 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion base_layer/common_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ once_cell = "1.8.0"
rand = "0.8"
serde = { version = "1.0.106", features = ["derive"] }
thiserror = "1.0.29"
tokio = { version = "1.23", features = ["time", "sync"] }
base64 = "0.21.0"
blake2 = "0.10"
primitive-types = { version = "0.12", features = ["serde"] }
1 change: 0 additions & 1 deletion base_layer/common_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ pub mod tari_address;
pub mod transaction;
mod tx_id;
pub mod types;
pub mod waiting_requests;
10 changes: 5 additions & 5 deletions base_layer/core/src/base_node/service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ use std::{
use futures::{pin_mut, stream::StreamExt, Stream};
use log::*;
use rand::rngs::OsRng;
use tari_common_types::{
types::BlockHash,
waiting_requests::{generate_request_key, RequestKey, WaitingRequests},
};
use tari_common_types::types::BlockHash;
use tari_comms::{connectivity::ConnectivityRequester, peer_manager::NodeId};
use tari_comms_dht::{
domain_message::OutboundDomainMessage,
Expand Down Expand Up @@ -60,7 +57,10 @@ use crate::{
},
blocks::{Block, NewBlock},
chain_storage::{BlockchainBackend, ChainStorageError},
common::BanPeriod,
common::{
waiting_requests::{generate_request_key, RequestKey, WaitingRequests},
BanPeriod,
},
proto as shared_protos,
proto::base_node as proto,
};
Expand Down
3 changes: 1 addition & 2 deletions base_layer/core/src/base_node/service/service_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use serde::{Deserialize, Serialize};
use tari_common_types::waiting_requests::RequestKey;

use crate::base_node::comms_interface::NodeCommsRequest;
use crate::{base_node::comms_interface::NodeCommsRequest, common::waiting_requests::RequestKey};

/// Request type for a received BaseNodeService request.
#[derive(Debug, Serialize, Deserialize)]
Expand Down
4 changes: 1 addition & 3 deletions base_layer/core/src/base_node/service/service_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use tari_common_types::waiting_requests::RequestKey;

use crate::base_node::comms_interface::NodeCommsResponse;
use crate::{base_node::comms_interface::NodeCommsResponse, common::waiting_requests::RequestKey};

/// Response type for a received BaseNodeService requests
#[derive(Debug)]
Expand Down
2 changes: 2 additions & 0 deletions base_layer/core/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ pub mod borsh;
pub mod byte_counter;
pub mod limited_reader;
pub mod one_sided;

#[cfg(feature = "base_node")]
pub mod rolling_avg;
#[cfg(feature = "base_node")]
pub mod rolling_vec;
pub(crate) mod waiting_requests;

/// Hasher used in the DAN to derive masks and encrypted value keys
pub type ConfidentialOutputHasher = DomainSeparatedConsensusHasher<ConfidentialOutputHashDomain, Blake2b<U64>>;
Expand Down
4 changes: 2 additions & 2 deletions base_layer/core/src/mempool/service/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
use core::fmt::{Display, Error, Formatter};

use serde::{Deserialize, Serialize};
use tari_common_types::{types::Signature, waiting_requests::RequestKey};
use tari_common_types::types::Signature;
use tari_utilities::hex::Hex;

use crate::transactions::transaction_components::Transaction;
use crate::{common::waiting_requests::RequestKey, transactions::transaction_components::Transaction};

/// API Request enum for Mempool requests.
#[derive(Debug, Serialize, Deserialize)]
Expand Down
7 changes: 4 additions & 3 deletions base_layer/core/src/mempool/service/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

use std::{fmt, fmt::Formatter};

use tari_common_types::waiting_requests::RequestKey;

use crate::mempool::{FeePerGramStat, StateResponse, StatsResponse, TxStorageResponse};
use crate::{
common::waiting_requests::RequestKey,
mempool::{FeePerGramStat, StateResponse, StatsResponse, TxStorageResponse},
};

/// API Response enum for Mempool responses.
#[derive(Clone, Debug)]
Expand Down

0 comments on commit 506e59c

Please sign in to comment.