mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-12-02 23:37:06 +00:00
chainHead based backend implementation (#1161)
* add follow_stream impl * follow_stream_unpin first draft * add tests for follow_stream_unpin * more tests and fixes for follow_stream_unpin * first pass follow_stream_driver * follow_stream_driver: add tests, fix things, buffer events from last finalized * First pass finishing Backend impl * Fix test compile issues * clippy fixes * clippy fix and consistify light_client * revert lightclient tweak * revert other lightclient thing * cargo fmt * start testing unstable backend behind feature flag * more test fixes and move test-runtime metadata path just incase * fix compile error * ensure transaction progress stream actually used and fix another test * cargo fmt * CI tweak * improve some comments and address some feedback bits * update CI to use our own nightly binary * wait for finalized block perhaps
This commit is contained in:
1 parent
00cce68371
commit
cf7e2db1b7
43 files changed
+2682
-250
No files matched your search
@@ -19,6 +19,7 @@ use std::collections::VecDeque;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
// Expose the RPC methods.
|
||||
pub use rpc_methods::LegacyRpcMethods;
|
||||
|
||||
/// The legacy backend.
|
||||
@@ -125,15 +126,6 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for LegacyBackend<T> {
|
||||
Ok(BlockRef::from_hash(hash))
|
||||
}
|
||||
|
||||
async fn latest_best_block_ref(&self) -> Result<BlockRef<T::Hash>, Error> {
|
||||
let hash = self
|
||||
.methods
|
||||
.chain_get_block_hash(None)
|
||||
.await?
|
||||
.ok_or_else(|| Error::Other("Latest best block doesn't exist".into()))?;
|
||||
Ok(BlockRef::from_hash(hash))
|
||||
}
|
||||
|
||||
async fn current_runtime_version(&self) -> Result<RuntimeVersion, Error> {
|
||||
let details = self.methods.state_get_runtime_version(None).await?;
|
||||
Ok(RuntimeVersion {
|
||||
@@ -231,7 +223,9 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for LegacyBackend<T> {
|
||||
})
|
||||
}
|
||||
RpcTransactionStatus::InBlock(hash) => {
|
||||
Some(TransactionStatus::InBestBlock { hash })
|
||||
Some(TransactionStatus::InBestBlock {
|
||||
hash: BlockRef::from_hash(hash),
|
||||
})
|
||||
}
|
||||
// These 5 mean that the stream will very likely end:
|
||||
RpcTransactionStatus::FinalityTimeout(_) => {
|
||||
@@ -240,7 +234,9 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for LegacyBackend<T> {
|
||||
})
|
||||
}
|
||||
RpcTransactionStatus::Finalized(hash) => {
|
||||
Some(TransactionStatus::InFinalizedBlock { hash })
|
||||
Some(TransactionStatus::InFinalizedBlock {
|
||||
hash: BlockRef::from_hash(hash),
|
||||
})
|
||||
}
|
||||
RpcTransactionStatus::Usurped(_) => Some(TransactionStatus::Invalid {
|
||||
message: "Transaction was usurped by another with the same nonce"
|
||||
|
||||
Reference in new issue
Block a user