Skip to content

Commit cf4f21f

Browse files
committed
Reorgs, bump version number for release
1 parent 92211bf commit cf4f21f

File tree

17 files changed

+1140
-264
lines changed

17 files changed

+1140
-264
lines changed

Cargo.lock

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ authors = [
1313
"Nikita Chashchinskii <nikita.chashchinskii@gmail.com>"
1414
]
1515
edition = "2021"
16-
version = "0.7.0"
16+
version = "0.8.0"
1717

1818
[workspace.dependencies.bip300301]
1919
git = "https://github.com/Ash-L2L/bip300301.git"
20-
rev = "43ba4d7bee075ecd2504f87b5ec2a5ba3b10cd3b"
20+
rev = "d1da609b4c77d2b53bea2c8e922891b83612a03b"
2121

2222

2323
[profile.release]

app/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ thunder_app_cli = { path = "../cli" }
3434
thunder_app_rpc_api = { path = "../rpc-api" }
3535
tiny-bip39 = "1.0.0"
3636
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
37+
tokio-util = { version = "0.7.10", features = ["rt"] }
3738
tracing = "0.1.40"
3839
tracing-subscriber = "0.3.18"
3940

app/app.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use thunder::{
1111
wallet::{self, Wallet},
1212
};
1313
use tokio::sync::RwLock as TokioRwLock;
14+
use tokio_util::task::LocalPoolHandle;
1415

1516
use crate::cli::Config;
1617

@@ -40,6 +41,7 @@ pub struct App {
4041
pub utxos: Arc<RwLock<HashMap<OutPoint, Output>>>,
4142
pub transaction: Arc<RwLock<Transaction>>,
4243
pub runtime: Arc<tokio::runtime::Runtime>,
44+
pub local_pool: LocalPoolHandle,
4345
}
4446

4547
impl App {
@@ -61,12 +63,14 @@ impl App {
6163
&config.main_password,
6264
)?;
6365
let rt_guard = runtime.enter();
66+
let local_pool = LocalPoolHandle::new(1);
6467
let node = Node::new(
6568
&config.datadir,
6669
config.net_addr,
6770
config.main_addr,
6871
&config.main_user,
6972
&config.main_password,
73+
local_pool.clone(),
7074
)?;
7175
drop(rt_guard);
7276
let utxos = {
@@ -90,6 +94,7 @@ impl App {
9094
outputs: vec![],
9195
})),
9296
runtime: Arc::new(runtime),
97+
local_pool,
9398
})
9499
}
95100

app/gui/block_explorer.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use eframe::egui;
22
use human_size::{Byte, Kibibyte, Mebibyte, SpecificSize};
3-
use thunder::{bip300301::bitcoin, state::State, types::GetValue};
3+
use thunder::{
4+
bip300301::bitcoin,
5+
state::State,
6+
types::{Body, GetValue, Header},
7+
};
48

59
use crate::app::App;
610

@@ -15,8 +19,17 @@ impl BlockExplorer {
1519

1620
pub fn show(&mut self, app: &mut App, ui: &mut egui::Ui) {
1721
let max_height = app.node.get_height().unwrap_or(0);
18-
let header = app.node.get_header(self.height).ok().flatten();
19-
let body = app.node.get_body(self.height).ok().flatten();
22+
let block: Option<(Header, Body)> = {
23+
if let Ok(Some(block_hash)) =
24+
app.node.try_get_block_hash(self.height)
25+
&& let Ok(header) = app.node.get_header(block_hash)
26+
&& let Ok(body) = app.node.get_body(block_hash)
27+
{
28+
Some((header, body))
29+
} else {
30+
None
31+
}
32+
};
2033
egui::CentralPanel::default().show_inside(ui, |ui| {
2134
ui.heading("Block");
2235
ui.horizontal(|ui| {
@@ -31,7 +44,7 @@ impl BlockExplorer {
3144
self.height = max_height;
3245
}
3346
});
34-
if let (Some(header), Some(body)) = (header, body) {
47+
if let Some((header, body)) = block {
3548
let hash = &format!("{}", header.hash());
3649
let merkle_root = &format!("{}", header.merkle_root);
3750
let prev_side_hash = &format!("{}", header.prev_side_hash);

app/gui/miner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ impl Miner {
3535
.clicked()
3636
{
3737
self.running.store(true, atomic::Ordering::SeqCst);
38-
app.runtime.spawn({
38+
app.local_pool.spawn_pinned({
3939
let app = app.clone();
4040
let running = self.running.clone();
41-
async move {
41+
|| async move {
4242
tracing::debug!("Mining...");
4343
let mining_result = app.mine(None).await;
4444
running.store(false, atomic::Ordering::SeqCst);

app/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(let_chains)]
2+
13
use std::sync::mpsc;
24

35
use clap::Parser as _;

app/rpc_server.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ impl RpcServer for RpcServerImpl {
8787

8888
async fn mine(&self, fee: Option<u64>) -> RpcResult<()> {
8989
let fee = fee.map(bip300301::bitcoin::Amount::from_sat);
90-
self.app.mine(fee).await.map_err(convert_app_err)
90+
self.app.local_pool.spawn_pinned({
91+
let app = self.app.clone();
92+
move || async move { app.mine(fee).await.map_err(convert_app_err) }
93+
}).await.unwrap()
9194
}
9295

9396
async fn remove_from_mempool(&self, txid: Txid) -> RpcResult<()> {

lib/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ byteorder = "1.4.3"
1515
bytes = "1.4.0"
1616
ed25519-dalek = { version = "2.1.1", features = ["batch", "serde"] }
1717
ed25519-dalek-bip32 = "0.3.0"
18+
fallible-iterator = "0.3.0"
1819
futures = "0.3.30"
1920
heed = { git = "https://github.com/meilisearch/heed", tag = "v0.12.4", version = "0.12.4" }
2021
hex = { version = "0.4.3", features = ["serde"] }
@@ -31,6 +32,7 @@ thiserror = "1.0.44"
3132
tiny-bip39 = "1.0.0"
3233
tokio = { version = "1.29.1", features = ["sync"] }
3334
tokio-stream = "0.1.15"
35+
tokio-util = { version = "0.7.10", features = ["rt"] }
3436
tracing = "0.1.40"
3537

3638
[lib]

0 commit comments

Comments
 (0)