[−][src]Struct fabric_contract::contract::Ledger
Ledger representing high level concept of the Fabric Blockchain network
Provides the access points for
- getting access to data in both world state and peer's private collections
- invoking chaincode on this and other networks
When a transaction is invoked, it takes place under a 'transactional context' This context can be queried to provide the current transaction id, and information about the identity requesting the transaction.
All operations need to be done under this transactional context, therefore the context needs to be passed to obtain the Ledger instance
Example
use fabric_contract::contract::*; pub fn asset_exists(my_assset_id: String) -> Result<bool,String> { let ledger = Ledger::access_ledger(); let world = ledger.get_collection(CollectionName::World); Ok(world.state_exists(&my_assset_id)) }
Implementations
impl Ledger
[src]
pub fn access_ledger() -> Ledger
[src]
Get the Ledger based on the current transactional context
The Tranasctional Context is available via the Transaction API
pub fn get_collection(&self, name: CollectionName) -> Collection
[src]
Return the collection based on the name
The collection provides access to the put & get Fabric semantics of the underlying world state, or private data that is specified by the Collection name.
Example
use fabric_contract::contract::*; let ledger = Ledger::access_ledger(); // get the collectin that is backed by the World State let world = ledger.get_collection(CollectionName::World); // get the collection that is backed by the Organization's Implicity Private Data Collection let orgs_collection = ledger.get_collection(CollectionName::Organization(String::from("org1"))); // get the collection that is backed by the named Private Data Collection let private_collection = ledger.get_collection(CollectionName::Private(String::from("my_private_details")));
Auto Trait Implementations
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnwindSafe for Ledger
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,