Skip to content

Commit

Permalink
Merge pull request #41 from metaplex-foundation/feat/rpc-interface
Browse files Browse the repository at this point in the history
feat: solana-rpc interfaces
  • Loading branch information
StanChe authored Jan 9, 2024
2 parents fa0b369 + 459c416 commit dac41db
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

8 changes: 8 additions & 0 deletions entities/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,11 @@ impl<T> Updated<T> {
}
}
}

#[derive(Clone)]
pub struct BufferedTransaction {
pub transaction: Vec<u8>,
// this flag tells if the transaction should be mapped from extrnode flatbuffer to mplx flatbuffer structure
// data from geyser should be mapped and data from BG should not
pub map_flatbuffer: bool,
}
1 change: 1 addition & 0 deletions interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ futures="0.3.29"
mockall = "0.12.0"
thiserror = "1.0.51"
entities = { path = "../entities" }
solana-sdk = "~1.14"
1 change: 1 addition & 0 deletions interface/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod asset_streaming_and_discovery;
pub mod error;
pub mod solana_rpc;
31 changes: 31 additions & 0 deletions interface/src/solana_rpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::error::UsecaseError;
use async_trait::async_trait;
use entities::models::BufferedTransaction;
use mockall::automock;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Signature;

#[allow(dead_code)]
pub struct SignatureWithSlot {
pub signature: Signature,
pub slot: u64,
}

#[automock]
#[async_trait]
pub trait GetSignaturesByAddress: Send + Sync {
async fn get_signatures_by_address(
&self,
signature: Signature,
program_id: Pubkey,
) -> Result<Vec<SignatureWithSlot>, UsecaseError>;
}

#[automock]
#[async_trait]
pub trait GetTransactionsBySignatures: Send + Sync {
async fn get_txs_by_signatures(
&self,
signatures: Vec<Signature>,
) -> Result<Vec<BufferedTransaction>, UsecaseError>;
}
3 changes: 2 additions & 1 deletion nft_ingester/src/bin/ingester/backfiller.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use entities::models::BufferedTransaction;
use flatbuffers::FlatBufferBuilder;
use log::{debug, error, info, warn};
use metrics_utils::{BackfillerMetricsConfig, MetricStatus};
use nft_ingester::buffer::{Buffer, BufferedTransaction};
use nft_ingester::buffer::Buffer;
use nft_ingester::config::BackfillerConfig;
use nft_ingester::error::IngesterError;
use plerkle_serialization::serializer::seralize_encoded_transaction_with_status;
Expand Down
9 changes: 1 addition & 8 deletions nft_ingester/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::collections::VecDeque;
use std::sync::Arc;

use entities::models::BufferedTransaction;
use tokio::sync::Mutex;

use metrics_utils::IngesterMetricsConfig;
Expand All @@ -22,14 +23,6 @@ pub struct Buffer {
pub json_tasks: Mutex<VecDeque<Task>>,
}

#[derive(Clone)]
pub struct BufferedTransaction {
pub transaction: Vec<u8>,
// this flag tells if the transaction should be mapped from extrnode flatbuffer to mplx flatbuffer structure
// data from geyser should be mapped and data from BG should not
pub map_flatbuffer: bool,
}

impl Buffer {
pub fn new() -> Self {
Self {
Expand Down
3 changes: 2 additions & 1 deletion nft_ingester/src/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use blockbuster::{
},
};
use chrono::Utc;
use entities::models::BufferedTransaction;
use flatbuffers::FlatBufferBuilder;
use log::{error, warn};
use plerkle_serialization::AccountInfo;
Expand All @@ -18,7 +19,7 @@ use utils::flatbuffer::account_data_generated::account_data::root_as_account_dat

use rocks_db::columns::{Mint, TokenAccount};

use crate::buffer::{Buffer, BufferedTransaction};
use crate::buffer::Buffer;
use crate::error::IngesterError;
use crate::error::IngesterError::MissingFlatbuffersFieldError;
use crate::mplx_updates_processor::MetadataInfo;
Expand Down

0 comments on commit dac41db

Please sign in to comment.