Expand description
Solana transaction indexing entity
§Examples
use solana_indexer::{Indexer, CallbackResult, Instruction, IndexerEngine, InstructionCallback, InstructionExecutor};
use async_trait::async_trait;
#[derive(Default)]
pub struct ProcessingStruct;
#[async_trait]
impl InstructionCallback for ProcessingStruct {
async fn process_instruction(&mut self, instruction: &Instruction) -> CallbackResult<()> {
println!("Instruction program id: {}", instruction.program_id);
Ok(())
}
}
#[tokio::main]
async fn main() {
let mut solana_indexer = Indexer::build().await.unwrap();
let processor = ProcessingStruct::default();
solana_indexer.set_executor(InstructionExecutor::from_executor(processor));
solana_indexer.start_indexing().await.unwrap();
}
§Panics
Library panics if it fails to connect to database.
§Environment variables
-
INDEXER_CFG
Path to configuration file. Default is
configuration.yaml
. -
INDEXER_MIGRATE
Flag to perform database migration on startup. Acceptable true values:
1
,true
,y
. Everything else is false. This variable overridesindexer_settings.migrate
setting in the configuration file. Default is false.
§Configuration
Indexer is configured via a configuration file specified by INDEXER_CFG
environment variable.
Please refer to Configuration schema for details on available settings.
Structs§
- Configuration
- Configurations for the indexer engine
- Fetching
Settings - Settings struct dedicated to fetching data from Solana RPC
- Indexer
- Indexer state
- Indexer
Report - A structure holding the indexer monitoring data
- Indexer
Settings - A structure for a general indexer configuration
- Instruction
- Struct representing an Instruction entity from a Solana transaction
Enums§
- Callback
Error - An error that was caused by a library callback function
- Indexer
Error - Collection of errors that are emitted during indexing process
- Instruction
Executor - An entity that is called on every indexed instruction consequentially
Traits§
Functions§
Type Aliases§
- Callback
Result - Result of the callback execution
- Indexer
State - Indexer state for health reporting
- Indexing
Result - Result of indexing process
- Request
Metrics - Request counting metrics