Fail if bitcoind is pruned or still in IBD

(with human-readable error message)
This commit is contained in:
Roman Zeyde 2018-08-02 16:38:47 +03:00
parent 308333f40b
commit 792dd8867a
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -91,6 +91,7 @@ pub struct BlockchainInfo {
bestblockhash: String,
size_on_disk: u64,
pruned: bool,
initialblockdownload: bool,
}
#[derive(Serialize, Deserialize, Debug)]
@ -280,7 +281,16 @@ impl Daemon {
network_info.subversion,
)
}
debug!("{:?}", daemon.getblockchaininfo()?);
let blockchain_info = daemon.getblockchaininfo()?;
debug!("{:?}", blockchain_info);
if blockchain_info.initialblockdownload == true {
bail!(ErrorKind::Connection(
"wait until bitcoin is synced (i.e. initialblockdownload = false)".to_owned()
))
}
if blockchain_info.pruned == true {
bail!("pruned node is not supported (use '-prune=0' bitcoind flag)".to_owned())
}
Ok(daemon)
}