Merge branch 'master' into new-jsonrpc
This commit is contained in:
@@ -234,7 +234,8 @@ pub struct Miner {
|
||||
impl Miner {
|
||||
/// Push notifier that will handle new jobs
|
||||
pub fn push_notifier(&self, notifier: Box<NotifyWork>) {
|
||||
self.notifiers.write().push(notifier)
|
||||
self.notifiers.write().push(notifier);
|
||||
self.sealing_work.lock().enabled = true;
|
||||
}
|
||||
|
||||
/// Creates new instance of miner Arc.
|
||||
@@ -304,7 +305,7 @@ impl Miner {
|
||||
|
||||
fn forced_sealing(&self) -> bool {
|
||||
self.options.force_sealing
|
||||
|| !self.options.new_work_notify.is_empty()
|
||||
|| !self.notifiers.read().is_empty()
|
||||
|| Instant::now() > *self.next_mandatory_reseal.read()
|
||||
}
|
||||
|
||||
@@ -1017,6 +1018,16 @@ impl MinerService for Miner {
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_pending_transaction(&self, chain: &MiningBlockChainClient, hash: &H256) -> Option<PendingTransaction> {
|
||||
let mut queue = self.transaction_queue.lock();
|
||||
let tx = queue.find(hash);
|
||||
if tx.is_some() {
|
||||
let fetch_nonce = |a: &Address| chain.latest_nonce(a);
|
||||
queue.remove_invalid(hash, &fetch_nonce);
|
||||
}
|
||||
tx
|
||||
}
|
||||
|
||||
fn pending_receipt(&self, best_block: BlockNumber, hash: &H256) -> Option<RichReceipt> {
|
||||
self.from_pending_block(
|
||||
best_block,
|
||||
|
||||
@@ -150,6 +150,10 @@ pub trait MinerService : Send + Sync {
|
||||
/// Query pending transactions for hash.
|
||||
fn transaction(&self, best_block: BlockNumber, hash: &H256) -> Option<PendingTransaction>;
|
||||
|
||||
/// Removes transaction from the queue.
|
||||
/// NOTE: The transaction is not removed from pending block if mining.
|
||||
fn remove_pending_transaction(&self, chain: &MiningBlockChainClient, hash: &H256) -> Option<PendingTransaction>;
|
||||
|
||||
/// Get a list of all pending transactions in the queue.
|
||||
fn pending_transactions(&self) -> Vec<PendingTransaction>;
|
||||
|
||||
|
||||
@@ -211,6 +211,8 @@ impl From<AddrParseError> for Error {
|
||||
|
||||
impl super::work_notify::NotifyWork for Stratum {
|
||||
fn notify(&self, pow_hash: H256, difficulty: U256, number: u64) {
|
||||
trace!(target: "stratum", "Notify work");
|
||||
|
||||
self.service.push_work_all(
|
||||
self.dispatcher.payload(pow_hash, difficulty, number)
|
||||
).unwrap_or_else(
|
||||
|
||||
Reference in New Issue
Block a user