Crate solana_indexer

Source
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 overrides indexer_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
FetchingSettings
Settings struct dedicated to fetching data from Solana RPC
Indexer
Indexer state
IndexerReport
A structure holding the indexer monitoring data
IndexerSettings
A structure for a general indexer configuration
Instruction
Struct representing an Instruction entity from a Solana transaction

Enums§

CallbackError
An error that was caused by a library callback function
IndexerError
Collection of errors that are emitted during indexing process
InstructionExecutor
An entity that is called on every indexed instruction consequentially

Traits§

IndexerEngine
InstructionCallback

Functions§

get_configuration

Type Aliases§

CallbackResult
Result of the callback execution
IndexerState
Indexer state for health reporting
IndexingResult
Result of indexing process
RequestMetrics
Request counting metrics