From ebcfdb947c9ff6b8cb000695b7a6bc434075d81a Mon Sep 17 00:00:00 2001 From: danda Date: Wed, 18 Dec 2024 12:15:38 +0800 Subject: [PATCH] feat: display if block in canonical chain or not Adds a 'Canonical' field to the /block page. note: this requires updating neptune-core in order to obtain the field from neptune-core's /block_info rpc endpoint. it was also necessary to change 'use neptune_core::" statements to 'use neptune_cash::' --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- src/html/page/block.rs | 2 +- src/html/page/root.rs | 2 +- src/html/page/utxo.rs | 2 +- src/model/app_state.rs | 8 ++++---- src/model/block_selector_extended.rs | 4 ++-- src/model/height_or_digest.rs | 8 ++++---- src/neptune_rpc.rs | 2 +- src/rpc/block_digest.rs | 2 +- src/rpc/block_info.rs | 2 +- src/rpc/utxo_digest.rs | 2 +- templates/web/html/page/block_info.html | 16 ++++++++++++++++ 13 files changed, 39 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3351cb..a04903b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -1946,9 +1946,9 @@ dependencies = [ ] [[package]] -name = "neptune-core" +name = "neptune-cash" version = "0.0.10" -source = "git+https://github.com/Neptune-Crypto/neptune-core.git?rev=1f4afb0c000e60f976a15a990414349d17207524#1f4afb0c000e60f976a15a990414349d17207524" +source = "git+https://github.com/Neptune-Crypto/neptune-core.git?rev=dbc660634c27cdd2c65ed760dadc123c244d6cd1#dbc660634c27cdd2c65ed760dadc123c244d6cd1" dependencies = [ "aead", "aes-gcm", @@ -2020,7 +2020,7 @@ dependencies = [ "clap", "html-escaper", "lettre", - "neptune-core", + "neptune-cash", "readonly", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 7f2a47d..964ac57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ tokio = { version = "1.37.0", features = ["full", "tracing"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" -# 1f4afb0c000e60f976a15a990414349d17207524 = betanet -neptune-core = {git = "https://github.com/Neptune-Crypto/neptune-core.git", rev = "1f4afb0c000e60f976a15a990414349d17207524"} +# dbc660634c27cdd2c65ed760dadc123c244d6cd1 = betanet +neptune-cash = {git = "https://github.com/Neptune-Crypto/neptune-core.git", rev = "dbc660634c27cdd2c65ed760dadc123c244d6cd1"} tarpc = { version = "^0.34", features = [ "tokio1", "serde-transport", diff --git a/src/html/page/block.rs b/src/html/page/block.rs index 1298a94..b406ef7 100644 --- a/src/html/page/block.rs +++ b/src/html/page/block.rs @@ -9,7 +9,7 @@ use axum::response::Html; use axum::response::Response; use html_escaper::Escape; use html_escaper::Trusted; -use neptune_core::models::blockchain::block::block_info::BlockInfo; +use neptune_cash::models::blockchain::block::block_info::BlockInfo; use std::sync::Arc; use tarpc::context; diff --git a/src/html/page/root.rs b/src/html/page/root.rs index 2244ed7..08b0946 100644 --- a/src/html/page/root.rs +++ b/src/html/page/root.rs @@ -5,7 +5,7 @@ use axum::extract::State; use axum::response::Html; use axum::response::Response; use html_escaper::Escape; -use neptune_core::models::blockchain::block::block_height::BlockHeight; +use neptune_cash::models::blockchain::block::block_height::BlockHeight; use std::sync::Arc; use tarpc::context; diff --git a/src/html/page/utxo.rs b/src/html/page/utxo.rs index 6085164..78c55fa 100644 --- a/src/html/page/utxo.rs +++ b/src/html/page/utxo.rs @@ -8,7 +8,7 @@ use axum::response::Html; use axum::response::Response; use html_escaper::Escape; use html_escaper::Trusted; -use neptune_core::prelude::tasm_lib::Digest; +use neptune_cash::prelude::tasm_lib::Digest; use std::sync::Arc; use tarpc::context; diff --git a/src/model/app_state.rs b/src/model/app_state.rs index deae913..d327c4c 100644 --- a/src/model/app_state.rs +++ b/src/model/app_state.rs @@ -3,10 +3,10 @@ use crate::neptune_rpc; use anyhow::Context; use arc_swap::ArcSwap; use clap::Parser; -use neptune_core::config_models::network::Network; -use neptune_core::models::blockchain::block::block_selector::BlockSelector; -use neptune_core::prelude::twenty_first::math::digest::Digest; -use neptune_core::rpc_server::RPCClient; +use neptune_cash::config_models::network::Network; +use neptune_cash::models::blockchain::block::block_selector::BlockSelector; +use neptune_cash::prelude::twenty_first::math::digest::Digest; +use neptune_cash::rpc_server::RPCClient; use std::sync::Arc; pub struct AppStateInner { diff --git a/src/model/block_selector_extended.rs b/src/model/block_selector_extended.rs index 4f79dfe..da90971 100644 --- a/src/model/block_selector_extended.rs +++ b/src/model/block_selector_extended.rs @@ -1,6 +1,6 @@ use super::height_or_digest::HeightOrDigest; -use neptune_core::models::blockchain::block::block_selector::BlockSelector; -use neptune_core::models::blockchain::block::block_selector::BlockSelectorParseError; +use neptune_cash::models::blockchain::block::block_selector::BlockSelector; +use neptune_cash::models::blockchain::block::block_selector::BlockSelectorParseError; use serde::de::Error; use serde::Deserialize; use serde::Deserializer; diff --git a/src/model/height_or_digest.rs b/src/model/height_or_digest.rs index 92bc9d5..fbbadec 100644 --- a/src/model/height_or_digest.rs +++ b/src/model/height_or_digest.rs @@ -1,7 +1,7 @@ -use neptune_core::models::blockchain::block::block_height::BlockHeight; -use neptune_core::models::blockchain::block::block_selector::BlockSelector; -use neptune_core::models::blockchain::block::block_selector::BlockSelectorParseError; -use neptune_core::prelude::tasm_lib::Digest; +use neptune_cash::models::blockchain::block::block_height::BlockHeight; +use neptune_cash::models::blockchain::block::block_selector::BlockSelector; +use neptune_cash::models::blockchain::block::block_selector::BlockSelectorParseError; +use neptune_cash::prelude::tasm_lib::Digest; use serde::{Deserialize, Serialize}; use std::str::FromStr; diff --git a/src/neptune_rpc.rs b/src/neptune_rpc.rs index f91cec7..0c8a06d 100644 --- a/src/neptune_rpc.rs +++ b/src/neptune_rpc.rs @@ -6,7 +6,7 @@ use chrono::DateTime; use chrono::TimeDelta; use chrono::Utc; use clap::Parser; -use neptune_core::rpc_server::RPCClient; +use neptune_cash::rpc_server::RPCClient; use std::net::Ipv4Addr; use std::net::SocketAddr; use tarpc::client; diff --git a/src/rpc/block_digest.rs b/src/rpc/block_digest.rs index c114055..79f888b 100644 --- a/src/rpc/block_digest.rs +++ b/src/rpc/block_digest.rs @@ -6,7 +6,7 @@ use axum::extract::Path; use axum::extract::State; use axum::response::IntoResponse; use axum::response::Json; -use neptune_core::prelude::twenty_first::math::digest::Digest; +use neptune_cash::prelude::twenty_first::math::digest::Digest; use std::sync::Arc; use tarpc::context; diff --git a/src/rpc/block_info.rs b/src/rpc/block_info.rs index 4070e41..5b009c4 100644 --- a/src/rpc/block_info.rs +++ b/src/rpc/block_info.rs @@ -6,7 +6,7 @@ use axum::extract::Path; use axum::extract::State; use axum::response::Json; use axum::response::Response; -use neptune_core::models::blockchain::block::block_info::BlockInfo; +use neptune_cash::models::blockchain::block::block_info::BlockInfo; use std::sync::Arc; use tarpc::context; diff --git a/src/rpc/utxo_digest.rs b/src/rpc/utxo_digest.rs index 5437093..830f98c 100644 --- a/src/rpc/utxo_digest.rs +++ b/src/rpc/utxo_digest.rs @@ -2,7 +2,7 @@ use axum::extract::Path; use axum::extract::State; use axum::response::IntoResponse; use axum::response::Json; -use neptune_core::prelude::twenty_first::math::digest::Digest; +use neptune_cash::prelude::twenty_first::math::digest::Digest; use std::sync::Arc; use tarpc::context; diff --git a/templates/web/html/page/block_info.html b/templates/web/html/page/block_info.html index 35ff7b1..fe2e73a 100644 --- a/templates/web/html/page/block_info.html +++ b/templates/web/html/page/block_info.html @@ -27,6 +27,22 @@ Digest {{self.block_info.digest.to_hex()}} + + Canonical +🛈 + + The canonical blockchain is the chain with the most accumulated proof-of-work and is considered the official record of transaction history. + + + + +%% if self.block_info.is_canonical { +This block is a link in the canonical blockchain. +%% } else { +This block is not in the canonical blockchain. +%% } + + Created {{self.block_info.timestamp.standard_format()}}