Skip to main content

ChaincodeStub

Struct ChaincodeStub 

Source
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

Source

pub fn get_tx_id(&self) -> &str

Source

pub fn get_channel_id(&self) -> &str

Source

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).

Source

pub fn get_args(&self) -> &[Vec<u8>]

Source

pub fn get_string_args(&self) -> Vec<String>

Source

pub fn get_function_and_args(&self) -> (String, Vec<String>)

First arg as the function name, rest as parameters.

Source

pub fn get_creator(&self) -> &[u8] ⓘ

Raw creator bytes (a marshaled msp.SerializedIdentity).

Source

pub fn get_creator_identity(&self) -> Result<SerializedIdentity>

Creator decoded into MSP ID + identity (certificate) bytes.

Source

pub fn get_transient(&self) -> &HashMap<String, Vec<u8>>

Source

pub fn get_decorations(&self) -> &HashMap<String, Vec<u8>>

Source

pub fn get_signed_proposal(&self) -> Option<&SignedProposal>

Source

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).

Source

pub async fn put_state( &self, key: &str, value: impl Into<Vec<u8>>, ) -> Result<()>

Source

pub async fn del_state(&self, key: &str) -> Result<()>

Source

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.

Source

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.

Source

pub async fn get_query_result(&self, query: &str) -> Result<StateQueryIterator>

Rich query (CouchDB state databases only).

Source

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).

Source

pub fn create_composite_key( &self, object_type: &str, attributes: &[&str], ) -> Result<String>

Source

pub fn split_composite_key( &self, composite_key: &str, ) -> Result<(String, Vec<String>)>

Source

pub async fn get_state_by_partial_composite_key( &self, object_type: &str, attributes: &[&str], ) -> Result<StateQueryIterator>

Source

pub async fn get_private_data( &self, collection: &str, key: &str, ) -> Result<Vec<u8>>

Source

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.

Source

pub async fn put_private_data( &self, collection: &str, key: &str, value: impl Into<Vec<u8>>, ) -> Result<()>

Source

pub async fn del_private_data(&self, collection: &str, key: &str) -> Result<()>

Source

pub async fn purge_private_data( &self, collection: &str, key: &str, ) -> Result<()>

Source

pub async fn get_private_data_by_range( &self, collection: &str, start_key: &str, end_key: &str, ) -> Result<StateQueryIterator>

Source

pub fn set_event(&self, name: &str, payload: impl Into<Vec<u8>>) -> Result<()>

Set the single chaincode event emitted with this transaction. A second call replaces the first (Go shim semantics).

Source

pub async fn invoke_chaincode( &self, chaincode_name: &str, args: Vec<Vec<u8>>, channel: &str, ) -> Result<Response>

Invoke another chaincode on this peer. Same-channel calls join this transaction’s read/write set; cross-channel calls are read-only.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T> Instrument for T

Source§

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

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

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 T
where 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
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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