pub struct Fabric { /* private fields */ }Implementations§
Source§impl Fabric
impl Fabric
Sourcepub async fn new(base: &str) -> Result<Self, Error>
pub async fn new(base: &str) -> Result<Self, Error>
Create Fabric by opening RocksDb at base/fabric
pub fn db(&self) -> &RocksDb
pub async fn cleanup(&self)
pub fn insert_entry( &self, hash: &Hash, height: u64, slot: u64, entry_bin: &[u8], seen_millis: u64, ) -> Result<(), Error>
pub fn entries_by_height(&self, height: u64) -> Result<Vec<Vec<u8>>, Error>
pub fn entries_by_slot(&self, slot: u64) -> Result<Vec<Vec<u8>>, Error>
pub fn get_entry_by_hash(&self, hash: &Hash) -> Option<Entry>
pub fn my_attestation_by_entryhash( &self, hash: &[u8], ) -> Result<Option<Attestation>, Error>
pub fn get_or_resign_my_attestation( &self, config: &Config, entry_hash: &Hash, ) -> Result<Option<Attestation>, Error>
pub fn insert_consensus(&self, consensus: &Consensus) -> Result<(), Error>
Sourcepub fn validate_consensus(
&self,
consensus: &Consensus,
) -> Result<BitVec<u8, Msb0>, Error>
pub fn validate_consensus( &self, consensus: &Consensus, ) -> Result<BitVec<u8, Msb0>, Error>
Validate consensus vs chain state:
- Entry must exist and not be in the future vs current temporal_height
- Aggregate signature must verify against the set of trainers unmasked by
mask
On success, sets consensus.score = Some(score) and returns Ok(())
pub fn best_consensus_by_entryhash( &self, trainers: &[PublicKey], entry_hash: &[u8], ) -> Result<(Option<[u8; 32]>, Option<f64>, Option<StoredConsensus>), Error>
Sourcepub fn set_temporal_hash_height(&self, entry: &Entry) -> Result<(), Error>
pub fn set_temporal_hash_height(&self, entry: &Entry) -> Result<(), Error>
Sets temporal entry hash and height
pub fn get_temporal_entry(&self) -> Result<Option<Entry>, Error>
pub fn get_temporal_hash(&self) -> Result<Option<[u8; 32]>, Error>
pub fn get_temporal_height(&self) -> Result<Option<u64>, Error>
Sourcepub fn set_rooted_hash_height(&self, entry: &Entry) -> Result<(), Error>
pub fn set_rooted_hash_height(&self, entry: &Entry) -> Result<(), Error>
Sets rooted entry hash and height
pub fn get_rooted_entry(&self) -> Result<Option<Entry>, Error>
pub fn get_rooted_hash(&self) -> Result<Option<[u8; 32]>, Error>
pub fn get_rooted_height(&self) -> Result<Option<u64>, Error>
pub fn get_temporal_height_or_0(&self) -> u64
pub fn get_chain_epoch_or_0(&self) -> u64
pub fn trainers_for_height(&self, height: u64) -> Option<Vec<PublicKey>>
pub fn get_muts_rev(&self, hash: &Hash) -> Result<Option<Vec<u8>>, Error>
pub fn put_muts_rev(&self, hash: &Hash, data: &[u8]) -> Result<(), Error>
pub fn delete_muts_rev(&self, hash: &Hash) -> Result<(), Error>
pub fn get_muts(&self, hash: &Hash) -> Result<Option<Vec<u8>>, Error>
pub fn put_muts(&self, hash: &Hash, data: &[u8]) -> Result<(), Error>
pub fn put_attestation(&self, hash: &Hash, data: &[u8]) -> Result<(), Error>
pub fn delete_attestation(&self, hash: &Hash) -> Result<(), Error>
pub fn put_entry_seen_time( &self, hash: &Hash, seen_time: u64, ) -> Result<(), Error>
pub fn delete_entry_seen_time(&self, hash: &Hash) -> Result<(), Error>
pub fn get_entry_seen_time(&self, hash: &Hash) -> Result<Option<u64>, Error>
pub fn delete_consensus(&self, hash: &Hash) -> Result<(), Error>
pub fn delete_entry(&self, hash: &Hash) -> Result<(), Error>
pub fn delete_entry_by_height(&self, height_key: &[u8]) -> Result<(), Error>
pub fn delete_entry_by_slot(&self, slot_key: &[u8]) -> Result<(), Error>
pub fn put_tx_metadata(&self, key: &[u8], tx: &[u8]) -> Result<(), Error>
pub fn delete_tx_metadata(&self, hash: &Hash) -> Result<(), Error>
pub fn put_tx_account_nonce( &self, key: &[u8], tx_hash: &Hash, ) -> Result<(), Error>
pub fn delete_tx_account_nonce(&self, key: &[u8]) -> Result<(), Error>
pub fn put_entry_raw(&self, hash: &Hash, data: &[u8]) -> Result<(), Error>
pub fn get_entry_raw(&self, hash: &Hash) -> Result<Option<Vec<u8>>, Error>
Sourcepub fn are_we_trainer(&self, config: &Config) -> bool
pub fn are_we_trainer(&self, config: &Config) -> bool
Return true if our trainer_pk is included in trainers_for_height(chain_height()+1)
Sourcepub fn get_trainer_for_slot(&self, height: u64, slot: u64) -> Option<PublicKey>
pub fn get_trainer_for_slot(&self, height: u64, slot: u64) -> Option<PublicKey>
Select trainer for a slot from the roster for the corresponding height
pub fn get_trainer_for_current_slot(&self) -> Option<PublicKey>
pub fn get_trainer_for_next_slot(&self) -> Option<PublicKey>
pub fn are_we_trainer_for_next_slot(&self, config: &Config) -> bool
pub fn is_in_chain(&self, target_hash: &Hash) -> bool
Sourcepub fn validate_entry_slot_trainer(&self, entry: &Entry, prev_slot: u64) -> bool
pub fn validate_entry_slot_trainer(&self, entry: &Entry, prev_slot: u64) -> bool
Check if entry is in its designated slot
pub fn start_proc_consensus(&self)
pub fn stop_proc_consensus(&self)
pub fn is_proc_consensus(&self) -> bool
Sourcepub fn chain_nonce(&self, public_key: &[u8]) -> Option<u64>
pub fn chain_nonce(&self, public_key: &[u8]) -> Option<u64>
Get the chain nonce for a given public key
Sourcepub fn chain_balance(&self, public_key: &[u8]) -> i128
pub fn chain_balance(&self, public_key: &[u8]) -> i128
Get the chain balance for a given public key (native AMA token)
Sourcepub fn chain_diff_bits(&self) -> u64
pub fn chain_diff_bits(&self) -> u64
Get the chain difficulty bits
Sourcepub fn chain_segment_vr_hash(&self) -> Option<Vec<u8>>
pub fn chain_segment_vr_hash(&self) -> Option<Vec<u8>>
Get the chain segment VR hash
Sourcepub fn chain_balance_symbol(&self, public_key: &[u8], symbol: &[u8]) -> i128
pub fn chain_balance_symbol(&self, public_key: &[u8], symbol: &[u8]) -> i128
Get balance for a specific account and symbol from the chain state
Sourcepub fn chain_total_sols(&self) -> u64
pub fn chain_total_sols(&self) -> u64
Get the total number of solutions from the chain state
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Fabric
impl !RefUnwindSafe for Fabric
impl Send for Fabric
impl Sync for Fabric
impl Unpin for Fabric
impl !UnwindSafe for Fabric
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.