Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions core/src/rpc_utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use log::warn;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_client::rpc_config::RpcTransactionConfig;
use solana_clock::Slot;
use solana_commitment_config::CommitmentConfig;
use solana_rpc_client_api::client_error::Error as RpcError;
use solana_rpc_client_api::client_error::{Error as RpcError, ErrorKind as RpcErrorKind};
use solana_signature::Signature;
use solana_transaction_status::{EncodedConfirmedTransactionWithStatusMeta, UiTransactionEncoding};
use std::iter::{Map, Take};
Expand Down Expand Up @@ -45,14 +46,31 @@ async fn get_signatures_internal(

let mut temp_txs = vec![];
for signature in transaction_signatures.iter() {
let tx = rpc_client
match rpc_client
.get_transaction_with_config(signature, config)
.await?;
temp_txs.push(tx);
.await
{
Ok(tx) => temp_txs.push(tx),
Err(e) if is_null_transaction(&e) => {
warn!("getTransaction returned null for {signature}, skipping");
Comment thread
aoikurokawa marked this conversation as resolved.
Outdated
continue;
}
Err(e) => return Err(e),
}
}
Ok(temp_txs)
}

/// Returns true when an RPC error is the serde failure produced by a `null`
/// `getTransaction` response (`invalid type: null, expected struct
/// EncodedConfirmedTransactionWithStatusMeta`).
fn is_null_transaction(err: &RpcError) -> bool {
match &err.kind {
RpcErrorKind::SerdeJson(e) => e.to_string().contains("invalid type: null"),
_ => false,
}
}
Comment thread
aoikurokawa marked this conversation as resolved.

pub async fn retry_get_slot(rpc_client: &RpcClient) -> Result<Slot, RpcError> {
Retry::spawn(retry(), || rpc_client.get_slot()).await
}
2 changes: 1 addition & 1 deletion steward-writer-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async fn listen(
before,
until: Some(latest_signature),
limit: Some(NUM_TRANSACTIONS),
commitment: Some(CommitmentConfig::confirmed()),
commitment: Some(CommitmentConfig::finalized()),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think better to use same commitment level here

},
)
.await
Expand Down
Loading