commit 3e4647fb219a9d98ba31c1331ca18afe837b74ea
parent dda381097b71d82d1c055c2f00bc924aa4003ce6
Author: Antoine A <>
Date: Wed, 2 Mar 2022 21:26:06 +0100
Improve initwallet
Diffstat:
2 files changed, 9 insertions(+), 24 deletions(-)
diff --git a/btc-wire/src/main.rs b/btc-wire/src/main.rs
@@ -102,20 +102,6 @@ fn init(config: Option<PathBuf>, init: Init) {
println!("Database initialised");
}
Init::Initwallet => {
- // Skip past blocks
- let info = rpc
- .get_blockchain_info()
- .expect("Failed to get blockchain info");
- let nb_row = db
- .execute(
- "INSERT INTO state (name, value) VALUES ('last_hash', $1) ON CONFLICT (name) DO NOTHING",
- &[&info.best_block_hash.as_ref()],
- )
- .expect("Failed to update database state");
- if nb_row > 0 {
- println!("Skip previous block until now");
- }
-
// Create wallet
let passwd = password();
let created = match rpc.create_wallet(WIRE_WALLET_NAME, &passwd) {
diff --git a/eth-wire/src/main.rs b/eth-wire/src/main.rs
@@ -113,16 +113,6 @@ fn init(config: Option<PathBuf>, init: Init) {
tip_height: block.number.unwrap(),
conf_height: block.number.unwrap(),
};
- let nb_row = db
- .execute(
- "INSERT INTO state (name, value) VALUES ('sync', $1) ON CONFLICT (name) DO NOTHING",
- &[&state.to_bytes().as_ref()],
- )
- .expect("Failed to update database state");
- if nb_row > 0 {
- println!("Skipped {} previous block", state.conf_height);
- }
-
let prev_addr = db
.query_opt("SELECT value FROM state WHERE name = 'addr'", &[])
.expect("Failed to query database state");
@@ -137,6 +127,15 @@ fn init(config: Option<PathBuf>, init: Init) {
&[&new.as_bytes()],
)
.expect("Failed to update database state");
+ let nb_row = db
+ .execute(
+ "UPDATE state SET value=$1 WHERE name='sync'",
+ &[&state.to_bytes().as_ref()],
+ )
+ .expect("Failed to update database state");
+ if nb_row > 0 {
+ println!("Skipped {} previous block", state.conf_height);
+ }
(new, true)
};