Skip to content

Commit 1d889ca

Browse files
committed
Rebase master
1 parent 52e41ce commit 1d889ca

File tree

4 files changed

+161
-65
lines changed

4 files changed

+161
-65
lines changed

fuel-p2p/src/behavior.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
DiscoveryEvent,
1111
},
1212
gossipsub::{
13-
self,
13+
build_gossipsub,
1414
messages::{
1515
GossipsubBroadcastRequest,
1616
GossipsubMessage as FuelGossipsubMessage,
@@ -194,7 +194,7 @@ impl<Codec: NetworkCodec> FuelBehaviour<Codec> {
194194

195195
Self {
196196
discovery: discovery_config.finish(),
197-
gossipsub: gossipsub::build_gossipsub(&local_keypair, p2p_config),
197+
gossipsub: build_gossipsub(&local_keypair, p2p_config),
198198
peer_info,
199199
request_response,
200200

fuel-txpool/src/mock_db.rs

+32-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1-
use std::borrow::Cow;
2-
use std::collections::HashMap;
3-
use std::sync::{Arc, Mutex};
1+
use std::{
2+
borrow::Cow,
3+
collections::HashMap,
4+
sync::{
5+
Arc,
6+
Mutex,
7+
},
8+
};
49

510
use fuel_core_interfaces::{
611
common::{
712
fuel_storage::Storage,
8-
fuel_tx::{Contract, ContractId, MessageId, UtxoId},
13+
fuel_tx::{
14+
Contract,
15+
ContractId,
16+
MessageId,
17+
UtxoId,
18+
},
19+
},
20+
db::{
21+
Error,
22+
KvStoreError,
23+
},
24+
model::{
25+
Coin,
26+
Message,
927
},
10-
db::{Error, KvStoreError},
11-
model::{Coin, Message},
1228
txpool::TxPoolDb,
1329
};
1430

@@ -27,7 +43,11 @@ pub(crate) struct MockDb {
2743
impl Storage<UtxoId, Coin> for MockDb {
2844
type Error = KvStoreError;
2945

30-
fn insert(&mut self, key: &UtxoId, value: &Coin) -> Result<Option<Coin>, Self::Error> {
46+
fn insert(
47+
&mut self,
48+
key: &UtxoId,
49+
value: &Coin,
50+
) -> Result<Option<Coin>, Self::Error> {
3151
Ok(self.data.lock().unwrap().coins.insert(*key, value.clone()))
3252
}
3353

@@ -88,7 +108,11 @@ impl Storage<ContractId, Contract> for MockDb {
88108
impl Storage<MessageId, Message> for MockDb {
89109
type Error = KvStoreError;
90110

91-
fn insert(&mut self, key: &MessageId, value: &Message) -> Result<Option<Message>, Self::Error> {
111+
fn insert(
112+
&mut self,
113+
key: &MessageId,
114+
value: &Message,
115+
) -> Result<Option<Message>, Self::Error> {
92116
Ok(self
93117
.data
94118
.lock()

fuel-txpool/src/service.rs

+31-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
use crate::{Config, TxPool};
1+
use crate::{
2+
Config,
3+
TxPool,
4+
};
25
use anyhow::anyhow;
3-
use fuel_core_interfaces::block_importer::ImportBlockBroadcast;
4-
use fuel_core_interfaces::txpool::{self, TxPoolDb, TxPoolMpsc, TxStatusBroadcast};
6+
use fuel_core_interfaces::{
7+
block_importer::ImportBlockBroadcast,
8+
txpool::{
9+
self,
10+
TxPoolDb,
11+
TxPoolMpsc,
12+
TxStatusBroadcast,
13+
},
14+
};
515
use std::sync::Arc;
6-
use tokio::sync::{broadcast, mpsc, Mutex, RwLock};
7-
use tokio::task::JoinHandle;
16+
use tokio::{
17+
sync::{
18+
broadcast,
19+
mpsc,
20+
Mutex,
21+
RwLock,
22+
},
23+
task::JoinHandle,
24+
};
825

926
pub struct ServiceBuilder {
1027
sender: txpool::Sender,
@@ -63,7 +80,7 @@ impl ServiceBuilder {
6380

6481
pub fn build(self) -> anyhow::Result<Service> {
6582
if self.db.is_none() || self.import_block_events.is_none() {
66-
return Err(anyhow!("One of context items are not set"));
83+
return Err(anyhow!("One of context items are not set"))
6784
}
6885
let service = Service::new(
6986
self.sender,
@@ -207,7 +224,10 @@ pub mod tests {
207224
use crate::MockDb;
208225
use fuel_core_interfaces::{
209226
common::fuel_tx::TransactionBuilder,
210-
txpool::{Error as TxpoolError, TxStatus},
227+
txpool::{
228+
Error as TxpoolError,
229+
TxStatus,
230+
},
211231
};
212232
use tokio::sync::oneshot;
213233

@@ -416,7 +436,8 @@ pub mod tests {
416436
let _rem = receiver.await.unwrap();
417437

418438
assert_eq!(
419-
tokio::time::timeout(std::time::Duration::from_secs(2), subscribe.recv()).await,
439+
tokio::time::timeout(std::time::Duration::from_secs(2), subscribe.recv())
440+
.await,
420441
Ok(Ok(TxStatusBroadcast {
421442
tx: tx1,
422443
status: TxStatus::SqueezedOut {
@@ -427,7 +448,8 @@ pub mod tests {
427448
);
428449

429450
assert_eq!(
430-
tokio::time::timeout(std::time::Duration::from_secs(2), subscribe.recv()).await,
451+
tokio::time::timeout(std::time::Duration::from_secs(2), subscribe.recv())
452+
.await,
431453
Ok(Ok(TxStatusBroadcast {
432454
tx: tx2,
433455
status: TxStatus::SqueezedOut {

0 commit comments

Comments
 (0)