Skip to main content

OracleStorageAdapter

Trait OracleStorageAdapter 

Source
pub trait OracleStorageAdapter: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn state_updates_for_answer(
        &self,
        registration: &FeedRegistration,
        update: &OraclePriceUpdate,
        state: &dyn StateView,
    ) -> Result<Option<Vec<StateUpdate>>, OracleStorageError>;

    // Provided methods
    fn warm_slots_for_registration(
        &self,
        _registration: &FeedRegistration,
    ) -> Vec<(Address, U256)> { ... }
    fn state_updates_for_ocr2_transmission(
        &self,
        _registration: &FeedRegistration,
        _update: &Ocr2TransmissionStorageUpdate,
        _state: &dyn StateView,
    ) -> Result<Option<Vec<StateUpdate>>, OracleStorageError> { ... }
    fn state_updates_for_ocr1_transmission(
        &self,
        _registration: &FeedRegistration,
        _update: &Ocr1TransmissionStorageUpdate,
        _state: &dyn StateView,
    ) -> Result<Option<Vec<StateUpdate>>, OracleStorageError> { ... }
    fn prefers_ocr2_new_transmission(
        &self,
        _registration: &FeedRegistration,
    ) -> bool { ... }
    fn prefers_ocr1_new_transmission(
        &self,
        _registration: &FeedRegistration,
    ) -> bool { ... }
}
Expand description

Adapter that can translate oracle events into direct EVM cache state updates.

Implementations must be deployment-layout specific. Returning Ok(None) means the adapter does not support the feed/update and the caller should try the next adapter or fall back to conservative invalidation.

Required Methods§

Source

fn name(&self) -> &'static str

Stable adapter name for diagnostics.

Source

fn state_updates_for_answer( &self, registration: &FeedRegistration, update: &OraclePriceUpdate, state: &dyn StateView, ) -> Result<Option<Vec<StateUpdate>>, OracleStorageError>

Produce direct state updates for a detected oracle layout.

Provided Methods§

Source

fn warm_slots_for_registration( &self, _registration: &FeedRegistration, ) -> Vec<(Address, U256)>

Storage slots that should be warmed before live event handling.

Direct storage adapters may need a packed word to be present before they can safely emit masked writes. Returning these slots lets callers bulk load them once through evm-fork-cache before entering the reactive loop.

Source

fn state_updates_for_ocr2_transmission( &self, _registration: &FeedRegistration, _update: &Ocr2TransmissionStorageUpdate, _state: &dyn StateView, ) -> Result<Option<Vec<StateUpdate>>, OracleStorageError>

Produce direct state updates for a detected OCR2 NewTransmission event.

Source

fn state_updates_for_ocr1_transmission( &self, _registration: &FeedRegistration, _update: &Ocr1TransmissionStorageUpdate, _state: &dyn StateView, ) -> Result<Option<Vec<StateUpdate>>, OracleStorageError>

Produce direct state updates for a detected OCR1 NewTransmission event.

Source

fn prefers_ocr2_new_transmission( &self, _registration: &FeedRegistration, ) -> bool

Return true when this adapter wants OCR2 NewTransmission as the primary event.

Source

fn prefers_ocr1_new_transmission( &self, _registration: &FeedRegistration, ) -> bool

Return true when this adapter wants OCR1 NewTransmission as the primary event.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§