From 6525fcb67ceee2ec5147834d353d997bc12464d9 Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Fri, 24 May 2024 18:43:54 +0300 Subject: [PATCH 1/5] Bump version --- Cargo.lock | 2 +- Cargo.toml | 2 +- templates/base.html.tera | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 911b7e4..5cc456a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -736,7 +736,7 @@ dependencies = [ [[package]] name = "grin-explorer" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 164b703..8d3ddc1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "grin-explorer" -version = "0.1.3" +version = "0.1.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/templates/base.html.tera b/templates/base.html.tera index c9d1e2a..352d862 100644 --- a/templates/base.html.tera +++ b/templates/base.html.tera @@ -212,7 +212,7 @@
From 7b360d8a10db848e2c212ce1fae44ac1ed85d3f0 Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Fri, 24 May 2024 18:51:07 +0300 Subject: [PATCH 2/5] Kernel api for Coinbase has no fee field, so remove it --- src/requests.rs | 5 ++--- templates/kernel.html.tera | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/requests.rs b/src/requests.rs index 0fc6020..00a0864 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -411,8 +411,8 @@ pub async fn get_kernel(excess: &str, kernel: &mut Kernel) let resp = call("get_kernel", params, "1", "foreign").await?; if resp["result"]["Ok"].is_null() == false { - kernel.height = resp["result"]["Ok"]["height"].to_string(); - kernel.excess = resp["result"]["Ok"]["tx_kernel"]["excess"].as_str().unwrap().to_string(); + kernel.height = resp["result"]["Ok"]["height"].to_string(); + kernel.excess = resp["result"]["Ok"]["tx_kernel"]["excess"].as_str().unwrap().to_string(); if resp["result"]["Ok"]["tx_kernel"]["features"]["Plain"].is_null() == false { kernel.ker_type = "Plain".to_string(); kernel.fee = format!("ツ {}", @@ -420,7 +420,6 @@ pub async fn get_kernel(excess: &str, kernel: &mut Kernel) .to_string().parse::
+
+
+
+
+
+
+
+
+
+ Supported search inputs:
+ block number
+ block hash
+ kernel
+
+
+
+
+
+
+
+{% endblock %}
+
From 2995b4f1433a29d626724b25e5b4047aba3e95f9 Mon Sep 17 00:00:00 2001
From: aglkm <39521015+aglkm@users.noreply.github.com>
Date: Sat, 25 May 2024 14:06:41 +0300
Subject: [PATCH 4/5] remove debug prints
---
src/main.rs | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index ffd3105..97ce2e4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -220,8 +220,6 @@ async fn api_foreign(data: &str) -> String {
_ => return "{\"error\":\"bad syntax\"}".to_string(),
};
- println!("{}", method);
- println!("{}", data);
let resp = requests::call(method, v["params"].to_string().as_str(), v["id"].to_string().as_str(), "foreign").await;
let result = match resp {
From f315d31b58683269dcd43d098c692941ad4b5b07 Mon Sep 17 00:00:00 2001
From: aglkm <39521015+aglkm@users.noreply.github.com>
Date: Sat, 25 May 2024 16:17:40 +0300
Subject: [PATCH 5/5] Adding ability to check for unconfirmed kernels
---
src/data.rs | 2 ++
src/main.rs | 2 +-
src/requests.rs | 26 +++++++++++++++++++++++---
templates/kernel.html.tera | 26 +++++++++++++++++---------
4 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/src/data.rs b/src/data.rs
index d529320..bae2440 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -118,6 +118,7 @@ pub struct Kernel {
pub excess: String,
pub ker_type: String,
pub fee: String,
+ pub status: String,
pub raw_data: String,
}
@@ -128,6 +129,7 @@ impl Kernel {
excess: String::new(),
ker_type: String::new(),
fee: String::new(),
+ status: String::new(),
raw_data: String::new(),
}
}
diff --git a/src/main.rs b/src/main.rs
index 97ce2e4..5e74b06 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -126,7 +126,7 @@ async fn kernel(excess: &str) -> Template {
let _ = requests::get_kernel(&excess, &mut kernel).await;
- if kernel.height.is_empty() == false {
+ if kernel.excess.is_empty() == false {
return Template::render("kernel", context! {
route: "kernel",
kernel,
diff --git a/src/requests.rs b/src/requests.rs
index 00a0864..b6f62dd 100644
--- a/src/requests.rs
+++ b/src/requests.rs
@@ -404,11 +404,31 @@ pub async fn get_block_header(hash: &str, height: &mut String)
// Get kernel.
-pub async fn get_kernel(excess: &str, kernel: &mut Kernel)
- -> Result<(), anyhow::Error> {
+pub async fn get_kernel(excess: &str, kernel: &mut Kernel) -> Result<(), anyhow::Error> {
+ // First check whether kernel is broadcasted but not confirmed yet (in mempool)
+ let mut resp = call("get_unconfirmed_transactions", "[]", "1", "foreign").await?;
+
+ if resp["result"]["Ok"].is_null() == false {
+ for tx in resp["result"]["Ok"].as_array().unwrap() {
+ for ker in tx["tx"]["body"]["kernels"].as_array().unwrap() {
+ if ker["excess"].as_str().unwrap() == excess {
+ // Only Plain kernels in the mempool
+ kernel.ker_type = "Plain".to_string();
+ kernel.excess = ker["excess"].as_str().unwrap().to_string();
+ kernel.status = "Unconfirmed".to_string();
+ kernel.fee = format!("ツ {}",
+ ker["features"]["Plain"]["fee"]
+ .to_string().parse::