[][src]Enum exonum::runtime::Caller

#[non_exhaustive]pub enum Caller {
    Transaction {
        author: PublicKey,
    },
    Service {
        instance_id: InstanceId,
    },
    Blockchain,
}

The authorization information for a service call.

Caller provides authorization details about the call. The called service may use Caller to decide whether to proceed with the processing, or to return an error because the caller has insufficient privileges. In some other cases (e.g., crypto-tokens), Caller may be used to get or modify information about the caller in the blockchain state (e.g., the current token balance).

Authorization info is not purely determined by the call stack. While outermost transactions calls always have Transaction auth, services may make internal calls, which either inherit the parent authorization or authorize a child call in their name (Service auth). This is decided by the service; both kinds of auth may make sense depending on the use case. Inherited auth makes sense for "middleware" (e.g., batched calls), while service auth makes sense for stateful authorization (e.g., multi-signatures).

Note that Caller has a forward-compatible uniform representation obtained via address() method. Services may use this representation to compare or index callers without the necessity to care about all possible kinds of authorization supported by the framework.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Transaction

A usual transaction from the Exonum client authorized by its key pair.

Fields of Transaction

author: PublicKey

Public key of the user who signed this transaction.

Service

The call is invoked with the authority of a blockchain service.

Fields of Service

instance_id: InstanceId

Identifier of the service instance which invoked the call.

Blockchain

The call is invoked by one of the blockchain lifecycle events.

This kind of authorization is used for before_transactions / after_transactions calls to the service instances, and for initialization of the built-in services.

Methods

impl Caller[src]

pub fn author(&self) -> Option<PublicKey>[src]

Returns the author's public key, if it exists.

pub fn as_service(&self) -> Option<InstanceId>[src]

Tries to reinterpret the caller as a service.

pub fn as_supervisor(&self) -> Option<()>[src]

Verifies that the caller of this method is a supervisor service.

pub fn address(&self) -> CallerAddress[src]

Returns a uniform, forward-compatible presentation of the Caller that can be used as the account address. Different addresses are guaranteed to correspond to different Callers.

Trait Implementations

impl BinaryValue for Caller[src]

impl Clone for Caller[src]

impl Debug for Caller[src]

impl ObjectHash for Caller[src]

impl PartialEq<Caller> for Caller[src]

impl ProtobufConvert for Caller[src]

type ProtoStruct = Caller

Type generated from the Protobuf definition.

impl StructuralPartialEq for Caller[src]

Auto Trait Implementations

impl RefUnwindSafe for Caller

impl Send for Caller

impl Sync for Caller

impl Unpin for Caller

impl UnwindSafe for Caller

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,