pub struct InMemoryDbSync {
    pub(crate) transactions: HashMap<u32, Vec<Transaction>>,
    pub(crate) blocks: Vec<Block>,
    stakes: HashMap<String, BigNum>,
    settings: Settings,
}
Expand description

Mock of real cardano db sync. At this moment we only stores transactions metadata as the only purpose of existance for this struct is to provide catalyst voting registrations Struct can be persisted and restored from json file using serde_json.

Fields§

§transactions: HashMap<u32, Vec<Transaction>>§blocks: Vec<Block>§stakes: HashMap<String, BigNum>§settings: Settings

Implementations§

source§

impl InMemoryDbSync

source

pub fn from_block0(block0: &Block0) -> Self

Creates new instance out of block0

source

pub fn empty() -> Self

Create an empty instance

source

pub fn connect_to_node(self, node: &mut InMemoryNode) -> SharedInMemoryDbSync

Connects to Cardano mock node using simple observer/observable mechanism

Panics

On accessing db sync state

source

pub fn try_as_string(&self) -> Result<String, Error>

Retrieves db sync content as string

Errors

On deserialization issues

source

pub fn on_block_propagation(&mut self, block: &Block)

Accept new block

Panics

On integer overflow

source

pub fn transaction_by_hash( &self, hash: &str ) -> Vec<(Option<&Block>, &Transaction)>

Query transaction by it’s hash representation

source

pub fn query_all_registration_transactions( &self ) -> Vec<GeneralTransactionMetadata>

Gets all transactions metadata without bounds

source

pub fn metadata(&self) -> HashMap<u32, Vec<GeneralTransactionMetadata>>

Gets all metadata per block number

source

pub fn query_voting_transactions_with_bounds( &self, lower: u64, upper: u64 ) -> HashMap<u32, Vec<GeneralTransactionMetadata>>

Gets all transactions metadata with slot_no upper and lower bounds

source

pub fn settings(&self) -> &Settings

gets reference to db sync connection settings

source

pub fn stakes(&self) -> &HashMap<String, BigNum>

gets all known to dbsync wallet ada distribution

source

pub fn persist(&self, path: impl AsRef<Path>) -> Result<(), Error>

Persists current state of db sync

Errors

If cannot create file or cannot serialize to json

source

pub fn restore(path: impl AsRef<Path>) -> Result<Self, Error>

Restores current state of db sync from json file

Errors

If file cannot be opened or cannot deserialize from json

Trait Implementations§

source§

impl Debug for InMemoryDbSync

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for InMemoryDbSync

source§

fn default() -> InMemoryDbSync

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for InMemoryDbSync

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for InMemoryDbSync

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,