Skip to content

Commit 59b0e46

Browse files
chore: update to upgrade dash core with x11 as a feature (#46)
1 parent bd6efdb commit 59b0e46

File tree

4 files changed

+185
-164
lines changed

4 files changed

+185
-164
lines changed

client/src/client.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ use dashcore::{
2828
Address, Amount, Block, OutPoint, PrivateKey, ProTxHash, PublicKey, QuorumHash, Transaction,
2929
};
3030
use dashcore_private::hex::display::DisplayHex;
31-
use hex::ToHex;
31+
use dashcore_rpc_json::dashcore::bls_sig_utils::BLSSignature;
3232
use dashcore_rpc_json::dashcore::{BlockHash, ChainLock};
3333
use dashcore_rpc_json::{ProTxInfo, ProTxListType, QuorumType};
34+
use hex::ToHex;
3435
use log::Level::{Debug, Trace, Warn};
35-
use dashcore_rpc_json::dashcore::bls_sig_utils::BLSSignature;
3636

3737
use crate::error::*;
38-
use crate::Error::UnexpectedStructure;
3938
use crate::json;
4039
use crate::queryable;
40+
use crate::Error::UnexpectedStructure;
4141

4242
/// Crate-specific Result type, shorthand for `std::result::Result` with our
4343
/// crate-specific Error type;
@@ -393,11 +393,17 @@ pub trait RpcApi: Sized {
393393

394394
/// Returns information about the best chainlock.
395395
fn get_best_chain_lock(&self) -> Result<ChainLock> {
396-
let json::GetBestChainLockResult { blockhash, height, signature, known_block: _ } = self.call("getbestchainlock", &[])?;
396+
let json::GetBestChainLockResult {
397+
blockhash,
398+
height,
399+
signature,
400+
known_block: _,
401+
} = self.call("getbestchainlock", &[])?;
397402

398403
Ok(ChainLock {
399404
block_height: height,
400-
signature: BLSSignature::try_from(signature.as_slice()).map_err(|e| UnexpectedStructure(e.to_string()))?,
405+
signature: BLSSignature::try_from(signature.as_slice())
406+
.map_err(|e| UnexpectedStructure(e.to_string()))?,
401407
block_hash: blockhash,
402408
})
403409
}
@@ -421,7 +427,11 @@ pub trait RpcApi: Sized {
421427

422428
fn get_raw_change_address(&self) -> Result<Address<NetworkUnchecked>> {
423429
let data: String = self.call("getrawchangeaddress", &[])?;
424-
let address = Address::from_str(&data).map_err(|_e| Error::UnexpectedStructure("change address given by core was not an address".to_string()))?;
430+
let address = Address::from_str(&data).map_err(|_e| {
431+
Error::UnexpectedStructure(
432+
"change address given by core was not an address".to_string(),
433+
)
434+
})?;
425435

426436
Ok(address)
427437
}
@@ -442,7 +452,10 @@ pub trait RpcApi: Sized {
442452
transactions_by_block_hash: BTreeMap<&BlockHash, Vec<&dashcore::Txid>>,
443453
) -> Result<BTreeMap<dashcore::Txid, Transaction>> {
444454
let mut args = [into_json(transactions_by_block_hash)?, into_json(false)?];
445-
let list = self.call::<Vec<(dashcore::Txid, Transaction)>>("getrawtransactionmulti", handle_defaults(&mut args, &[null()]))?;
455+
let list = self.call::<Vec<(dashcore::Txid, Transaction)>>(
456+
"getrawtransactionmulti",
457+
handle_defaults(&mut args, &[null()]),
458+
)?;
446459
Ok(list.into_iter().collect())
447460
}
448461

@@ -512,7 +525,7 @@ pub trait RpcApi: Sized {
512525
.into_iter()
513526
.map(|index| Ok(into_json(index.to_string())?))
514527
.collect::<Result<Vec<Value>>>()?;
515-
let args = [indices_json.into(), opt_into_json(height)?];
528+
let args = [indices_json.into(), opt_into_json(height)?];
516529
self.call("getassetunlockstatuses", &args)
517530
}
518531

@@ -1565,12 +1578,12 @@ pub trait RpcApi: Sized {
15651578
/// If the returned height is less than the given chain lock height this means that the chain lock was accepted but we did not yet have the block
15661579
/// If the returned height is equal to the chain lock height given this means that we are at the height of the chain lock
15671580
/// If the returned height is higher that the given chain lock this means that we ignored the chain lock because core had something better.
1568-
fn submit_chain_lock(
1569-
&self,
1570-
chain_lock: &ChainLock,
1571-
) -> Result<u32> {
1572-
let mut args =
1573-
[into_json(hex::encode(chain_lock.block_hash))?, into_json(hex::encode(chain_lock.signature.as_bytes()))?, into_json(chain_lock.block_height)?];
1581+
fn submit_chain_lock(&self, chain_lock: &ChainLock) -> Result<u32> {
1582+
let mut args = [
1583+
into_json(hex::encode(chain_lock.block_hash))?,
1584+
into_json(hex::encode(chain_lock.signature.as_bytes()))?,
1585+
into_json(chain_lock.block_height)?,
1586+
];
15741587
self.call::<u32>("submitchainlock", handle_defaults(&mut args, &[null()]))
15751588
}
15761589

client/src/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ impl fmt::Display for Error {
8787
Error::Io(ref e) => write!(f, "I/O error: {}", e),
8888
Error::InvalidAmount(ref e) => write!(f, "invalid amount: {}", e),
8989
Error::InvalidCookieFile => write!(f, "invalid cookie file"),
90-
Error::UnexpectedStructure(ref e) => write!(f, "the JSON result had an unexpected structure: {}", e),
90+
Error::UnexpectedStructure(ref e) => {
91+
write!(f, "the JSON result had an unexpected structure: {}", e)
92+
}
9193
}
9294
}
9395
}

0 commit comments

Comments
 (0)