Skip to content

Commit

Permalink
Tag: v0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
nishuzumi committed Mar 26, 2024
1 parent 8d2e337 commit 053d50a
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 4 deletions.
55 changes: 55 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ indicatif = { version = "0.17.8", features = ["improved_unicode"] }
ocl = { version = "0.19.6" }
colored = "2.1.0"
prettytable-rs = "0.10.0"
reqwest = "0.11.27"
toml = "0.8.12"
semver = "1.0.22"

[features]
default = []
op_sha256 = []
op_sha256 = []
40 changes: 37 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use bitcoin::consensus::encode;
use bitcoin::key::Secp256k1;
use bitcoin::Network;
use colored::*;
use eyre::{eyre, Result};
use ocl::{Device, Platform};
use prettytable::{Cell, Row, Table};
use tracing::{info, subscriber};
use tracing::{info, subscriber, warn};
use tracing_subscriber::fmt::format::Format;

use atomicals_electrumx::{Api, ElectrumXBuilder};
Expand All @@ -35,6 +36,7 @@ compile_error!("This program requires a 64-bit architecture.");
async fn main() {
dotenvy::dotenv().ok();

let version = env!("CARGO_PKG_VERSION");
let opts = GLOBAL_OPTS.clone();

if GLOBAL_OPTS.verbose {
Expand All @@ -56,6 +58,9 @@ async fn main() {

subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
};

let latest_version = get_latest_version().await.unwrap_or(version.to_owned());

println!(
"{}",
"
Expand All @@ -77,10 +82,22 @@ async fn main() {
Made with ❤️ by {boxchen}, @atomicalsir, @atomicals
{twitter}
Github: https://github.com/nishuzumi/collider
Miner Version: {version}, Latest Version: {latest_version}
"#
);

let v1 = semver::Version::parse(version).unwrap();
let v2 = semver::Version::parse(&latest_version).unwrap();

if v1 < v2 {
warn!("Please download the latest version, https://github.com/nishuzumi/collider/releases/latest");

if v1.major < v2.major || (v1.major == v2.major && v1.minor < v2.minor) {
std::process::exit(0);
}
}

if opts.verbose {
tracing::debug!("Verbose mode is enabled");
}
Expand All @@ -94,6 +111,20 @@ async fn main() {
}
}

async fn get_latest_version() -> Result<String> {
let url = "https://raw.githubusercontent.com/nishuzumi/collider/main/Cargo.toml";
let response = reqwest::get(url).await?;
let cargo_toml_content = response.text().await?;

let cargo_toml: toml::Value = toml::from_str(&cargo_toml_content)?;

if let Some(version) = cargo_toml["package"]["version"].as_str() {
Ok(version.to_string())
} else {
Err(eyre!("Version not found in Cargo.toml"))
}
}

fn collider_benchmark() {
info!("{}", "Benchmarking, will take a few minutes...".yellow());

Expand Down Expand Up @@ -215,10 +246,13 @@ async fn mint() {
.expect("Cannot generate payload script");

let utxo = electrumx
.wait_until_utxo(funding_wallet.to_string(),fees.commit_and_reveal_and_outputs)
.wait_until_utxo(
funding_wallet.to_string(),
fees.commit_and_reveal_and_outputs,
)
.await
.expect("wait until utxo error");

let commit_result = worker
.build_commit_tx(&worker_data, utxo)
.expect("build commit tx error");
Expand Down

0 comments on commit 053d50a

Please sign in to comment.