Skip to content

Commit

Permalink
Fixes and updates from Helius fork (metaplex-foundation#60)
Browse files Browse the repository at this point in the history
Co-authored-by: Tahsin Tunan <[email protected]>
  • Loading branch information
NicolasPennie and tahsintunan authored Jul 18, 2023
1 parent 317dd0f commit 64c0a3f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions plerkle/src/geyser_plugin_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,7 @@ impl GeyserPlugin for Plerkle<'static> {
}

metric! {
let slt_idx = format!("{}-{}", slot, transaction_info.index);
statsd_count!("transaction_seen_event", 1, "slot-idx" => &slt_idx);
statsd_count!("transaction_seen_event", 1);
}
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions plerkle_messenger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ futures = "0.3"
async-mutex = "1.4.0"
serde = {version = "1.0.137", features = ["derive"] }
blake3 = "1.3.3"
cadence = "0.29.0"
cadence-macros = "0.29.0"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down
1 change: 1 addition & 0 deletions plerkle_messenger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub mod redis_messenger;

mod error;
mod metrics;
mod plerkle_messenger;

pub use crate::{error::*, plerkle_messenger::*};
10 changes: 10 additions & 0 deletions plerkle_messenger/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[macro_export]
macro_rules! metric {
{$($block:stmt;)*} => {
if cadence_macros::is_global_default_set() {
$(
$block
)*
}
};
}
17 changes: 10 additions & 7 deletions plerkle_messenger/src/redis_messenger.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{
error::MessengerError, ConsumptionType, Messenger, MessengerConfig, MessengerType, RecvData,
error::MessengerError, metric, ConsumptionType, Messenger, MessengerConfig, MessengerType,
RecvData,
};
use async_trait::async_trait;

use cadence_macros::statsd_count;
use log::*;
use redis::{
aio::ConnectionManager,
Expand Down Expand Up @@ -76,10 +78,8 @@ impl RedisMessenger {
.await
.map_err(|e| MessengerError::AutoclaimError { msg: e.to_string() })?;

id = result.0;
let range_reply = result.1;

if id == "0-0" || range_reply.ids.is_empty() {
if range_reply.ids.is_empty() {
// We've reached the end of the PEL.
return Ok(Vec::new());
}
Expand Down Expand Up @@ -116,26 +116,29 @@ impl RedisMessenger {
let info = if let Some(info) = pending.get(&id) {
info
} else {
println!("No pending info for ID {id}");
warn!("No pending info for ID {id}");
continue;
};
let data = if let Some(data) = map.get(DATA_KEY) {
data
} else {
println!("No Data was stored in Redis for ID {id}");
info!("No Data was stored in Redis for ID {id}");
continue;
};
// Get data from map.

let bytes = match data {
Value::Data(bytes) => bytes,
_ => {
println!("Redis data for ID {id} in wrong format");
error!("Redis data for ID {id} in wrong format");
continue;
}
};

if info.times_delivered > self.retries {
metric! {
statsd_count!("plerkle.messenger.retries.exceeded", 1);
}
error!("Message has reached maximum retries {} for id", id);
ack_list.push(id.clone());
continue;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.64.0"
channel = "stable"

0 comments on commit 64c0a3f

Please sign in to comment.