Skip to content

Commit 7312650

Browse files
committed
Use same commitment level for Oracle and Subscriber
1 parent a7b045b commit 7312650

File tree

1 file changed

+9
-30
lines changed

1 file changed

+9
-30
lines changed

src/agent/solana/oracle.rs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ pub struct Config {
9393
pub poll_interval_duration: Duration,
9494
/// Whether subscribing to account updates over websocket is enabled
9595
pub subscriber_enabled: bool,
96-
/// Configuration for account Subscriber
97-
pub subscriber: subscriber::Config,
9896
/// Capacity of the channel over which the Subscriber sends updates to the Exporter
9997
pub updates_channel_capacity: usize,
10098
}
@@ -105,7 +103,6 @@ impl Default for Config {
105103
commitment: CommitmentLevel::Confirmed,
106104
poll_interval_duration: Duration::from_secs(30),
107105
subscriber_enabled: true,
108-
subscriber: Default::default(),
109106
updates_channel_capacity: 10000,
110107
}
111108
}
@@ -125,9 +122,9 @@ pub fn spawn_oracle(
125122
let (updates_tx, updates_rx) = mpsc::channel(config.updates_channel_capacity);
126123
if config.subscriber_enabled {
127124
let subscriber = Subscriber::new(
128-
config.subscriber.clone(),
129125
rpc_url.to_string(),
130126
wss_url.to_string(),
127+
config.commitment,
131128
key_store.program_key.clone(),
132129
updates_tx,
133130
logger.clone(),
@@ -450,10 +447,6 @@ mod subscriber {
450447
anyhow,
451448
Result,
452449
},
453-
serde::{
454-
Deserialize,
455-
Serialize,
456-
},
457450
slog::Logger,
458451
solana_sdk::{
459452
account::Account,
@@ -470,30 +463,16 @@ mod subscriber {
470463
},
471464
};
472465

473-
#[derive(Clone, Serialize, Deserialize, Debug)]
474-
#[serde(default)]
475-
pub struct Config {
476-
/// Commitment level used to read account data
477-
pub commitment: CommitmentLevel,
478-
}
479-
480-
impl Default for Config {
481-
fn default() -> Self {
482-
Self {
483-
commitment: CommitmentLevel::Confirmed,
484-
}
485-
}
486-
}
487-
488466
/// Subscriber subscribes to all changes on the given account, and sends those changes
489467
/// on updates_tx. This is a convenience wrapper around the Blockchain Shadow crate.
490468
pub struct Subscriber {
491-
config: Config,
492-
493469
/// HTTP RPC endpoint
494-
pub rpc_url: String,
470+
rpc_url: String,
495471
/// WSS RPC endpoint
496-
pub wss_url: String,
472+
wss_url: String,
473+
474+
/// Commitment level used to read account data
475+
commitment: CommitmentLevel,
497476

498477
/// Public key of the root account to monitor. Note that all
499478
/// accounts owned by this account are also monitored.
@@ -507,17 +486,17 @@ mod subscriber {
507486

508487
impl Subscriber {
509488
pub fn new(
510-
config: Config,
511489
rpc_url: String,
512490
wss_url: String,
491+
commitment: CommitmentLevel,
513492
account_key: Pubkey,
514493
updates_tx: mpsc::Sender<(Pubkey, solana_sdk::account::Account)>,
515494
logger: Logger,
516495
) -> Self {
517496
Subscriber {
518-
config,
519497
rpc_url,
520498
wss_url,
499+
commitment,
521500
account_key,
522501
updates_tx,
523502
logger,
@@ -559,7 +538,7 @@ mod subscriber {
559538
self.rpc_url.clone(),
560539
self.wss_url.clone(),
561540
),
562-
commitment: self.config.commitment,
541+
commitment: self.commitment,
563542
..SyncOptions::default()
564543
},
565544
)

0 commit comments

Comments
 (0)