diff --git a/geyser-plugin-runner/src/block.rs b/geyser-plugin-runner/src/block.rs index e435ff07..107df5cb 100644 --- a/geyser-plugin-runner/src/block.rs +++ b/geyser-plugin-runner/src/block.rs @@ -1,6 +1,4 @@ use cid::Cid; -use serde_cbor; -use serde_json; use std::error::Error; @@ -63,9 +61,9 @@ impl Block { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(kind)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - block.kind = kind as u64; + block.kind = *kind as u64; - if kind as u64 != Kind::Block as u64 { + if *kind as u64 != Kind::Block as u64 { return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, std::format!( @@ -77,7 +75,7 @@ impl Block { } } if let Some(serde_cbor::Value::Integer(slot)) = array.get(1) { - block.slot = slot as u64; + block.slot = *slot as u64; } if let Some(serde_cbor::Value::Array(shredding)) = &array.get(2) { @@ -1127,10 +1125,10 @@ impl Shredding { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(entry_end_idx)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - shredding.entry_end_idx = entry_end_idx as i64; + shredding.entry_end_idx = *entry_end_idx as i64; } if let Some(serde_cbor::Value::Integer(shred_end_idx)) = array.get(1) { - shredding.shred_end_idx = shred_end_idx as i64; + shredding.shred_end_idx = *shred_end_idx as i64; } } return shredding; @@ -1197,13 +1195,13 @@ impl SlotMeta { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(parent_slot)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - slot_meta.parent_slot = parent_slot as u64; + slot_meta.parent_slot = *parent_slot as u64; } if let Some(serde_cbor::Value::Integer(blocktime)) = array.get(1) { - slot_meta.blocktime = blocktime as u64; + slot_meta.blocktime = *blocktime as u64; } if let Some(serde_cbor::Value::Integer(block_height)) = array.get(2) { - slot_meta.block_height = Some(block_height as u64); + slot_meta.block_height = Some(*block_height as u64); } } return slot_meta; diff --git a/geyser-plugin-runner/src/dataframe.rs b/geyser-plugin-runner/src/dataframe.rs index daa3cf1b..49cf98a9 100644 --- a/geyser-plugin-runner/src/dataframe.rs +++ b/geyser-plugin-runner/src/dataframe.rs @@ -1,6 +1,4 @@ use cid::Cid; -use serde_cbor; -use serde_json; use std::error::Error; @@ -48,9 +46,9 @@ impl DataFrame { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(kind)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - data_frame.kind = kind as u64; + data_frame.kind = *kind as u64; - if kind as u64 != Kind::DataFrame as u64 { + if *kind as u64 != Kind::DataFrame as u64 { return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, std::format!( @@ -62,13 +60,13 @@ impl DataFrame { } } if let Some(serde_cbor::Value::Integer(hash)) = array.get(1) { - data_frame.hash = Some(hash as u64); + data_frame.hash = Some(*hash as u64); } if let Some(serde_cbor::Value::Integer(index)) = array.get(2) { - data_frame.index = Some(index as u64); + data_frame.index = Some(*index as u64); } if let Some(serde_cbor::Value::Integer(total)) = array.get(3) { - data_frame.total = Some(total as u64); + data_frame.total = Some(*total as u64); } if let Some(serde_cbor::Value::Bytes(data)) = &array.get(4) { data_frame.data = Buffer::from_vec(data.clone()); diff --git a/geyser-plugin-runner/src/entry.rs b/geyser-plugin-runner/src/entry.rs index d6a43d6d..a69af210 100644 --- a/geyser-plugin-runner/src/entry.rs +++ b/geyser-plugin-runner/src/entry.rs @@ -1,6 +1,4 @@ use cid::Cid; -use serde_cbor; -use serde_json; use std::error::Error; @@ -45,9 +43,9 @@ impl Entry { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(kind)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - entry.kind = kind as u64; + entry.kind = *kind as u64; - if kind as u64 != Kind::Entry as u64 { + if *kind as u64 != Kind::Entry as u64 { return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, std::format!( @@ -59,7 +57,7 @@ impl Entry { } } if let Some(serde_cbor::Value::Integer(num_hashes)) = array.get(1) { - entry.num_hashes = num_hashes as u64; + entry.num_hashes = *num_hashes as u64; } if let Some(serde_cbor::Value::Bytes(hash)) = &array.get(2) { entry.hash = Hash(hash.to_vec()); diff --git a/geyser-plugin-runner/src/epoch.rs b/geyser-plugin-runner/src/epoch.rs index f1bd04f9..6be7e80d 100644 --- a/geyser-plugin-runner/src/epoch.rs +++ b/geyser-plugin-runner/src/epoch.rs @@ -1,7 +1,4 @@ use cid::Cid; -use serde_cbor; -use serde_json; - use std::error::Error; use std::vec::Vec; @@ -39,9 +36,9 @@ impl Epoch { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(kind)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - epoch.kind = kind as u64; + epoch.kind = *kind as u64; - if kind as u64 != Kind::Epoch as u64 { + if *kind as u64 != Kind::Epoch as u64 { return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, std::format!( @@ -53,7 +50,7 @@ impl Epoch { } } if let Some(serde_cbor::Value::Integer(num)) = array.get(1) { - epoch.epoch = num as u64; + epoch.epoch = *num as u64; } if let Some(serde_cbor::Value::Array(subsets)) = &array.get(2) { diff --git a/geyser-plugin-runner/src/main.rs b/geyser-plugin-runner/src/main.rs index 0d5e39fc..73aa466d 100644 --- a/geyser-plugin-runner/src/main.rs +++ b/geyser-plugin-runner/src/main.rs @@ -1,6 +1,5 @@ #![recursion_limit = "512"] -use solana_storage_proto; use std::env::args; use std::error::Error; diff --git a/geyser-plugin-runner/src/node.rs b/geyser-plugin-runner/src/node.rs index e0765cff..534894bd 100644 --- a/geyser-plugin-runner/src/node.rs +++ b/geyser-plugin-runner/src/node.rs @@ -1,11 +1,7 @@ -use bytes::Buf; use cid::Cid; use core::hash::Hasher; use crc::{Crc, CRC_64_GO_ISO}; use fnv::FnvHasher; -use multihash; - -use serde_cbor; use std::error::Error; use std::fs::File; @@ -296,7 +292,7 @@ pub fn parse_any_from_cbordata(data: Vec) -> Result> { // based on the kind, we can decode the rest of the data match kind { - kind => match Kind::from_u64(kind as u64).unwrap() { + kind => match Kind::from_u64(*kind as u64).unwrap() { Kind::Transaction => { let transaction = transaction::Transaction::from_cbor(cloned_data)?; return Ok(Node::Transaction(transaction)); diff --git a/geyser-plugin-runner/src/rewards.rs b/geyser-plugin-runner/src/rewards.rs index 4f7f0958..cfb2c8bb 100644 --- a/geyser-plugin-runner/src/rewards.rs +++ b/geyser-plugin-runner/src/rewards.rs @@ -1,5 +1,3 @@ -use serde_cbor; -use serde_json; use std::error::Error; use std::vec::Vec; @@ -45,9 +43,9 @@ impl Rewards { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(kind)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - rewards.kind = kind as u64; + rewards.kind = *kind as u64; - if kind as u64 != Kind::Rewards as u64 { + if *kind as u64 != Kind::Rewards as u64 { return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, std::format!( @@ -59,7 +57,7 @@ impl Rewards { } } if let Some(serde_cbor::Value::Integer(slot)) = array.get(1) { - rewards.slot = slot as u64; + rewards.slot = *slot as u64; } if let Some(serde_cbor::Value::Array(data)) = &array.get(2) { diff --git a/geyser-plugin-runner/src/subset.rs b/geyser-plugin-runner/src/subset.rs index bf3384c8..d25ea342 100644 --- a/geyser-plugin-runner/src/subset.rs +++ b/geyser-plugin-runner/src/subset.rs @@ -1,6 +1,4 @@ use cid::Cid; -use serde_cbor; -use serde_json; use std::error::Error; @@ -42,9 +40,9 @@ impl Subset { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(kind)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - subset.kind = kind as u64; + subset.kind = *kind as u64; - if kind as u64 != Kind::Subset as u64 { + if *kind as u64 != Kind::Subset as u64 { return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, std::format!( @@ -56,10 +54,10 @@ impl Subset { } } if let Some(serde_cbor::Value::Integer(first)) = array.get(1) { - subset.first = first as u64; + subset.first = *first as u64; } if let Some(serde_cbor::Value::Integer(last)) = array.get(2) { - subset.last = last as u64; + subset.last = *last as u64; } if let Some(serde_cbor::Value::Array(blocks)) = &array.get(3) { diff --git a/geyser-plugin-runner/src/transaction.rs b/geyser-plugin-runner/src/transaction.rs index 6de5f204..b9bc0e17 100644 --- a/geyser-plugin-runner/src/transaction.rs +++ b/geyser-plugin-runner/src/transaction.rs @@ -1,7 +1,4 @@ use bincode::deserialize; -use serde_cbor; -use serde_json; -use solana_sdk; use std::error::Error; use std::vec::Vec; @@ -60,9 +57,9 @@ impl Transaction { // println!("Kind: {:?}", array[0]); if let Some(serde_cbor::Value::Integer(kind)) = array.get(0) { // println!("Kind: {:?}", Kind::from_u64(kind as u64).unwrap().to_string()); - transaction.kind = kind as u64; + transaction.kind = *kind as u64; - if kind as u64 != Kind::Transaction as u64 { + if *kind as u64 != Kind::Transaction as u64 { return Err(Box::new(std::io::Error::new( std::io::ErrorKind::Other, std::format!( @@ -84,11 +81,11 @@ impl Transaction { } if let Some(serde_cbor::Value::Integer(slot)) = array.get(3) { - transaction.slot = slot as u64; + transaction.slot = *slot as u64; } if let Some(serde_cbor::Value::Integer(index)) = array.get(4) { - transaction.index = Some(index as u64); + transaction.index = Some(*index as u64); } } return Ok(transaction); diff --git a/geyser-plugin-runner/src/utils.rs b/geyser-plugin-runner/src/utils.rs index dd6589af..df6c8c44 100644 --- a/geyser-plugin-runner/src/utils.rs +++ b/geyser-plugin-runner/src/utils.rs @@ -1,5 +1,7 @@ use std::error::Error; +use base64::engine::general_purpose::STANDARD; +use base64::engine::Engine; use std::io::{self, Read}; use std::vec::Vec; @@ -150,7 +152,7 @@ impl std::fmt::Debug for Buffer { // base64 impl std::fmt::Display for Buffer { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - base64::encode(&self.0).fmt(f) + STANDARD.encode(&self.0).fmt(f) } } @@ -159,7 +161,7 @@ impl serde::Serialize for Buffer { where S: serde::ser::Serializer, { - base64::encode(&self.0).serialize(serializer) + STANDARD.encode(&self.0).serialize(serializer) } } @@ -169,7 +171,7 @@ impl<'de> serde::Deserialize<'de> for Buffer { D: serde::de::Deserializer<'de>, { let base64 = String::deserialize(deserializer)?; - Ok(Buffer(base64::decode(&base64).unwrap())) + Ok(Buffer(STANDARD.decode(&base64).unwrap())) } }