Skip to content

Commit 01e6f2c

Browse files
committed
chore: fix warnings
1 parent c93623b commit 01e6f2c

File tree

9 files changed

+54
-79
lines changed

9 files changed

+54
-79
lines changed

src/frontend/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{env, process};
66

77
use crate::poke::load_session;
88
use crate::integrate::{self, DevnetOrchestrator};
9-
use crate::publish::{self, Network, publish_contracts};
9+
use crate::publish::{Network, publish_contracts};
1010
use crate::test::run_tests;
1111
use crate::types::{MainConfig, MainConfigFile, RequirementConfig};
1212
use crate::{
@@ -329,7 +329,7 @@ pub fn main() {
329329
println!(
330330
"Start orchestrating stacks-node, stacks-blockchain-api, bitcoind, bitcoin explorer, stacks-explorer"
331331
);
332-
let mut devnet = DevnetOrchestrator::new(manifest_path);
332+
let devnet = DevnetOrchestrator::new(manifest_path);
333333
integrate::run_devnet(devnet);
334334
}
335335
};

src/integrate/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ pub async fn do_run_devnet(
3636

3737
devnet.termination_success_tx = Some(termination_success_tx);
3838

39-
let devnet_config = match devnet.network_config {
39+
let (devnet_config, accounts) = match devnet.network_config {
4040
Some(ref network_config) => match &network_config.devnet {
41-
Some(devnet_config) => Ok(devnet_config.clone()),
41+
Some(devnet_config) => Ok((devnet_config.clone(), network_config.accounts.clone())),
4242
_ => Err("Unable to retrieve config")
4343
}
4444
_ => Err("Unable to retrieve config")
@@ -48,6 +48,7 @@ pub async fn do_run_devnet(
4848
// and should be able to be terminated
4949
let config = EventObserverConfig {
5050
devnet_config,
51+
accounts,
5152
manifest_path: devnet.manifest_path.clone(),
5253
pox_info: PoxInfo::default(),
5354
};
@@ -56,7 +57,7 @@ pub async fn do_run_devnet(
5657
let events_observer_handle = std::thread::spawn(move || {
5758
let future = start_events_observer(config, events_observer_tx, terminator_rx);
5859
let rt = utils::create_basic_runtime();
59-
rt.block_on(future);
60+
let _ = rt.block_on(future);
6061
});
6162

6263
// The devnet orchestrator should be able to send some events to the UI thread,
@@ -69,7 +70,7 @@ pub async fn do_run_devnet(
6970
rt.block_on(future);
7071
});
7172

72-
ui::start_ui(
73+
let _ = ui::start_ui(
7374
devnet_events_tx,
7475
devnet_events_rx,
7576
events_observer_terminator_tx,
@@ -86,12 +87,12 @@ pub enum DevnetEvent {
8687
Log(LogData),
8788
KeyEvent(crossterm::event::KeyEvent),
8889
Tick,
89-
Restart,
90-
Terminate,
9190
ServiceStatus(ServiceStatusData),
9291
Block(BlockData),
93-
Microblock(MicroblockData),
9492
MempoolAdmission(MempoolAdmissionData),
93+
// Restart,
94+
// Terminate,
95+
// Microblock(MicroblockData),
9596
}
9697

9798
impl DevnetEvent {
@@ -100,6 +101,7 @@ impl DevnetEvent {
100101
DevnetEvent::Log(Self::log_error(message))
101102
}
102103

104+
#[allow(dead_code)]
103105
pub fn warning(message: String) -> DevnetEvent {
104106
DevnetEvent::Log(Self::log_warning(message))
105107
}
@@ -183,10 +185,6 @@ pub struct Transaction {
183185
pub events: Vec<String>,
184186
}
185187

186-
pub struct Event {
187-
pub content: String,
188-
}
189-
190188
#[derive(Clone)]
191189
pub struct BlockData {
192190
pub block_height: u32,
@@ -199,10 +197,10 @@ pub struct BlockData {
199197
pub transactions: Vec<Transaction>
200198
}
201199

202-
pub struct MicroblockData {
203-
pub seq: u32,
204-
pub transactions: Vec<Transaction>
205-
}
200+
// pub struct MicroblockData {
201+
// pub seq: u32,
202+
// pub transactions: Vec<Transaction>
203+
// }
206204

207205
pub struct MempoolAdmissionData {
208206
pub txid: String,

src/integrate/orchestrator.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use crate::integrate::{ServiceStatusData, Status};
22
use crate::types::{ChainConfig, MainConfig};
33
use deno_core::futures::TryStreamExt;
4-
use reqwest::StatusCode;
54
use super::DevnetEvent;
65
use std::collections::HashMap;
76
use std::fs::{File, self};
87
use std::io::Write;
98
use std::path::PathBuf;
109
use std::sync::mpsc::{Receiver, Sender};
1110
use bollard::Docker;
12-
use bollard::container::{Config, KillContainerOptions, CreateContainerOptions, StartContainerOptions, LogsOptions};
11+
use bollard::container::{Config, KillContainerOptions, CreateContainerOptions};
1312
use bollard::models::{HostConfig, PortBinding};
1413
use bollard::network::{ConnectNetworkOptions, CreateNetworkOptions, PruneNetworksOptions};
1514
use bollard::image::CreateImageOptions;
@@ -65,7 +64,7 @@ impl DevnetOrchestrator {
6564
}
6665
_ => return
6766
};
68-
event_tx.send(DevnetEvent::info(format!("Initiating Devnet boot sequence (working_dir: {})", devnet_config.working_dir)));
67+
let _ = event_tx.send(DevnetEvent::info(format!("Initiating Devnet boot sequence (working_dir: {})", devnet_config.working_dir)));
6968

7069
fs::create_dir(format!("{}", devnet_config.working_dir)).expect("Unable to create working dir");
7170
fs::create_dir(format!("{}/conf", devnet_config.working_dir)).expect("Unable to create working dir");
@@ -104,15 +103,15 @@ impl DevnetOrchestrator {
104103
comment: "initializing".into(),
105104
}));
106105

107-
event_tx.send(DevnetEvent::info(format!("Creating network {}", self.network_name)));
106+
let _ = event_tx.send(DevnetEvent::info(format!("Creating network {}", self.network_name)));
108107
let _network = docker.create_network(CreateNetworkOptions {
109108
name: self.network_name.clone(),
110109
driver: "bridge".to_string(),
111110
..Default::default()
112111
}).await.expect("Unable to create network");
113112

114113
// Start bitcoind
115-
event_tx.send(DevnetEvent::info(format!("Starting bitcoind")));
114+
let _ = event_tx.send(DevnetEvent::info(format!("Starting bitcoind")));
116115
let _ = event_tx.send(DevnetEvent::ServiceStatus(ServiceStatusData {
117116
order: 0,
118117
status: Status::Yellow,
@@ -141,7 +140,7 @@ impl DevnetOrchestrator {
141140
name: "stacks-api".into(),
142141
comment: "preparing postgres container".into(),
143142
}));
144-
event_tx.send(DevnetEvent::info(format!("Starting postgres")));
143+
let _ = event_tx.send(DevnetEvent::info(format!("Starting postgres")));
145144
match self.boot_postgres_container().await {
146145
Ok(_) => {},
147146
Err(message) => {
@@ -158,7 +157,7 @@ impl DevnetOrchestrator {
158157
name: "stacks-api".into(),
159158
comment: "preparing container".into(),
160159
}));
161-
event_tx.send(DevnetEvent::info(format!("Starting stacks-api")));
160+
let _ = event_tx.send(DevnetEvent::info(format!("Starting stacks-api")));
162161
match self.boot_stacks_blockchain_api_container().await {
163162
Ok(_) => {},
164163
Err(message) => {
@@ -175,7 +174,7 @@ impl DevnetOrchestrator {
175174
}));
176175

177176
// Start stacks-blockchain
178-
event_tx.send(DevnetEvent::info(format!("Starting stacks-node")));
177+
let _ = event_tx.send(DevnetEvent::info(format!("Starting stacks-node")));
179178
let _ = event_tx.send(DevnetEvent::ServiceStatus(ServiceStatusData {
180179
order: 1,
181180
status: Status::Yellow,
@@ -204,7 +203,7 @@ impl DevnetOrchestrator {
204203
name: "stacks-explorer".into(),
205204
comment: "preparing container".into(),
206205
}));
207-
event_tx.send(DevnetEvent::info(format!("Starting stacks-explorer")));
206+
let _ = event_tx.send(DevnetEvent::info(format!("Starting stacks-explorer")));
208207
match self.boot_stacks_explorer_container().await {
209208
Ok(_) => {},
210209
Err(message) => {
@@ -225,7 +224,7 @@ impl DevnetOrchestrator {
225224
self.terminate().await;
226225
},
227226
Ok(false) => {
228-
self.restart();
227+
self.restart().await;
229228
}
230229
_ => {}
231230
}
@@ -892,13 +891,14 @@ events_keys = ["*"]
892891
println!("Pruning network {}", self.network_name);
893892
let mut filters = HashMap::new();
894893
filters.insert("label".to_string(), vec![format!("label={}", self.network_name)]);
895-
docker.prune_networks(Some(PruneNetworksOptions { filters })).await;
894+
let _ = docker.prune_networks(Some(PruneNetworksOptions { filters })).await;
896895

897896
let _ = docker.remove_network(&self.network_name).await;
898897

899898
println!("Ended termination sequence");
900899
if let Some(ref tx) = self.termination_success_tx {
901900
tx.send(true).expect("Unable to confirm termination");
902901
}
902+
std::process::exit(0);
903903
}
904904
}

src/integrate/ui/app.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct App<'a> {
1616
}
1717

1818
impl<'a> App<'a> {
19-
pub fn new(title: &'a str, enhanced_graphics: bool) -> App<'a> {
19+
pub fn new(title: &'a str) -> App<'a> {
2020
App {
2121
title,
2222
should_quit: false,
@@ -77,7 +77,7 @@ impl<'a> App<'a> {
7777

7878
pub fn display_block(&mut self, block: BlockData) {
7979
let cycle_len = block.pox_cycle_length;
80-
let abs_pos = (block.bitcoin_block_height - block.first_burnchain_block_height);
80+
let abs_pos = block.bitcoin_block_height - block.first_burnchain_block_height;
8181
let (start, end) = if abs_pos % cycle_len == (cycle_len - 1) {
8282
("", "<")
8383
} else if abs_pos % cycle_len == 0 {
@@ -92,7 +92,11 @@ impl<'a> App<'a> {
9292
};
9393
self.tabs.titles.push_front(Spans::from(
9494
Span::styled(format!("{}[{}{}]{}", end, block.block_height, has_tx, start),
95-
Style::default().fg(Color::LightMagenta))
95+
if block.pox_cycle_id % 2 == 1 {
96+
Style::default().fg(Color::Yellow)
97+
} else {
98+
Style::default().fg(Color::LightYellow)
99+
})
96100
));
97101
self.blocks.push(block);
98102
if self.tabs.index != 0 {

src/integrate/ui/mod.rs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
// Mockup
2-
// Section 1 (10 lines)
3-
// | Devnet orchestration (75%) | Endpoints (25%) |
4-
// | Gauge (boot, yellow or green) | Table (Name | Address | Status) |
5-
// | Logs | |
6-
// Section 2 (5 lines)
7-
// | Blocks Tab + PoX Tab (100%) |
8-
// Section 3 (Else)
9-
// | Details about block, Transactions, Asset map.
10-
// Section 4
11-
// | Mempool state
12-
131
#[allow(dead_code)]
142
mod app;
153
#[allow(dead_code)]
@@ -31,7 +19,7 @@ use std::{
3119
time::{Duration, Instant},
3220
};
3321
use tui::{backend::CrosstermBackend, Terminal};
34-
use super::{DevnetEvent, LogData, LogLevel};
22+
use super::{DevnetEvent};
3523

3624
pub fn start_ui(devnet_events_tx: Sender<DevnetEvent>, devnet_events_rx: Receiver<DevnetEvent>, events_observer_terminator_tx: Sender<bool>, orchestrator_terminator_tx: Sender<bool>, orchestrator_terminated_rx: Receiver<bool>) -> Result<(), Box<dyn Error>> {
3725

@@ -45,7 +33,6 @@ pub fn start_ui(devnet_events_tx: Sender<DevnetEvent>, devnet_events_rx: Receive
4533
let mut terminal = Terminal::new(backend)?;
4634

4735
// Setup input handling
48-
let enhanced_graphics = false;
4936
let tick_rate = Duration::from_millis(500);
5037
thread::spawn(move || {
5138
let mut last_tick = Instant::now();
@@ -60,13 +47,15 @@ pub fn start_ui(devnet_events_tx: Sender<DevnetEvent>, devnet_events_rx: Receive
6047
}
6148
}
6249
if last_tick.elapsed() >= tick_rate {
63-
devnet_events_tx.send(DevnetEvent::Tick).unwrap();
50+
if let Err(_) = devnet_events_tx.send(DevnetEvent::Tick) {
51+
break;
52+
}
6453
last_tick = Instant::now();
6554
}
6655
}
6756
});
6857

69-
let mut app = App::new("Clarinet", enhanced_graphics);
58+
let mut app = App::new("Clarinet");
7059
terminal.clear()?;
7160

7261
loop {
@@ -76,7 +65,7 @@ pub fn start_ui(devnet_events_tx: Sender<DevnetEvent>, devnet_events_rx: Receive
7665
DevnetEvent::KeyEvent(event) => match (event.modifiers, event.code) {
7766
(KeyModifiers::CONTROL, KeyCode::Char('c')) => {
7867
app.display_log(DevnetEvent::log_warning("Ctrl+C received, initiating termination sequence.".into()));
79-
terminate(
68+
let _ = terminate(
8069
&mut terminal,
8170
true,
8271
events_observer_terminator_tx,
@@ -98,25 +87,25 @@ pub fn start_ui(devnet_events_tx: Sender<DevnetEvent>, devnet_events_rx: Receive
9887
},
9988
DevnetEvent::Log(log) => {
10089
app.display_log(log);
101-
},
102-
DevnetEvent::Terminate => {
103-
104-
},
105-
DevnetEvent::Restart => {
106-
10790
},
10891
DevnetEvent::ServiceStatus(status) => {
10992
app.display_service_status_update(status);
11093
}
11194
DevnetEvent::Block(block) => {
11295
app.display_block(block);
113-
}
114-
DevnetEvent::Microblock(microblock) => {
115-
11696
}
11797
DevnetEvent::MempoolAdmission(tx) => {
11898
app.update_mempool(tx);
11999
}
100+
// DevnetEvent::Microblock(microblock) => {
101+
102+
// }
103+
// DevnetEvent::Terminate => {
104+
105+
// },
106+
// DevnetEvent::Restart => {
107+
108+
// },
120109
}
121110
if app.should_quit {
122111
break;

src/integrate/ui/ui.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ where
174174
draw_transactions(f, app, block_details_components[1], &selected_block);
175175
}
176176

177-
fn draw_block_details<B>(f: &mut Frame<B>, app: &mut App, area: Rect, block: &BlockData)
177+
fn draw_block_details<B>(f: &mut Frame<B>, _app: &mut App, area: Rect, block: &BlockData)
178178
where
179179
B: Backend,
180180
{
@@ -264,19 +264,10 @@ where
264264
// TODO(ludo): Mining informations (miner, VRF)
265265
}
266266

267-
fn draw_transactions<B>(f: &mut Frame<B>, app: &mut App, area: Rect, block: &BlockData)
267+
fn draw_transactions<B>(f: &mut Frame<B>, _app: &mut App, area: Rect, block: &BlockData)
268268
where
269269
B: Backend,
270270
{
271-
let normal_style = Style::default().bg(Color::DarkGray);
272-
let header_cells = ["", "Txid", "Result"]
273-
.iter()
274-
.map(|h| Cell::from(*h).style(Style::default().fg(Color::Gray)));
275-
let header = Row::new(header_cells)
276-
.style(normal_style)
277-
.height(1)
278-
.bottom_margin(0);
279-
280271
let transactions: Vec<ListItem> = block.transactions.iter().map(|t| {
281272
let tx_info = Spans::from(vec![
282273
Span::styled(
@@ -318,7 +309,7 @@ where
318309

319310
}
320311

321-
fn draw_help<B>(f: &mut Frame<B>, app: &mut App, area: Rect)
312+
fn draw_help<B>(f: &mut Frame<B>, _app: &mut App, area: Rect)
322313
where
323314
B: Backend,
324315
{

0 commit comments

Comments
 (0)