Skip to content

Commit 2cc179e

Browse files
committed
Client supports now to query the Status of local transactions.
+ Log Level adjustments
1 parent 2d2e044 commit 2cc179e

File tree

8 files changed

+49
-5
lines changed

8 files changed

+49
-5
lines changed

crates/concensus/miner/src/pool/queue.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ use crate::pool::{
4141
verifier, PendingOrdering, PendingSettings, PrioritizationStrategy,
4242
};
4343

44+
use super::local_transactions;
45+
4446
type Listener = (
4547
LocalTransactionsList,
4648
(listener::Notifier, listener::Logger),
@@ -546,6 +548,17 @@ impl TransactionQueue {
546548
)
547549
}
548550

551+
/// Returns status of a local transaction by its hash.
552+
pub fn local_transaction_status(&self, tx_hash: &H256) -> Option<local_transactions::Status> {
553+
self.pool
554+
.read()
555+
.listener()
556+
.0
557+
.all_transactions()
558+
.get(tx_hash)
559+
.cloned()
560+
}
561+
549562
/// Collect pending transactions.
550563
///
551564
/// NOTE This is re-computing the pending set and it might be expensive to do so.

crates/ethcore/src/client/client.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ use ansi_term::Colour;
8989
use bytes::{Bytes, ToPretty};
9090
use call_contract::{CallContract, RegistryInfo};
9191
use db::{DBTransaction, DBValue, KeyValueDB};
92-
use ethcore_miner::pool::VerifiedTransaction;
92+
use ethcore_miner::pool::{VerifiedTransaction, local_transactions::Status};
9393
use ethereum_types::{Address, H256, H264, H512, U256};
9494
use hash::keccak;
9595
use itertools::Itertools;
@@ -1410,6 +1410,16 @@ impl Client {
14101410
}
14111411
}
14121412

1413+
/// Get local transactions from the miner.
1414+
pub fn local_transactions(&self) -> BTreeMap<H256, Status> {
1415+
self.importer.miner.local_transactions()
1416+
}
1417+
1418+
/// Get local transactions from the miner.
1419+
pub fn local_transaction_status(&self, tx_hash: &H256) -> Option<Status> {
1420+
self.importer.miner.local_transaction_status(tx_hash)
1421+
}
1422+
14131423
/// Get shared miner reference.
14141424
#[cfg(test)]
14151425
pub fn miner(&self) -> Arc<Miner> {

crates/ethcore/src/engines/hbbft/contracts/validator_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn is_pending_validator(
8181
call_const_validator!(c, is_pending_validator, staking_address.clone())
8282
}
8383

84-
#[derive(PartialEq)]
84+
#[derive(PartialEq, Debug)]
8585
pub enum KeyGenMode {
8686
WritePart,
8787
WriteAck,

crates/ethcore/src/engines/hbbft/hbbft_peers_management.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl HbbftPeersManagement {
9191
) {
9292
connected_current_pending_validators.push(connected_validator);
9393
} else {
94-
warn!(target: "Engine", "could not add pending validator to reserved peers: {}", pending_validator_address);
94+
debug!(target: "Engine", "could not add pending validator to reserved peers: {}", pending_validator_address);
9595
}
9696
}
9797
}
@@ -546,7 +546,7 @@ fn connect_to_validator_core(
546546
};
547547

548548
if socket_addr.port() == 0 {
549-
error!(target: "engine", "connect_to_validator_core: no port specified for Node ( Public (NodeId): {:?} , staking address: {}, socket_addr: {:?}", node_id, staking_address, socket_addr);
549+
debug!(target: "engine", "connect_to_validator_core: no port specified for Node ( Public (NodeId): {:?} , staking address: {}, socket_addr: {:?}", node_id, staking_address, socket_addr);
550550
// we interprate port 0 as NULL.
551551
return None;
552552
}

crates/ethcore/src/engines/hbbft/keygen_transactions.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,13 @@ impl KeygenTransactionSender {
440440
// it could trigger in a scenario where a service transaction was just sent,
441441
// is getting included by other nodes, but this one does not know about it yet,
442442
// sending a Nonce that is to small.
443+
// if a transaction gets replaced, "own_tx Transaction culled" happens,
444+
// in this case we there are signs, that our key gen transaction was not included,
445+
// and we might need to resend it.
446+
// currently there is no "observer" available, to observe culled transactions,
447+
// local_transactions frequently deletes outdated transactions.
448+
// however: we could check if the transaction is neither available in the service transaction pool,
449+
// nor available as included transaction.
443450
// A better ServiceTransactionManager could be implemented to handle this more gracefully.
444451

445452
let nonce = full_client

crates/ethcore/src/miner/miner.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,10 @@ impl miner::MinerService for Miner {
14841484
.expect("remove() returns one result per hash; one hash passed; qed")
14851485
}
14861486

1487+
fn local_transaction_status(&self, hash: &H256) -> Option<pool::local_transactions::Status> {
1488+
self.transaction_queue.local_transaction_status(hash)
1489+
}
1490+
14871491
fn queue_status(&self) -> QueueStatus {
14881492
self.transaction_queue.status()
14891493
}

crates/ethcore/src/miner/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ use crate::types::{
4646
transaction::{self, PendingTransaction, SignedTransaction, UnverifiedTransaction},
4747
};
4848
use bytes::Bytes;
49-
use ethcore_miner::pool::{QueueStatus, VerifiedTransaction, local_transactions};
49+
use ethcore_miner::pool::{
50+
QueueStatus, VerifiedTransaction,
51+
local_transactions::{self, Status},
52+
};
5053
use ethereum_types::{Address, H256, U256};
5154

5255
use crate::{
@@ -287,4 +290,7 @@ pub trait MinerService: Send + Sync {
287290
/// Set a new minimum gas limit.
288291
/// Will not work if dynamic gas calibration is set.
289292
fn set_minimal_gas_price(&self, gas_price: U256) -> Result<bool, &str>;
293+
294+
/// Get the status of a local transaction by its hash.
295+
fn local_transaction_status(&self, hash: &H256) -> Option<Status>;
290296
}

crates/rpc/src/v1/tests/helpers/miner_service.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ impl MinerService for TestMinerService {
286286
.collect()
287287
}
288288

289+
fn local_transaction_status(&self, tx_hash: &H256) -> Option<LocalTransactionStatus> {
290+
self.local_transactions.lock().get(tx_hash).cloned()
291+
}
292+
289293
fn ready_transactions_filtered<C: ethcore::client::BlockChain>(
290294
&self,
291295
chain: &C,

0 commit comments

Comments
 (0)