Skip to main content

ScanClient

Struct ScanClient 

Source
pub struct ScanClient { /* private fields */ }
Expand description

A client for one Scan, or for one validator’s scan-proxy.

Implementations§

Source§

impl ScanClient

Source

pub fn new(base_url: &str) -> Result<Self>

A client for the Scan served at base_url, which ends in /api/scan.

§Errors

Error::InvalidRequest if base_url is not a URL, or an HTTP client cannot be built.

Source

pub fn with_http_client(base_url: &str, http: Client) -> Result<Self>

new with an HTTP client the caller has configured: timeouts, proxies, a custom TLS root store. Configure it with reqwest::redirect::Policy::none(), as new does: what Scan answers goes into commands the caller signs, so it must come from the Scan the caller named and not from wherever a 3xx points.

§Errors

Error::InvalidRequest if base_url is not a URL.

Source

pub fn through_validator(base_url: &str) -> Result<Self>

A client for the scan-proxy of the validator served at base_url, which ends in /api/validator.

The proxy authenticates every request: give the client a token with with_token or with_token_source.

§Errors

Error::InvalidRequest if base_url is not a URL, or an HTTP client cannot be built.

Source

pub fn through_validator_with_http_client( base_url: &str, http: Client, ) -> Result<Self>

through_validator with an HTTP client the caller has configured. See with_http_client.

§Errors

Error::InvalidRequest if base_url is not a URL.

Source

pub fn with_token(self, token: impl Into<String>) -> Self

Send a bearer token with every request. A validator’s scan-proxy requires one; a Scan does not.

Source

pub fn with_token_source(self, source: impl TokenSource + 'static) -> Self

Send a bearer token from a source that refreshes it, such as canton_auth::TokenProvider.

Source

pub fn with_internal_endpoints(self) -> Self

Allow the calls that reach endpoints Splice tags internal when the client asks a Scan directly: featured_app_right and transfer_preapproval_by_party, and the lighter of the two ways to read amulet_rules.

Splice may change an internal endpoint in any release, and these methods change with it. Through a validator’s scan-proxy the same calls are part of the proxy’s API, and this is not needed.

Source

pub async fn dso_party_id(&self) -> Result<String>

The party that represents the DSO.

§Errors

As any HTTP call, plus Error::UnexpectedResponse on a body that is not what Splice specifies.

Source

pub async fn dso(&self) -> Result<DsoInfo>

The DSO: its party, its voting threshold, and the contracts that hold its rules.

Asked at /v1/dso, which Splice 0.10 added. A Scan or a validator older than that answers 404 there and serves /v0/dso, which carries the same contracts, so that is asked next.

§Errors

As dso_party_id.

Source

pub async fn scans(&self) -> Result<Vec<SynchronizerScans>>

Every Super Validator’s Scan, per synchronizer.

§Errors

As dso_party_id, and Error::InvalidRequest through a validator’s scan-proxy, which does not serve it.

Source

pub async fn open_and_issuing_mining_rounds(&self) -> Result<MiningRounds>

The open and the issuing mining rounds.

§Errors

As dso_party_id.

Source

pub async fn latest_open_mining_round(&self) -> Result<ContractWithState>

The open mining round to pass to a choice now: see MiningRounds::latest_open.

§Errors

As open_and_issuing_mining_rounds and MiningRounds::latest_open.

Source

pub async fn closed_rounds(&self) -> Result<Vec<ScanContract>>

The closed mining rounds that have not been archived yet.

§Errors

As scans.

Source

pub async fn amulet_rules(&self) -> Result<ContractWithState>

The AmuletRules contract.

A Scan publishes it twice: with the rest of the DSO’s contracts in the external API (dso), and alone at an internal endpoint. The external one is asked, unless the client opted into the internal endpoints (with_internal_endpoints), whose reply is the one contract. A validator’s scan-proxy serves it as part of its own API.

§Errors

As dso_party_id.

Source

pub async fn featured_app_right( &self, provider: &str, ) -> Result<Option<ScanContract>>

A provider’s FeaturedAppRight contract, or None if the provider is not a featured application.

The contract comes without a synchronizer: disclose it on the one the Amulet rules are on (ScanContract::disclosed).

On a Scan this is an internal endpoint: see with_internal_endpoints.

§Errors

As dso_party_id, and Error::InvalidRequest on a Scan without the opt-in.

Source

pub async fn transfer_preapproval_by_party( &self, party: &str, ) -> Result<Option<ContractWithState>>

The TransferPreapproval contract that lets party receive Amulet without accepting each transfer, or None if it has none.

On a Scan this is an internal endpoint: see with_internal_endpoints.

§Errors

As featured_app_right.

Source

pub async fn member_traffic_status( &self, synchronizer_id: &str, member_id: &str, ) -> Result<TrafficStatus>

How much traffic member has bought and used on a synchronizer. A member is a participant or a mediator, by its id (PAR::…, MED::…).

§Errors

As scans.

Source

pub async fn ans_entry_by_party(&self, party: &str) -> Result<Option<AnsEntry>>

The Amulet Name Service entry of party, or None if it has none.

§Errors

As dso_party_id.

Source

pub async fn ans_entry_by_name(&self, name: &str) -> Result<Option<AnsEntry>>

The Amulet Name Service entry for name, or None if there is none.

§Errors

As dso_party_id.

Source

pub async fn ans_entries( &self, name_prefix: Option<&str>, page_size: u32, ) -> Result<Vec<AnsEntry>>

Up to page_size unexpired Amulet Name Service entries, those whose name starts with name_prefix where one is given.

§Errors

As dso_party_id.

Source

pub async fn updates( &self, after: Option<&HistoryPosition>, page_size: u32, ) -> Result<Vec<ScanUpdate>>

Up to page_size updates after after, oldest first, or from the beginning of history where after is None.

The last update’s position is the after of the next page, and fewer than page_size updates means the end of what Scan has so far. Every Scan returns the same updates in the same order.

§Errors

As scans.

Source

pub async fn update(&self, update_id: &str) -> Result<Option<ScanUpdate>>

The update with this id, or None if Scan has none.

§Errors

As scans.

Source

pub async fn events( &self, after: Option<&HistoryPosition>, page_size: u32, ) -> Result<Vec<ScanEventItem>>

Up to page_size entries of the event history after after: each update with the mediator’s verdict on it. Paged as updates, from the last entry’s position, which an entry has also when it is a verdict with no update.

§Errors

As scans.

Source

pub async fn acs_snapshot_timestamp( &self, before: &str, migration_id: i64, ) -> Result<Option<String>>

The record time of the most recent snapshot of the active contracts taken before before (an RFC 3339 time) in migration_id, or None if there is none.

§Errors

As scans.

Source

pub async fn acs_snapshot( &self, request: &SnapshotRequest, ) -> Result<AcsSnapshot>

A page of a snapshot of the active contracts.

Splice 0.7.5 and later: an older Scan has no /v2/state/acs and answers 404.

§Errors

As scans, and Error::InvalidRequest for a page size Scan does not allow.

Source

pub async fn holdings_state( &self, request: &SnapshotRequest, ) -> Result<AcsSnapshot>

A page of the Amulet and locked Amulet contracts the request’s parties owned at a snapshot. Splice 0.7.5 and later, as acs_snapshot.

§Errors

As acs_snapshot, and Error::InvalidRequest if the request names no party.

Source

pub async fn holdings_summary( &self, request: &SnapshotRequest, ) -> Result<HoldingsSummaries>

The Amulet totals the request’s parties held at a snapshot. The page size, page token and templates of the request are not used. Splice 0.6.3 and later.

§Errors

As dso_party_id, and Error::InvalidRequest if the request names no party.

Source

pub async fn get_json( &self, version: &str, segments: &[&str], query: &[(&str, &str)], ) -> Result<Value>

GET a path this client has no method for, and return the JSON as it came. version is the first path segment (v0, v1, …).

For the rest of Splice’s API: the same transport as every other call here (the token, no redirects, a bounded reply, encoded segments) and nothing checked about what comes back. Through a validator the path is taken under its scan-proxy prefix.

§Errors

As any HTTP call.

Source

pub async fn post_json( &self, version: &str, segments: &[&str], body: &Value, ) -> Result<Value>

POST a JSON body to a path this client has no method for, and return the JSON as it came. See get_json.

§Errors

As any HTTP call.

Trait Implementations§

Source§

impl Clone for ScanClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScanClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ScanClient

§

impl !UnwindSafe for ScanClient

§

impl Forget for ScanClient

§

impl Freeze for ScanClient
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<ClientRef> is !null: Freeze, PhantomData<ArcInner<ClientRef>>: Freeze, *const ArcInner<dyn TokenSource> is !null: Freeze, PhantomData<ArcInner<dyn TokenSource>>: Freeze,

§

impl Move for ScanClient

§

impl Send for ScanClient
where RawVecInner: Send, Arc<ClientRef>: Send, Arc<dyn TokenSource>: Send,

§

impl Sync for ScanClient
where RawVecInner: Sync, Arc<ClientRef>: Sync, Arc<dyn TokenSource>: Sync,

§

impl Unpin for ScanClient
where *const u8 is !null: Unpin, Arc<ClientRef>: Unpin, Arc<dyn TokenSource>: Unpin,

§

impl UnsafeUnpin for ScanClient
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<ClientRef> is !null: UnsafeUnpin, PhantomData<ArcInner<ClientRef>>: UnsafeUnpin, *const ArcInner<dyn TokenSource> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn TokenSource>>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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