Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Accountsdb plugin transaction part 3: Transaction Notifier #21374

Conversation

lijunwangs
Copy link
Contributor

@lijunwangs lijunwangs commented Nov 19, 2021

Problem

This enables transaction data to be notified through the plugin framework.

Summary of Changes

  1. The TransactionNotifierInterface interface for notifying transactions.
  2. Changes to transaction_status_service to notify the notifier of the transaction data.
  3. Interface to query the plugin's interest in transaction data
    Fixes #

This is the 3rd part of original PR #21247

Changes to transaction_status_service to notify the notifier of the transaction data.
Interface to query the plugin's interest in transaction data
@lijunwangs lijunwangs force-pushed the accountsdb_plugin_transaction_part_3.3 branch from 4b354e9 to fa7cda8 Compare November 21, 2021 20:29
@codecov
Copy link

codecov bot commented Nov 22, 2021

Codecov Report

Merging #21374 (2e2b887) into master (c3e5927) will increase coverage by 0.0%.
The diff coverage is 86.0%.

@@            Coverage Diff            @@
##           master   #21374     +/-   ##
=========================================
  Coverage    81.5%    81.5%             
=========================================
  Files         500      505      +5     
  Lines      140604   141639   +1035     
=========================================
+ Hits       114704   115549    +845     
- Misses      25900    26090    +190     

@carllin
Copy link
Contributor

carllin commented Nov 23, 2021

Might be good to include a comment describing the high level flow for the components/logic in this notification model. From what I gather it looks something like:

1. AccountsDbPluginService owns a TransactionNotifier
2. TransactionStatusService talks to TransactionNotifier from AccountsDbPluginService via `notify_transaction()`
3. TransactionNotifier owns a `AccountsDbPluginManager`
4. AccountsDbPluginManager calls `notify_transaction` for each plugin, for example a plugin like `AccountsDbPluginPostgres`
5. `AccountsDbPluginPostgres` a TransactionSelector which determines which transactions it's interested in.

/// Check if the plugin is interested in transaction data
/// Default is false -- if the plugin is not interested in
/// transaction data, please return false.
fn to_notify_transaction_data(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

to_notify_transaction_data -> transaction_notifications_enabled
to_notify_account_data -> account_data_notifications_enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 65 to 66
let transaction_log_info =
Self::build_replica_transaction_info(signature, transaction_status_meta, transaction);
Copy link
Contributor

Choose a reason for hiding this comment

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

can move this outside of the self.plugin_manager.write().unwrap(); lock above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

transaction_status_meta: &TransactionStatusMeta,
transaction: &SanitizedTransaction,
) {
self.notify_transaction_info(slot, signature, transaction_status_meta, transaction);
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like we could just move the body of notify_transaction_info inside here, the function signatures look exactly the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

);
}

pub type TransactionNotifier = Arc<RwLock<dyn TransactionNotifierInterface + Sync + Send>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I prefer to be more explicit:

  1. TransactionNotifierInterface -> TransactinNotifier
  2. TransactionNotifier -> TransactionNotifierLock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@lijunwangs lijunwangs merged commit c29838f into solana-labs:master Nov 23, 2021
dankelleher pushed a commit to identity-com/solana that referenced this pull request Nov 24, 2021
…bs#21374)

The TransactionNotifierInterface interface for notifying transactions.
Changes to transaction_status_service to notify the notifier of the transaction data.
Interface to query the plugin's interest in transaction data
frits-metalogix added a commit to identity-com/solana that referenced this pull request Nov 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants