Skip to content

Commit 408c024

Browse files
Seulgi Kimmajecty
authored andcommitted
Remove ChainNotify::transactions_received()
This is not used.
1 parent a56097d commit 408c024

File tree

6 files changed

+9
-28
lines changed

6 files changed

+9
-28
lines changed

core/src/client/chain_notify.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

17-
use cnetwork::NodeId;
18-
use ctypes::{BlockHash, TxHash};
17+
use ctypes::BlockHash;
1918

2019
/// Represents what has to be handled by actor listening to chain events
2120
pub trait ChainNotify: Send + Sync {
@@ -28,9 +27,4 @@ pub trait ChainNotify: Send + Sync {
2827
fn new_blocks(&self, _imported: Vec<BlockHash>, _invalid: Vec<BlockHash>, _enacted: Vec<BlockHash>) {
2928
// does nothing by default
3029
}
31-
32-
/// fires when new transactions are received from a peer
33-
fn transactions_received(&self, _hashes: Vec<TxHash>, _peer_id: NodeId) {
34-
// does nothing by default
35-
}
3630
}

core/src/client/client.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use crate::MemPoolMinFees;
3737
use cdb::{new_journaldb, Algorithm, AsHashDB};
3838
use cio::IoChannel;
3939
use ckey::{Address, NetworkId, PlatformAddress};
40-
use cnetwork::NodeId;
4140
use cstate::{ActionHandler, FindActionHandler, StateDB, StateResult, TopLevelState, TopStateView};
4241
use ctimer::{TimeoutHandler, TimerApi, TimerScheduleError, TimerToken};
4342
use ctypes::header::Header;
@@ -138,12 +137,6 @@ impl Client {
138137
self.notify.write().push(target);
139138
}
140139

141-
pub fn transactions_received(&self, hashes: &[TxHash], peer_id: NodeId) {
142-
self.notify(|notify| {
143-
notify.transactions_received(hashes.to_vec(), peer_id);
144-
});
145-
}
146-
147140
pub fn new_blocks(&self, imported: &[BlockHash], invalid: &[BlockHash], enacted: &[BlockHash]) {
148141
self.notify(|notify| notify.new_blocks(imported.to_vec(), invalid.to_vec(), enacted.to_vec()));
149142
}
@@ -202,13 +195,11 @@ impl Client {
202195
}
203196

204197
/// Import transactions from the IO queue
205-
pub fn import_queued_transactions(&self, transactions: &[Bytes], peer_id: NodeId) -> usize {
198+
pub fn import_queued_transactions(&self, transactions: &[Bytes]) -> usize {
206199
ctrace!(EXTERNAL_TX, "Importing queued");
207200
self.queue_transactions.fetch_sub(transactions.len(), AtomicOrdering::SeqCst);
208201
let transactions: Vec<UnverifiedTransaction> =
209202
transactions.iter().filter_map(|bytes| Rlp::new(bytes).as_val().ok()).collect();
210-
let hashes: Vec<_> = transactions.iter().map(UnverifiedTransaction::hash).collect();
211-
self.transactions_received(&hashes, peer_id);
212203
let results = self.importer.miner.import_external_transactions(self, transactions);
213204
results.len()
214205
}
@@ -535,14 +526,14 @@ impl BlockChainClient for Client {
535526
Ok(())
536527
}
537528

538-
fn queue_transactions(&self, transactions: Vec<Bytes>, peer_id: NodeId) {
529+
fn queue_transactions(&self, transactions: Vec<Bytes>) {
539530
let queue_size = self.queue_transactions.load(AtomicOrdering::Relaxed);
540531
ctrace!(EXTERNAL_TX, "Queue size: {}", queue_size);
541532
if queue_size > MAX_MEM_POOL_SIZE {
542533
cwarn!(EXTERNAL_TX, "Ignoring {} transactions: queue is full", transactions.len());
543534
} else {
544535
let len = transactions.len();
545-
match self.io_channel.lock().send(ClientIoMessage::NewTransactions(transactions, peer_id)) {
536+
match self.io_channel.lock().send(ClientIoMessage::NewTransactions(transactions)) {
546537
Ok(_) => {
547538
self.queue_transactions.fetch_add(len, AtomicOrdering::SeqCst);
548539
}

core/src/client/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use crate::transaction::{LocalizedTransaction, PendingVerifiedTransactions, Veri
3838
use crate::types::{BlockId, BlockStatus, TransactionId, VerificationQueueInfo as BlockQueueInfo};
3939
use cdb::DatabaseError;
4040
use ckey::{Address, NetworkId, PlatformAddress};
41-
use cnetwork::NodeId;
4241
use cstate::{FindActionHandler, StateResult, TopLevelState, TopStateView};
4342
use ctypes::header::Header;
4443
use ctypes::transaction::ShardTransaction;
@@ -198,7 +197,7 @@ pub trait BlockChainClient: Sync + Send + AccountData + BlockChainTrait + Import
198197
fn queue_own_transaction(&self, transaction: VerifiedTransaction) -> Result<(), GenericError>;
199198

200199
/// Queue transactions for importing.
201-
fn queue_transactions(&self, transactions: Vec<Bytes>, peer_id: NodeId);
200+
fn queue_transactions(&self, transactions: Vec<Bytes>);
202201

203202
/// Delete all pending transactions.
204203
fn delete_all_pending_transactions(&self);

core/src/client/test_client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use ckey::{
5050
public_to_address, Address, Ed25519KeyPair as KeyPair, Ed25519Private as Private, Ed25519Public as Public,
5151
Generator, KeyPairTrait, NetworkId, PlatformAddress, Random,
5252
};
53-
use cnetwork::NodeId;
5453
use cstate::tests::helpers::empty_top_state_with_metadata;
5554
use cstate::{FindActionHandler, StateDB, TopLevelState};
5655
use ctimer::{TimeoutHandler, TimerToken};
@@ -508,7 +507,7 @@ impl BlockChainClient for TestBlockChainClient {
508507
Ok(())
509508
}
510509

511-
fn queue_transactions(&self, transactions: Vec<Bytes>, _peer_id: NodeId) {
510+
fn queue_transactions(&self, transactions: Vec<Bytes>) {
512511
// import right here
513512
let transactions = transactions.into_iter().filter_map(|bytes| Rlp::new(&bytes).as_val().ok()).collect();
514513
self.miner.import_external_transactions(self, transactions);

core/src/service.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use crate::miner::Miner;
2020
use crate::scheme::Scheme;
2121
use crate::BlockId;
2222
use cio::{IoContext, IoHandler, IoHandlerResult, IoService};
23-
use cnetwork::NodeId;
2423
use ctimer::TimerApi;
2524
use ctypes::BlockHash;
2625
use kvdb::KeyValueDB;
@@ -71,7 +70,7 @@ pub enum ClientIoMessage {
7170
/// A header is ready
7271
HeaderVerified,
7372
/// New transaction RLPs are ready to be imported
74-
NewTransactions(Vec<Bytes>, NodeId),
73+
NewTransactions(Vec<Bytes>),
7574
/// Block generation is required
7675
NewBlockRequired {
7776
parent_block: BlockId,
@@ -95,8 +94,8 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
9594
ClientIoMessage::HeaderVerified => {
9695
self.client.import_verified_headers();
9796
}
98-
ClientIoMessage::NewTransactions(transactions, peer_id) => {
99-
self.client.import_queued_transactions(&transactions, peer_id);
97+
ClientIoMessage::NewTransactions(transactions) => {
98+
self.client.import_queued_transactions(&transactions);
10099
}
101100
ClientIoMessage::NewBlockRequired {
102101
parent_block,

sync/src/transaction/extension.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ impl NetworkExtension<Never> for Extension {
111111

112112
self.client.queue_transactions(
113113
transactions.iter().map(|unverified| unverified.rlp_bytes().to_vec()).collect(),
114-
*token,
115114
);
116115
if let Some(peer) = self.peers.get_mut(token) {
117116
let transactions: Vec<_> = transactions

0 commit comments

Comments
 (0)