Skip to content

Commit

Permalink
[refactor] #2664: Introduce new wsv
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <shanin1000@yandex.ru>
  • Loading branch information
Erigara committed Nov 20, 2023
1 parent af85650 commit 04fe423
Show file tree
Hide file tree
Showing 36 changed files with 3,028 additions and 2,110 deletions.
55 changes: 52 additions & 3 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ serde_with = { version = "3.3.0", default-features = false }
parity-scale-codec = { version = "3.6.5", default-features = false }
json5 = "0.4.1"

storage = { git = "https://github.com/Erigara/storage.git", branch="main" }

[workspace.lints]
rust.anonymous_parameters = "deny"
rust.future_incompatible = "deny"
Expand Down
19 changes: 13 additions & 6 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ use iroha_core::{
gossiper::{TransactionGossiper, TransactionGossiperHandle},
handler::ThreadHandler,
kura::Kura,
prelude::{World, WorldStateView},
prelude::World,
query::store::LiveQueryStore,
queue::Queue,
smartcontracts::isi::Registrable as _,
snapshot::{try_read_snapshot, SnapshotMaker, SnapshotMakerHandle},
sumeragi::{SumeragiHandle, SumeragiStartArgs},
tx::PeerId,
wsv::WorldState,
IrohaNetwork,
};
use iroha_data_model::prelude::*;
Expand Down Expand Up @@ -95,6 +96,8 @@ pub struct Iroha {
pub torii: Option<Torii>,
/// Snapshot service
pub snapshot_maker: SnapshotMakerHandle,
/// State of blockchain
pub wsv: Arc<WorldState>,
/// Thread handlers
thread_handlers: Vec<ThreadHandler>,

Expand Down Expand Up @@ -256,7 +259,7 @@ impl Iroha {
.map_or_else(
|error| {
iroha_logger::warn!(%error, "Failed to load wsv from snapshot, creating empty wsv");
WorldStateView::from_configuration(
WorldState::from_configuration(
*config.wsv,
world,
Arc::clone(&kura),
Expand All @@ -265,12 +268,13 @@ impl Iroha {
},
|wsv| {
iroha_logger::info!(
at_height = wsv.height(),
at_height = wsv.view().height(),
"Successfully loaded wsv from snapshot"
);
wsv
},
);
let wsv = Arc::new(wsv);

let queue = Arc::new(Queue::from_configuration(&config.queue));
if Self::start_telemetry(telemetry, &config).await? {
Expand All @@ -284,7 +288,7 @@ impl Iroha {
let sumeragi = SumeragiHandle::start(SumeragiStartArgs {
configuration: &config.sumeragi,
events_sender: events_sender.clone(),
wsv,
wsv: Arc::clone(&wsv),
queue: Arc::clone(&queue),
kura: Arc::clone(&kura),
network: network.clone(),
Expand All @@ -298,14 +302,15 @@ impl Iroha {
Arc::clone(&kura),
PeerId::new(&config.torii.p2p_addr, &config.public_key),
network.clone(),
Arc::clone(&wsv),
)
.start();

let gossiper = TransactionGossiper::from_configuration(
&config.sumeragi,
network.clone(),
Arc::clone(&queue),
sumeragi.clone(),
Arc::clone(&wsv),
)
.start();

Expand All @@ -326,7 +331,7 @@ impl Iroha {
.start();

let snapshot_maker =
SnapshotMaker::from_configuration(&config.snapshot, sumeragi.clone()).start();
SnapshotMaker::from_configuration(&config.snapshot, Arc::clone(&wsv)).start();

let torii = Torii::from_configuration(
config.clone(),
Expand All @@ -336,6 +341,7 @@ impl Iroha {
sumeragi.clone(),
live_query_store_handle,
Arc::clone(&kura),
Arc::clone(&wsv),
);

Self::start_listening_signal(Arc::clone(&notify_shutdown))?;
Expand All @@ -349,6 +355,7 @@ impl Iroha {
kura,
torii,
snapshot_maker,
wsv,
thread_handlers: vec![kura_thread_handler],
#[cfg(debug_assertions)]
freeze_status,
Expand Down
2 changes: 2 additions & 0 deletions cli/src/torii/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use iroha_core::{
query::store::LiveQueryStoreHandle,
queue::{self, Queue},
sumeragi::SumeragiHandle,
wsv::WorldState,
EventsSender,
};
use tokio::sync::Notify;
Expand All @@ -40,6 +41,7 @@ pub struct Torii {
sumeragi: SumeragiHandle,
query_service: LiveQueryStoreHandle,
kura: Arc<Kura>,
wsv: Arc<WorldState>,
}

/// Torii errors.
Expand Down
Loading

0 comments on commit 04fe423

Please sign in to comment.