Skip to content

Commit

Permalink
Fix linting issues (metaplex-foundation#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelvanderwaal authored Jun 29, 2023
1 parent 4499925 commit 317dd0f
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 26 deletions.
4 changes: 1 addition & 3 deletions plerkle/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use tracing_subscriber::fmt;
pub fn init_logger() {
// tracing doesn't seem to load RUST_LOG even though its supposed to, set it
// manually
let env_filter = env::var("RUST_LOG")
.or::<Result<String, ()>>(Ok("info".to_string()))
.unwrap();
let env_filter = env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string());
fmt()
.with_env_filter(env_filter)
.event_format(fmt::format::json())
Expand Down
16 changes: 8 additions & 8 deletions plerkle/src/geyser_plugin_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use tokio::{
runtime::{Builder, Runtime},
time::Instant,
};
use tracing::{debug, error, info, trace, warn};
use tracing::{debug, error, info, trace};

struct SerializedData<'a> {
stream: &'static str,
Expand Down Expand Up @@ -102,7 +102,7 @@ pub(crate) struct Plerkle<'a> {
conf_level: Option<SlotStatus>,
}

#[derive(Deserialize, PartialEq, Debug)]
#[derive(Deserialize, PartialEq, Eq, Debug)]
pub enum ConfirmationLevel {
Processed,
Rooted,
Expand Down Expand Up @@ -502,7 +502,7 @@ impl GeyserPlugin for Plerkle<'static> {
if cache.contains_key(&account_key) {
cache.alter(&account_key, |_, v| {
if account.write_version > v.0 {
return (account.write_version, data);
(account.write_version, data)
} else {
v
}
Expand Down Expand Up @@ -634,22 +634,22 @@ impl GeyserPlugin for Plerkle<'static> {
"matched transaction"
);
// Get runtime and sender channel.
let runtime = self.get_runtime()?;
let sender = self.get_sender_clone()?;
let _runtime = self.get_runtime()?;
let _sender = self.get_sender_clone()?;

// Serialize data.
let builder = FlatBufferBuilder::new();
let builder = serialize_transaction(builder, transaction_info, slot);

// Push transaction events to queue
let signature = transaction_info.signature.clone();
let signature = *transaction_info.signature;
let cache = self.transaction_event_cache.get_mut(&slot);

let index = transaction_info.index.try_into().unwrap_or(0);
let data = SerializedData {
stream: TRANSACTION_STREAM,
builder,
seen_at: seen.clone(),
seen_at: seen,
};
if let Some(cache) = cache {
if cache.contains_key(&signature) {
Expand Down Expand Up @@ -702,7 +702,7 @@ impl GeyserPlugin for Plerkle<'static> {
let data = SerializedData {
stream: BLOCK_STREAM,
builder,
seen_at: seen.clone(),
seen_at: seen,
};
let _ = sender.send(data);
});
Expand Down
4 changes: 2 additions & 2 deletions plerkle_messenger/src/redis_messenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Messenger for RedisMessenger {
.and_then(|id| id.clone().into_string())
// Using the previous default name when the configuration does not
// specify any particular consumer_id.
.unwrap_or(String::from("ingester"));
.unwrap_or_else(|| String::from("ingester"));

let retries = config
.get("retries")
Expand All @@ -205,7 +205,7 @@ impl Messenger for RedisMessenger {
let consumer_group_name = config
.get("consumer_group_name")
.and_then(|r| r.clone().into_string())
.unwrap_or(GROUP_NAME.to_string());
.unwrap_or_else(|| GROUP_NAME.to_string());

let pipeline_size = config
.get("pipeline_size_bytes")
Expand Down
2 changes: 1 addition & 1 deletion plerkle_serialization/src/account_info_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};

pub enum AccountInfoOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct AccountInfo<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down
4 changes: 2 additions & 2 deletions plerkle_serialization/src/block_info_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'a> flatbuffers::Verifiable for RewardType {

impl flatbuffers::SimpleToVerifyInSlice for RewardType {}
pub enum RewardOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct Reward<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down Expand Up @@ -268,7 +268,7 @@ impl core::fmt::Debug for Reward<'_> {
}
}
pub enum BlockInfoOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct BlockInfo<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down
2 changes: 1 addition & 1 deletion plerkle_serialization/src/common_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use self::flatbuffers::{EndianScalar, Follow};

// struct Pubkey, aligned to 1
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct Pubkey(pub [u8; 32]);
impl Default for Pubkey {
fn default() -> Self {
Expand Down
4 changes: 2 additions & 2 deletions plerkle_serialization/src/compiled_instruction_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};

pub enum CompiledInstructionOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct CompiledInstruction<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down Expand Up @@ -142,7 +142,7 @@ impl core::fmt::Debug for CompiledInstruction<'_> {
}
}
pub enum CompiledInnerInstructionOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct CompiledInnerInstruction<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down
6 changes: 3 additions & 3 deletions plerkle_serialization/src/serializer/serializer_stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::solana_geyser_plugin_interface_shims::{
use crate::{
AccountInfo, AccountInfoArgs, BlockInfo, BlockInfoArgs, CompiledInnerInstruction,
CompiledInnerInstructionArgs, CompiledInnerInstructions, CompiledInnerInstructionsArgs,
CompiledInstruction, CompiledInstructionArgs, InnerInstructions, InnerInstructionsArgs,
CompiledInstruction, CompiledInstructionArgs,
Pubkey as FBPubkey, Pubkey, SlotStatusInfo, SlotStatusInfoArgs, Status as FBSlotStatus,
TransactionInfo, TransactionInfoArgs, TransactionVersion,
};
Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn serialize_transaction<'a>(
account_keys_fb_vec.push(pubkey);
}

if account_keys_fb_vec.len() > 0 {
if !account_keys_fb_vec.is_empty() {
Some(builder.create_vector(&account_keys_fb_vec))
} else {
None
Expand Down Expand Up @@ -298,7 +298,7 @@ pub fn seralize_encoded_transaction_with_status<'a>(
}
}
}
if account_keys_fb_vec.len() > 0 {
if !account_keys_fb_vec.is_empty() {
Some(builder.create_vector(&account_keys_fb_vec))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion plerkle_serialization/src/slot_status_info_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a> flatbuffers::Verifiable for Status {

impl flatbuffers::SimpleToVerifyInSlice for Status {}
pub enum SlotStatusInfoOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct SlotStatusInfo<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down
6 changes: 3 additions & 3 deletions plerkle_serialization/src/transaction_info_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'a> flatbuffers::Verifiable for TransactionVersion {

impl flatbuffers::SimpleToVerifyInSlice for TransactionVersion {}
pub enum TransactionInfoOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct TransactionInfo<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down Expand Up @@ -364,7 +364,7 @@ impl core::fmt::Debug for TransactionInfo<'_> {
}
}
pub enum InnerInstructionsOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct InnerInstructions<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down Expand Up @@ -478,7 +478,7 @@ impl core::fmt::Debug for InnerInstructions<'_> {
}
}
pub enum CompiledInnerInstructionsOffset {}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]

pub struct CompiledInnerInstructions<'a> {
pub _tab: flatbuffers::Table<'a>,
Expand Down

0 comments on commit 317dd0f

Please sign in to comment.