mirror of
https://github.com/transatoshi-mw/grin-explorer.git
synced 2025-10-22 05:43:42 +00:00
Adding ability to check for unconfirmed kernels
This commit is contained in:
@@ -118,6 +118,7 @@ pub struct Kernel {
|
|||||||
pub excess: String,
|
pub excess: String,
|
||||||
pub ker_type: String,
|
pub ker_type: String,
|
||||||
pub fee: String,
|
pub fee: String,
|
||||||
|
pub status: String,
|
||||||
pub raw_data: String,
|
pub raw_data: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +129,7 @@ impl Kernel {
|
|||||||
excess: String::new(),
|
excess: String::new(),
|
||||||
ker_type: String::new(),
|
ker_type: String::new(),
|
||||||
fee: String::new(),
|
fee: String::new(),
|
||||||
|
status: String::new(),
|
||||||
raw_data: String::new(),
|
raw_data: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -126,7 +126,7 @@ async fn kernel(excess: &str) -> Template {
|
|||||||
|
|
||||||
let _ = requests::get_kernel(&excess, &mut kernel).await;
|
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! {
|
return Template::render("kernel", context! {
|
||||||
route: "kernel",
|
route: "kernel",
|
||||||
kernel,
|
kernel,
|
||||||
|
@@ -404,11 +404,31 @@ pub async fn get_block_header(hash: &str, height: &mut String)
|
|||||||
|
|
||||||
|
|
||||||
// Get kernel.
|
// Get kernel.
|
||||||
pub async fn get_kernel(excess: &str, kernel: &mut Kernel)
|
pub async fn get_kernel(excess: &str, kernel: &mut Kernel) -> Result<(), anyhow::Error> {
|
||||||
-> 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::<f64>().unwrap() / 1000000000.0);
|
||||||
|
// Found it, no need to continue
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let params = &format!("[\"{}\", null, null]", excess)[..];
|
let params = &format!("[\"{}\", null, null]", excess)[..];
|
||||||
|
|
||||||
let resp = call("get_kernel", params, "1", "foreign").await?;
|
resp = call("get_kernel", params, "1", "foreign").await?;
|
||||||
|
|
||||||
if resp["result"]["Ok"].is_null() == false {
|
if resp["result"]["Ok"].is_null() == false {
|
||||||
kernel.height = resp["result"]["Ok"]["height"].to_string();
|
kernel.height = resp["result"]["Ok"]["height"].to_string();
|
||||||
|
@@ -6,12 +6,18 @@
|
|||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
<div class="darkorange-text"><i class="bi bi-card-text"></i> KERNEL</div>
|
<div class="darkorange-text"><i class="bi bi-card-text"></i> KERNEL</div>
|
||||||
|
{% if kernel.status == "Unconfirmed" %}
|
||||||
|
<span class="badge text-bg-warning px-2 py-2">UNCONFIRMED</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
<div class="value-text">Excess </div>
|
<div class="value-text">Excess </div>
|
||||||
<div class="value-text text-break text-end">{{ kernel.excess }}</div>
|
<div class="value-text text-break text-end">{{ kernel.excess }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if kernel.status != "Unconfirmed" %}
|
||||||
<br>
|
<br>
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
<div class="value-text">Block Height </div>
|
<div class="value-text">Block Height </div>
|
||||||
@@ -21,6 +27,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<br>
|
<br>
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
<div class="value-text">Type </div>
|
<div class="value-text">Type </div>
|
||||||
@@ -36,8 +43,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if kernel.status != "Unconfirmed" %}
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body" align="left">
|
<div class="card-body" align="left">
|
||||||
<div class="darkorange-text"><i class="bi bi-layout-text-sidebar-reverse"></i> RAW DATA</div>
|
<div class="darkorange-text"><i class="bi bi-layout-text-sidebar-reverse"></i> RAW DATA</div>
|
||||||
@@ -45,6 +52,7 @@
|
|||||||
<div class="value-text">{{ kernel.raw_data }}</div>
|
<div class="value-text">{{ kernel.raw_data }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user