Skip to content

Commit 5c66df0

Browse files
committed
Clean up with cargo fmt
1 parent 432bb41 commit 5c66df0

File tree

8 files changed

+49
-36
lines changed

8 files changed

+49
-36
lines changed

node/src/bin/spaced.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use log::error;
66
use spaced::{
77
config::{safe_exit, Args},
88
rpc::{AsyncChainState, LoadedWallet, RpcServerImpl, WalletManager},
9-
source::BitcoinBlockSource,
9+
source::{BitcoinBlockSource, BitcoinRpc},
1010
store,
1111
sync::Spaced,
1212
wallets::RpcWallet,
@@ -16,7 +16,6 @@ use tokio::{
1616
sync::{broadcast, mpsc},
1717
task::{JoinHandle, JoinSet},
1818
};
19-
use spaced::source::BitcoinRpc;
2019

2120
#[tokio::main]
2221
async fn main() {

node/src/config.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ impl Args {
173173
let block_index = if args.block_index {
174174
let block_db_path = data_dir.join("block_index.sdb");
175175
if !initial_sync && !block_db_path.exists() {
176-
return Err(anyhow::anyhow!("Block index must be enabled from the initial sync."))
176+
return Err(anyhow::anyhow!(
177+
"Block index must be enabled from the initial sync."
178+
));
177179
}
178180
let block_store = Store::open(block_db_path)?;
179181
let index = LiveStore {
@@ -184,7 +186,9 @@ impl Args {
184186
let tip_1 = index.state.tip.read().expect("index");
185187
let tip_2 = chain.state.tip.read().expect("tip");
186188
if tip_1.height != tip_2.height || tip_1.hash != tip_2.hash {
187-
return Err(anyhow::anyhow!("Protocol and block index states don't match."))
189+
return Err(anyhow::anyhow!(
190+
"Protocol and block index states don't match."
191+
));
188192
}
189193
}
190194
Some(index)

node/src/node.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use protocol::{
1111
hasher::{BidKey, KeyHasher, OutpointKey, SpaceKey},
1212
prepare::TxContext,
1313
sname::NameLike,
14-
validate::{UpdateKind, TxChangeSet, Validator},
14+
validate::{TxChangeSet, UpdateKind, Validator},
1515
Covenant, FullSpaceOut, RevokeReason, SpaceOut,
1616
};
1717
use serde::{Deserialize, Serialize};
@@ -232,13 +232,19 @@ impl Node {
232232
.to_bytes(),
233233
);
234234

235-
let (bid_value, previous_bid) =
236-
unwrap_bid_value(&update.output.spaceout);
235+
let (bid_value, previous_bid) = unwrap_bid_value(&update.output.spaceout);
237236

238237
let bid_hash = BidKey::from_bid(bid_value, base_hash);
239238
let space_key = SpaceKey::from(base_hash);
240239

241-
match update.output.spaceout.space.as_ref().expect("space").covenant {
240+
match update
241+
.output
242+
.spaceout
243+
.space
244+
.as_ref()
245+
.expect("space")
246+
.covenant
247+
{
242248
Covenant::Bid { claim_height, .. } => {
243249
if claim_height.is_none() {
244250
let prev_bid_hash = BidKey::from_bid(previous_bid, base_hash);

node/src/rpc.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub trait Rpc {
100100

101101
#[method(name = "getspaceowner")]
102102
async fn get_space_owner(&self, space_hash: &str)
103-
-> Result<Option<OutPoint>, ErrorObjectOwned>;
103+
-> Result<Option<OutPoint>, ErrorObjectOwned>;
104104

105105
#[method(name = "getspaceout")]
106106
async fn get_spaceout(&self, outpoint: OutPoint) -> Result<Option<SpaceOut>, ErrorObjectOwned>;
@@ -112,10 +112,8 @@ pub trait Rpc {
112112
async fn get_rollout(&self, target: usize) -> Result<Vec<(u32, SpaceKey)>, ErrorObjectOwned>;
113113

114114
#[method(name = "getblock")]
115-
async fn get_block(
116-
&self,
117-
block_hash: BlockHash,
118-
) -> Result<Option<BlockMeta>, ErrorObjectOwned>;
115+
async fn get_block(&self, block_hash: BlockHash)
116+
-> Result<Option<BlockMeta>, ErrorObjectOwned>;
119117

120118
#[method(name = "walletload")]
121119
async fn wallet_load(&self, name: &str) -> Result<(), ErrorObjectOwned>;
@@ -156,11 +154,11 @@ pub trait Rpc {
156154

157155
#[method(name = "walletlistspaces")]
158156
async fn wallet_list_spaces(&self, wallet: &str)
159-
-> Result<Vec<FullSpaceOut>, ErrorObjectOwned>;
157+
-> Result<Vec<FullSpaceOut>, ErrorObjectOwned>;
160158

161159
#[method(name = "walletlistunspent")]
162160
async fn wallet_list_unspent(&self, wallet: &str)
163-
-> Result<Vec<LocalOutput>, ErrorObjectOwned>;
161+
-> Result<Vec<LocalOutput>, ErrorObjectOwned>;
164162

165163
#[method(name = "walletlistauctionoutputs")]
166164
async fn wallet_list_auction_outputs(
@@ -803,30 +801,35 @@ impl AsyncChainState {
803801
rpc: &BitcoinRpc,
804802
chain_state: &mut LiveSnapshot,
805803
) -> Result<Option<BlockMeta>, anyhow::Error> {
806-
let index = index.as_mut()
804+
let index = index
805+
.as_mut()
807806
.ok_or_else(|| anyhow!("block index must be enabled"))?;
808807
let hash = BaseHash::from_slice(block_hash.as_ref());
809-
let block: Option<BlockMeta> = index.get(hash)
808+
let block: Option<BlockMeta> = index
809+
.get(hash)
810810
.context("Could not fetch block from index")?;
811811

812812
if let Some(block_set) = block {
813813
return Ok(Some(block_set));
814814
}
815815

816-
let info: serde_json::Value = rpc.send_json(client, &rpc.
817-
get_block_header(block_hash)).await
816+
let info: serde_json::Value = rpc
817+
.send_json(client, &rpc.get_block_header(block_hash))
818+
.await
818819
.map_err(|e| anyhow!("Could not retrieve block ({})", e))?;
819820

820-
let height = info.get("height").and_then(|t| t.as_u64())
821+
let height = info
822+
.get("height")
823+
.and_then(|t| t.as_u64())
821824
.ok_or_else(|| anyhow!("Could not retrieve block height"))?;
822825

823826
let tip = chain_state.tip.read().expect("read meta").clone();
824827
if height > tip.height as u64 {
825828
return Err(anyhow!(
826-
"Spaces is syncing at height {}, requested block height {}",
827-
tip.height,
828-
height
829-
));
829+
"Spaces is syncing at height {}, requested block height {}",
830+
tip.height,
831+
height
832+
));
830833
}
831834
Err(anyhow!("Could not retrieve block"))
832835
}
@@ -860,9 +863,9 @@ impl AsyncChainState {
860863
let _ = resp.send(result);
861864
}
862865
ChainStateCommand::GetBlockMeta { block_hash, resp } => {
863-
let res = Self::get_indexed_block(
864-
block_index, &block_hash, client, rpc, chain_state
865-
).await;
866+
let res =
867+
Self::get_indexed_block(block_index, &block_hash, client, rpc, chain_state)
868+
.await;
866869
let _ = resp.send(res);
867870
}
868871
ChainStateCommand::EstimateBid { target, resp } => {

node/src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl BitcoinRpc {
141141
self.make_request("getblockcount", params)
142142
}
143143

144-
pub fn get_block_header(&self, hash : &BlockHash) -> BitcoinRpcRequest {
144+
pub fn get_block_header(&self, hash: &BlockHash) -> BitcoinRpcRequest {
145145
let params = serde_json::json!([hash]);
146146
self.make_request("getblockheader", params)
147147
}

protocol/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ pub enum Covenant {
115115
#[derive(Copy, Clone, PartialEq, Debug)]
116116
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
117117
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
118-
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case", tag = "revoke_reason"))]
118+
#[cfg_attr(
119+
feature = "serde",
120+
serde(rename_all = "snake_case", tag = "revoke_reason")
121+
)]
119122
pub enum RevokeReason {
120123
BidPsbt(BidPsbtReason),
121124
/// Space was prematurely spent during the auctions phase
@@ -142,7 +145,7 @@ pub enum RejectReason {
142145
#[cfg_attr(
143146
feature = "serde",
144147
derive(Serialize, Deserialize),
145-
serde(rename_all = "snake_case", tag = "bid_psbt_reason"),
148+
serde(rename_all = "snake_case", tag = "bid_psbt_reason")
146149
)]
147150
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
148151
pub enum BidPsbtReason {

protocol/src/prepare.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ pub struct AuctionedOutput {
4747
}
4848

4949
pub trait DataSource {
50-
fn get_space_outpoint(
51-
&mut self,
52-
space_hash: &SpaceKey,
53-
) -> Result<Option<OutPoint>>;
50+
fn get_space_outpoint(&mut self, space_hash: &SpaceKey) -> Result<Option<OutPoint>>;
5451

5552
fn get_spaceout(&mut self, outpoint: &OutPoint) -> Result<Option<SpaceOut>>;
5653
}

protocol/src/validate.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec};
2+
23
#[cfg(feature = "bincode")]
34
use bincode::{Decode, Encode};
45
use bitcoin::{Amount, OutPoint, Transaction, Txid};
@@ -7,7 +8,7 @@ use serde::{Deserialize, Serialize};
78

89
use crate::{
910
constants::{AUCTION_DURATION, AUCTION_EXTENSION_ON_BID, RENEWAL_INTERVAL, ROLLOUT_BATCH_SIZE},
10-
prepare::{is_magic_lock_time, AuctionedOutput, TxContext, TrackableOutput, SSTXO},
11+
prepare::{is_magic_lock_time, AuctionedOutput, TrackableOutput, TxContext, SSTXO},
1112
script::{OpOpenContext, ScriptError, SpaceKind},
1213
sname::SName,
1314
BidPsbtReason, Covenant, FullSpaceOut, RejectReason, RevokeReason, Space, SpaceOut,
@@ -384,7 +385,7 @@ impl Validator {
384385
return;
385386
}
386387

387-
changeset.updates.push(UpdateOut{
388+
changeset.updates.push(UpdateOut {
388389
kind: UpdateKind::Bid,
389390
output: fullspaceout,
390391
});

0 commit comments

Comments
 (0)