Struct mainnet_lib::InMemoryDbSync
source · 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
impl InMemoryDbSync
sourcepub fn from_block0(block0: &Block0) -> Self
pub fn from_block0(block0: &Block0) -> Self
Creates new instance out of block0
sourcepub fn connect_to_node(self, node: &mut InMemoryNode) -> SharedInMemoryDbSync
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
sourcepub fn try_as_string(&self) -> Result<String, Error>
pub fn try_as_string(&self) -> Result<String, Error>
sourcepub fn on_block_propagation(&mut self, block: &Block)
pub fn on_block_propagation(&mut self, block: &Block)
sourcepub fn transaction_by_hash(
&self,
hash: &str
) -> Vec<(Option<&Block>, &Transaction)>
pub fn transaction_by_hash( &self, hash: &str ) -> Vec<(Option<&Block>, &Transaction)>
Query transaction by it’s hash representation
sourcepub fn query_all_registration_transactions(
&self
) -> Vec<GeneralTransactionMetadata>
pub fn query_all_registration_transactions( &self ) -> Vec<GeneralTransactionMetadata>
Gets all transactions metadata without bounds
sourcepub fn metadata(&self) -> HashMap<u32, Vec<GeneralTransactionMetadata>>
pub fn metadata(&self) -> HashMap<u32, Vec<GeneralTransactionMetadata>>
Gets all metadata per block number
sourcepub fn query_voting_transactions_with_bounds(
&self,
lower: u64,
upper: u64
) -> HashMap<u32, Vec<GeneralTransactionMetadata>>
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
sourcepub fn stakes(&self) -> &HashMap<String, BigNum>
pub fn stakes(&self) -> &HashMap<String, BigNum>
gets all known to dbsync wallet ada distribution
Trait Implementations§
source§impl Debug for InMemoryDbSync
impl Debug for InMemoryDbSync
source§impl Default for InMemoryDbSync
impl Default for InMemoryDbSync
source§fn default() -> InMemoryDbSync
fn default() -> InMemoryDbSync
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for InMemoryDbSync
impl<'de> Deserialize<'de> for InMemoryDbSync
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for InMemoryDbSync
impl Send for InMemoryDbSync
impl Sync for InMemoryDbSync
impl Unpin for InMemoryDbSync
impl UnwindSafe for InMemoryDbSync
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request