pub struct ChaincodeStub { /* private fields */ }Expand description
Per-transaction API handed to crate::Chaincode implementations.
Equivalent to shim.ChaincodeStubInterface in fabric-chaincode-go.
Implementations§
Source§impl ChaincodeStub
impl ChaincodeStub
pub fn get_tx_id(&self) -> &str
pub fn get_channel_id(&self) -> &str
Sourcepub fn get_tx_timestamp(&self) -> Result<Timestamp>
pub fn get_tx_timestamp(&self) -> Result<Timestamp>
Timestamp from the transaction’s channel header (client-set, identical on all endorsers — safe to use in chaincode logic).
pub fn get_args(&self) -> &[Vec<u8>]
pub fn get_string_args(&self) -> Vec<String>
Sourcepub fn get_function_and_args(&self) -> (String, Vec<String>)
pub fn get_function_and_args(&self) -> (String, Vec<String>)
First arg as the function name, rest as parameters.
Sourcepub fn get_creator(&self) -> &[u8] ⓘ
pub fn get_creator(&self) -> &[u8] ⓘ
Raw creator bytes (a marshaled msp.SerializedIdentity).
Sourcepub fn get_creator_identity(&self) -> Result<SerializedIdentity>
pub fn get_creator_identity(&self) -> Result<SerializedIdentity>
Creator decoded into MSP ID + identity (certificate) bytes.
pub fn get_transient(&self) -> &HashMap<String, Vec<u8>>
pub fn get_decorations(&self) -> &HashMap<String, Vec<u8>>
pub fn get_signed_proposal(&self) -> Option<&SignedProposal>
Sourcepub async fn get_state(&self, key: &str) -> Result<Vec<u8>>
pub async fn get_state(&self, key: &str) -> Result<Vec<u8>>
Value for key from the world state; empty if the key does not exist
(Fabric does not distinguish missing keys from empty values here).
pub async fn put_state( &self, key: &str, value: impl Into<Vec<u8>>, ) -> Result<()>
pub async fn del_state(&self, key: &str) -> Result<()>
Sourcepub async fn get_state_by_range(
&self,
start_key: &str,
end_key: &str,
) -> Result<StateQueryIterator>
pub async fn get_state_by_range( &self, start_key: &str, end_key: &str, ) -> Result<StateQueryIterator>
Range query over [start_key, end_key); empty strings mean unbounded.
Sourcepub async fn get_state_by_range_with_pagination(
&self,
start_key: &str,
end_key: &str,
page_size: i32,
bookmark: &str,
) -> Result<(StateQueryIterator, QueryResponseMetadata)>
pub async fn get_state_by_range_with_pagination( &self, start_key: &str, end_key: &str, page_size: i32, bookmark: &str, ) -> Result<(StateQueryIterator, QueryResponseMetadata)>
Paginated range query. Only valid in read-only (evaluate) transactions.
Sourcepub async fn get_query_result(&self, query: &str) -> Result<StateQueryIterator>
pub async fn get_query_result(&self, query: &str) -> Result<StateQueryIterator>
Rich query (CouchDB state databases only).
Sourcepub async fn get_history_for_key(
&self,
key: &str,
) -> Result<HistoryQueryIterator>
pub async fn get_history_for_key( &self, key: &str, ) -> Result<HistoryQueryIterator>
History of a key’s values across blocks (peer must have history db enabled).
pub fn create_composite_key( &self, object_type: &str, attributes: &[&str], ) -> Result<String>
pub fn split_composite_key( &self, composite_key: &str, ) -> Result<(String, Vec<String>)>
pub async fn get_state_by_partial_composite_key( &self, object_type: &str, attributes: &[&str], ) -> Result<StateQueryIterator>
pub async fn get_private_data( &self, collection: &str, key: &str, ) -> Result<Vec<u8>>
Sourcepub async fn get_private_data_hash(
&self,
collection: &str,
key: &str,
) -> Result<Vec<u8>>
pub async fn get_private_data_hash( &self, collection: &str, key: &str, ) -> Result<Vec<u8>>
SHA-256 hash of a private value — callable from any org, unlike
get_private_data which requires collection membership.
pub async fn put_private_data( &self, collection: &str, key: &str, value: impl Into<Vec<u8>>, ) -> Result<()>
pub async fn del_private_data(&self, collection: &str, key: &str) -> Result<()>
pub async fn purge_private_data( &self, collection: &str, key: &str, ) -> Result<()>
pub async fn get_private_data_by_range( &self, collection: &str, start_key: &str, end_key: &str, ) -> Result<StateQueryIterator>
Auto Trait Implementations§
impl !RefUnwindSafe for ChaincodeStub
impl !UnwindSafe for ChaincodeStub
impl Freeze for ChaincodeStub
impl Send for ChaincodeStub
impl Sync for ChaincodeStub
impl Unpin for ChaincodeStub
impl UnsafeUnpin for ChaincodeStub
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request