Skip to content

Commit

Permalink
Move p2p files to dedicated crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
siy committed Aug 14, 2024
1 parent 5fe0fcd commit 8679a93
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 21 deletions.
11 changes: 11 additions & 0 deletions core-rust/Cargo.lock

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

13 changes: 13 additions & 0 deletions core-rust/p2p/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "p2p"
version = "0.1.0"
edition = "2021"

[dependencies]
node-common = { path = "../node-common" }

sbor = { workspace = true }
radix-common = { workspace = true }

# Non-Radix Engine Dependencies:
jni = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use node_common::store::typed_cf_api::SborDbCodec;
use node_common::store::typed_cf_api::{
DefaultCf, DirectDbCodec, UnitDbCodec,
};
use crate::store::p2p::address_book_components::AddressBookNodeId;
use crate::store::p2p::migration::{MigrationId, MigrationStatus};
use crate::store::p2p::typed_cf_api::AddressBookNodeIdDbCodec;
use crate::address_book_components::AddressBookNodeId;
use crate::migration::{MigrationId, MigrationStatus};
use crate::typed_cf_api::AddressBookNodeIdDbCodec;

/// Address book and safety state store migration status. Filled once during the migration.
pub struct MigrationStatusCf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
pub mod address_book_components;
pub mod traits;
pub mod migration;
pub mod column_families;
pub mod migration;
pub mod rocks_db;
pub mod traits;
pub mod typed_cf_api;

pub mod engine_prelude {
pub use radix_common::prelude::*;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ use node_common::rocksdb::{
};

use crate::engine_prelude::*;
use crate::p2p::address_book_components::AddressBookNodeId;
use crate::p2p::column_families::{AddressBookCf, HighPriorityPeersCf, MigrationStatusCf, SafetyStoreCf};
use crate::p2p::traits::node::{AddressBookStore, HighPriorityPeersStore, MigrationStore, SafetyStateStore};
use crate::address_book_components::AddressBookNodeId;
use crate::column_families::{AddressBookCf, HighPriorityPeersCf, MigrationStatusCf, SafetyStoreCf};
use crate::traits::node::{AddressBookStore, HighPriorityPeersStore, MigrationStore, SafetyStateStore};
use crate::migration::{MigrationId, MigrationStatus};
use node_common::store::rocks_db::*;
use crate::store::p2p::migration::{MigrationId, MigrationStatus};
use node_common::store::typed_cf_api::*;

/// A listing of all column family names used by the Node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
use crate::engine_prelude::*;

pub mod node {
use crate::p2p::address_book_components::AddressBookNodeId;
use crate::p2p::migration::MigrationId;
use crate::address_book_components::AddressBookNodeId;
use crate::migration::MigrationId;

use super::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* permissions under this License.
*/

use crate::p2p::address_book_components::AddressBookNodeId;
use crate::address_book_components::AddressBookNodeId;
use crate::engine_prelude::*;
use node_common::store::typed_cf_api::{DbCodec, BoundedDbCodec};

Expand Down
2 changes: 2 additions & 0 deletions core-rust/state-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ edition = "2021"

[dependencies]
node-common = { path = "../node-common" }
# Eventually this should be removed, but we need to move JNINodeRustEnvironment to other place firts.
p2p = { path = "../p2p" }

sbor = { workspace = true }
radix-transactions = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions core-rust/state-manager/src/jni/node_rust_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ use crate::priority_mempool::PriorityMempool;
use super::fatal_panic_handler::FatalPanicHandler;

use crate::protocol::ProtocolManager;
use crate::store::p2p::rocks_db::ActualAddressBookDatabase;
use p2p::rocks_db::ActualAddressBookDatabase;
use crate::store::rocks_db::ActualStateManagerDatabase;
use crate::transaction::Preparator;
use crate::{Committer, DatabaseBackendConfig, LedgerMetrics, SystemExecutor};
use crate::{StateManager, StateManagerConfig};
use crate::p2p::rocks_db::{ActualMigrationDatabase, ActualSafetyStoreDatabase};
use p2p::rocks_db::{ActualMigrationDatabase, ActualSafetyStoreDatabase};

const POINTER_JNI_FIELD_NAME: &str = "rustNodeRustEnvironmentPointer";

Expand Down
4 changes: 2 additions & 2 deletions core-rust/state-manager/src/jni/p2p/address_book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@

use crate::engine_prelude::*;
use crate::jni::node_rust_environment::JNINodeRustEnvironment;
use crate::p2p::traits::node::AddressBookStore;
use p2p::traits::node::AddressBookStore;
use jni::objects::{JClass, JObject};
use jni::sys::jbyteArray;
use jni::JNIEnv;
use node_common::java::*;
use crate::p2p::address_book_components::{AddressBookEntry, AddressBookNodeId};
use p2p::address_book_components::{AddressBookEntry, AddressBookNodeId};

#[no_mangle]
extern "system" fn Java_com_radixdlt_p2p_RocksDbAddressBookStore_removeOne(
Expand Down
2 changes: 1 addition & 1 deletion core-rust/state-manager/src/jni/p2p/high_priority_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use node_common::java::*;

use crate::engine_prelude::*;
use crate::jni::node_rust_environment::JNINodeRustEnvironment;
use crate::p2p::traits::node::HighPriorityPeersStore;
use p2p::traits::node::HighPriorityPeersStore;

#[no_mangle]
extern "system" fn Java_com_radixdlt_p2p_RocksDbHighPriorityPeersStore_upsertAllHighPriorityPeers(
Expand Down
4 changes: 2 additions & 2 deletions core-rust/state-manager/src/jni/p2p/migration_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ use jni::sys::jbyteArray;
use node_common::java::*;

use crate::jni::node_rust_environment::JNINodeRustEnvironment;
use crate::store::p2p::migration::MigrationId;
use crate::p2p::traits::node::MigrationStore;
use p2p::migration::MigrationId;
use p2p::traits::node::MigrationStore;

#[no_mangle]
extern "system" fn Java_com_radixdlt_db_RocksDbMigrationStore_migrationDone(
Expand Down
2 changes: 2 additions & 0 deletions core-rust/state-manager/src/jni/p2p/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This module should be eventually moved to p2p crate.

pub mod address_book;
pub mod high_priority_peers;
pub mod migration_store;
Expand Down
2 changes: 1 addition & 1 deletion core-rust/state-manager/src/jni/p2p/safety_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

use crate::engine_prelude::*;
use crate::jni::node_rust_environment::JNINodeRustEnvironment;
use crate::store::p2p::traits::node::SafetyStateStore;
use p2p::traits::node::SafetyStateStore;
use jni::objects::{JClass, JObject};
use jni::sys::jbyteArray;
use jni::JNIEnv;
Expand Down
1 change: 0 additions & 1 deletion core-rust/state-manager/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ pub mod historical_state;
pub mod jmt_gc;
pub mod proofs_gc;
mod codecs;
pub mod p2p;
pub mod column_families;
pub mod rocks_db;
pub mod traits;
Expand Down

0 comments on commit 8679a93

Please sign in to comment.