mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
unstable_rpc: Add transactionBroadcast and transactionStop (#1497)
* unstable_rpc: Add transactionBroadcast and transactionStop Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Check transactionBroadcast works Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Enable default feature for subxt-signer Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Increase number of blocks to look for Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix clippy for unneed let binds Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update subxt/src/backend/unstable/rpc_methods.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * tests: Adjust txBroadcast test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Add test for txStop Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Ignore compact encoded lenght prefix Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -288,6 +288,28 @@ impl<T: Config> UnstableRpcMethods<T> {
|
||||
|
||||
Ok(TransactionSubscription { sub, done: false })
|
||||
}
|
||||
|
||||
/// Broadcast the transaction on the p2p network until the
|
||||
/// [`Self::transaction_unstable_stop`] is called.
|
||||
///
|
||||
/// Returns an operation ID that can be used to stop the broadcasting process.
|
||||
/// Returns `None` if the server cannot handle the request at the moment.
|
||||
pub async fn transaction_unstable_broadcast(&self, tx: &[u8]) -> Result<Option<String>, Error> {
|
||||
self.client
|
||||
.request("transaction_unstable_broadcast", rpc_params![to_hex(tx)])
|
||||
.await
|
||||
}
|
||||
|
||||
/// Stop the broadcasting process of the transaction.
|
||||
///
|
||||
/// The operation ID is obtained from the [`Self::transaction_unstable_broadcast`] method.
|
||||
///
|
||||
/// Returns an error if the operation ID does not correspond to any active transaction for this connection.
|
||||
pub async fn transaction_unstable_stop(&self, operation_id: &str) -> Result<(), Error> {
|
||||
self.client
|
||||
.request("transaction_unstable_stop", rpc_params![operation_id])
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
/// This represents events generated by the `follow` method.
|
||||
|
||||
Reference in New Issue
Block a user