Retaining transaction logs when transaction plugin is loaded. (#22874)

Transaction logs are not being saved to the database through the plugin interface.

Summary of Changes

Retain the transaction logs when transaction notification plugin is loaded.

Fixes #
lijunwangs/solana-accountsdb-plugin-postgres#6
This commit is contained in:
Lijun Wang
2022-02-11 20:29:07 -08:00
committed by GitHub
parent 817f47d970
commit c04438be4b
5 changed files with 17 additions and 15 deletions

View File

@ -4330,6 +4330,7 @@ pub fn create_test_transactions_and_populate_blockstore(
true,
None,
blockstore,
false,
&Arc::new(AtomicBool::new(false)),
);
@ -4343,7 +4344,6 @@ pub fn create_test_transactions_and_populate_blockstore(
Some(
&solana_ledger::blockstore_processor::TransactionStatusSender {
sender: transaction_status_sender,
enable_cpi_and_log_storage: false,
},
),
Some(&replay_vote_sender),

View File

@ -34,6 +34,7 @@ impl TransactionStatusService {
enable_rpc_transaction_history: bool,
transaction_notifier: Option<TransactionNotifierLock>,
blockstore: Arc<Blockstore>,
enable_cpi_and_log_storage: bool,
exit: &Arc<AtomicBool>,
) -> Self {
let exit = exit.clone();
@ -50,6 +51,7 @@ impl TransactionStatusService {
enable_rpc_transaction_history,
transaction_notifier.clone(),
&blockstore,
enable_cpi_and_log_storage,
) {
break;
}
@ -64,6 +66,7 @@ impl TransactionStatusService {
enable_rpc_transaction_history: bool,
transaction_notifier: Option<TransactionNotifierLock>,
blockstore: &Arc<Blockstore>,
enable_cpi_and_log_storage: bool,
) -> Result<(), RecvTimeoutError> {
match write_transaction_status_receiver.recv_timeout(Duration::from_secs(1))? {
TransactionStatusMessage::Batch(TransactionStatusBatch {
@ -142,7 +145,7 @@ impl TransactionStatusService {
.collect(),
);
let loaded_addresses = transaction.get_loaded_addresses();
let transaction_status_meta = TransactionStatusMeta {
let mut transaction_status_meta = TransactionStatusMeta {
status,
fee,
pre_balances,
@ -163,6 +166,12 @@ impl TransactionStatusService {
&transaction,
);
}
if !(enable_cpi_and_log_storage || transaction_notifier.is_some()) {
transaction_status_meta.log_messages.take();
transaction_status_meta.inner_instructions.take();
}
if enable_rpc_transaction_history {
if let Some(memos) = extract_and_fmt_memos(transaction.message()) {
blockstore
@ -385,6 +394,7 @@ pub(crate) mod tests {
false,
Some(test_notifier.clone()),
blockstore,
false,
&exit,
);