diff options
author | Antoine A <> | 2023-10-04 23:21:40 +0200 |
---|---|---|
committer | Antoine A <> | 2023-10-04 23:21:40 +0200 |
commit | b898b96922ac80325d6371c0aafa3ee55c2c21b2 (patch) | |
tree | 39f131fe041cd933cc964b3b73b26346c578c1d5 /btc-wire | |
parent | b64461c9e5133f63b9edbfb9bb2fc07017a2b735 (diff) | |
download | depolymerization-b898b96922ac80325d6371c0aafa3ee55c2c21b2.tar.gz depolymerization-b898b96922ac80325d6371c0aafa3ee55c2c21b2.tar.bz2 depolymerization-b898b96922ac80325d6371c0aafa3ee55c2c21b2.zip |
Improve test runner and improve initdb commands
Diffstat (limited to 'btc-wire')
-rw-r--r-- | btc-wire/src/main.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/btc-wire/src/main.rs b/btc-wire/src/main.rs index 0d35f5a..edb82e5 100644 --- a/btc-wire/src/main.rs +++ b/btc-wire/src/main.rs @@ -78,21 +78,23 @@ fn init(config: Option<PathBuf>, init: Init) -> LoopResult<()> { let mut rpc = Rpc::common(&btc_conf).or_fail(|e| format!("rpc connect: {}", e));
match init {
Init::Initdb => {
+ let mut tx = db.transaction()?;
// Load schema
- db.batch_execute(include_str!("../../db/btc.sql"))?;
+ tx.batch_execute(include_str!("../../db/btc.sql"))?;
// Init status to true
- db
+ tx
.execute(
"INSERT INTO state (name, value) VALUES ('status', $1) ON CONFLICT (name) DO NOTHING",
&[&[1u8].as_slice()],
)?;
// Init last_hash if not already set
let genesis_hash = rpc.get_genesis()?;
- db
+ tx
.execute(
"INSERT INTO state (name, value) VALUES ('last_hash', $1) ON CONFLICT (name) DO NOTHING",
&[&genesis_hash.as_byte_array().as_slice()],
)?;
+ tx.commit()?;
println!("Database initialised");
}
Init::Initwallet => {
|