Revert "Watch existing extrinsics RPC (#3873)" (#3931)

This reverts commit d149c2f719.
This commit is contained in:
Gavin Wood
2019-10-27 13:19:06 +01:00
committed by GitHub
parent d149c2f719
commit d41a5ce00f
15 changed files with 73 additions and 194 deletions
@@ -165,17 +165,6 @@ impl<B: ChainApi> Pool<B> {
)
}
/// Watch existing transaction
///
/// Get notified when some existing transaction is finished verifying or gets finalized
/// in a new block.
pub fn watch(
&self,
hash: ExHash<B>,
) -> Watcher<ExHash<B>, BlockHash<B>> {
self.validated_pool.watch(hash)
}
/// Prunes ready transactions.
///
/// Used to clear the pool from transactions that were part of recently imported block.
@@ -794,6 +783,7 @@ mod tests {
// when
pool.validated_pool.remove_invalid(&[*watcher.hash()]);
// then
let mut stream = futures::executor::block_on_stream(watcher.into_stream());
assert_eq!(stream.next(), Some(watcher::Status::Ready));
@@ -917,37 +907,5 @@ mod tests {
assert_eq!(pool.status().ready, 1);
assert_eq!(pool.status().future, 0);
}
#[test]
fn should_watch_existing() {
let limit = Limit {
count: 1,
total_bytes: 1000,
};
let pool = Pool::new(Options {
ready: limit.clone(),
future: limit.clone(),
}, TestApi::default());
let xt = uxt(Transfer {
from: AccountId::from_h256(H256::from_low_u64_be(1)),
to: AccountId::from_h256(H256::from_low_u64_be(2)),
amount: 5,
nonce: 0,
});
let hash = block_on(pool.submit_one(&BlockId::Number(0), xt)).expect("Failed to submit");
assert_eq!(pool.status().ready, 1);
let watcher = pool.watch(hash);
block_on(pool.prune_tags(&BlockId::Number(2), vec![], vec![hash]))
.expect("Failed to prune tags");
let mut stream = futures::executor::block_on_stream(
watcher.into_stream()
);
assert_eq!(stream.next(), Some(watcher::Status::Finalized(H256::from_low_u64_be(2).into())));
assert_eq!(stream.next(), None);
}
}
}
@@ -171,7 +171,7 @@ impl<B: ChainApi> ValidatedPool<B> {
match tx {
ValidatedTransaction::Valid(tx) => {
let hash = self.api.hash_and_length(&tx.data).0;
let watcher = self.watch(hash);
let watcher = self.listener.write().create_watcher(hash);
self.submit(std::iter::once(ValidatedTransaction::Valid(tx)))
.pop()
.expect("One extrinsic passed; one result returned; qed")
@@ -182,11 +182,6 @@ impl<B: ChainApi> ValidatedPool<B> {
}
}
/// Watch some existing transaction with known hash.
pub fn watch(&self, hash: ExHash<B>) -> Watcher<ExHash<B>, BlockHash<B>> {
self.listener.write().create_watcher(hash)
}
/// For each extrinsic, returns tags that it provides (if known), or None (if it is unknown).
pub fn extrinsics_tags(&self, extrinsics: &[ExtrinsicFor<B>]) -> (Vec<ExHash<B>>, Vec<Option<Vec<Tag>>>) {
let hashes = extrinsics.iter().map(|extrinsic| self.api.hash_and_length(extrinsic).0).collect::<Vec<_>>();
@@ -130,6 +130,7 @@ impl<H: Clone, H2: Clone> Sender<H, H2> {
self.send(Status::Broadcast(peers))
}
/// Returns true if the are no more listeners for this extrinsic or it was finalized.
pub fn is_done(&self) -> bool {
self.finalized || self.receivers.is_empty()