diff --git a/Cargo.lock b/Cargo.lock index 18bfec122..80fdd32df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -844,6 +844,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + [[package]] name = "cc" version = "1.0.79" @@ -1378,6 +1384,31 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossterm" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +dependencies = [ + "bitflags 1.3.2", + "crossterm_winapi", + "libc", + "mio", + "parking_lot 0.12.1", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -2044,6 +2075,7 @@ dependencies = [ "darkfi", "darkfi-serial", "easy-parallel", + "libsqlite3-sys", "log", "serde", "serde_json", @@ -2270,6 +2302,29 @@ dependencies = [ "libloading 0.8.0", ] +[[package]] +name = "dnetview" +version = "0.4.1" +dependencies = [ + "async-channel", + "async-std", + "clap 4.3.19", + "darkfi", + "easy-parallel", + "hex", + "libsqlite3-sys", + "log", + "rand 0.8.5", + "serde", + "serde_json", + "simplelog", + "smol", + "termion 2.0.1", + "thiserror", + "tui", + "url", +] + [[package]] name = "downcast-rs" version = "1.2.0" @@ -3684,6 +3739,18 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.48.0", +] + [[package]] name = "more-asserts" version = "0.2.2" @@ -3924,6 +3991,12 @@ dependencies = [ "libc", ] +[[package]] +name = "numtoa" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" + [[package]] name = "object" version = "0.31.1" @@ -4746,6 +4819,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_termios" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f" +dependencies = [ + "redox_syscall 0.2.16", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -5371,6 +5453,17 @@ dependencies = [ "signal-hook", ] +[[package]] +name = "signal-hook-mio" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -5880,6 +5973,30 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "termion" +version = "1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e" +dependencies = [ + "libc", + "numtoa", + "redox_syscall 0.2.16", + "redox_termios", +] + +[[package]] +name = "termion" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "659c1f379f3408c7e5e84c7d0da6d93404e3800b6b9d063ba24436419302ec90" +dependencies = [ + "libc", + "numtoa", + "redox_syscall 0.2.16", + "redox_termios", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -6795,6 +6912,20 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375812fa44dab6df41c195cd2f7fecb488f6c09fbaafb62807488cefab642bff" +[[package]] +name = "tui" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" +dependencies = [ + "bitflags 1.3.2", + "cassowary", + "crossterm", + "termion 1.5.6", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "typed-index-collections" version = "3.1.0" diff --git a/src/validator/consensus/mod.rs b/src/validator/consensus/mod.rs index 04279bcca..a895d4210 100644 --- a/src/validator/consensus/mod.rs +++ b/src/validator/consensus/mod.rs @@ -124,7 +124,7 @@ impl Consensus { } // Check if proposal extends any existing forks - let (mut fork, index) = self.find_extended_fork_overlay(&proposal).await?; + let (mut fork, index) = self.find_extended_fork(&proposal).await?; // Grab overlay last block let previous = fork.overlay.lock().unwrap().last_block()?; @@ -166,7 +166,7 @@ impl Consensus { /// Given a proposal, find the index of the fork chain it extends, along with the specific /// extended proposal index. - fn find_extended_fork(&self, proposal: &Proposal) -> Result<(usize, usize)> { + fn find_extended_fork_index(&self, proposal: &Proposal) -> Result<(usize, usize)> { for (f_index, fork) in self.forks.iter().enumerate() { // Traverse fork proposals sequence in reverse for (p_index, p_hash) in fork.proposals.iter().enumerate().rev() { @@ -184,12 +184,9 @@ impl Consensus { /// we re-apply the proposals up to the extending one. If proposal extends canonical, /// a new fork is created. Additionally, we return the fork index if a new fork /// was not created, so caller can replace the fork. - async fn find_extended_fork_overlay( - &self, - proposal: &Proposal, - ) -> Result<(Fork, Option)> { + async fn find_extended_fork(&self, proposal: &Proposal) -> Result<(Fork, Option)> { // Check if proposal extends any fork - let found = self.find_extended_fork(proposal); + let found = self.find_extended_fork_index(proposal); if found.is_err() { // Check if we extend canonical let (last_slot, last_block) = self.blockchain.last()?;