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::<x>" statements to
'use neptune_cash::<x>'
This commit is contained in:
danda 2024-12-18 12:15:38 +08:00
parent 0bc81d2382
commit ebcfdb947c
13 changed files with 39 additions and 23 deletions

8
Cargo.lock generated
View File

@ -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",

View File

@ -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",

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -27,6 +27,22 @@
<td>Digest</td>
<td class="mono">{{self.block_info.digest.to_hex()}}</td>
</tr>
<tr>
<td>Canonical
<span class="tooltip">🛈
<span class="tooltiptext">
The canonical blockchain is the chain with the most accumulated proof-of-work and is considered the official record of transaction history.
</span>
</span>
</td>
<td>
%% if self.block_info.is_canonical {
This block is a link in the canonical blockchain.
%% } else {
This block is not in the canonical blockchain.
%% }
</td>
</tr>
<tr>
<td>Created</td>
<td>{{self.block_info.timestamp.standard_format()}}</td>