pub struct ScanClient { /* private fields */ }Expand description
A client for one Scan, or for one validator’s scan-proxy.
Implementations§
Source§impl ScanClient
impl ScanClient
Sourcepub fn new(base_url: &str) -> Result<Self>
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.
Sourcepub fn with_http_client(base_url: &str, http: Client) -> Result<Self>
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.
Sourcepub fn through_validator(base_url: &str) -> Result<Self>
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.
Sourcepub fn through_validator_with_http_client(
base_url: &str,
http: Client,
) -> Result<Self>
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.
Sourcepub fn with_token(self, token: impl Into<String>) -> Self
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.
Sourcepub fn with_token_source(self, source: impl TokenSource + 'static) -> Self
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.
Sourcepub fn with_internal_endpoints(self) -> Self
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.
Sourcepub async fn dso_party_id(&self) -> Result<String>
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.
Sourcepub async fn dso(&self) -> Result<DsoInfo>
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.
Sourcepub async fn scans(&self) -> Result<Vec<SynchronizerScans>>
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.
Sourcepub async fn open_and_issuing_mining_rounds(&self) -> Result<MiningRounds>
pub async fn open_and_issuing_mining_rounds(&self) -> Result<MiningRounds>
Sourcepub async fn latest_open_mining_round(&self) -> Result<ContractWithState>
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.
Sourcepub async fn closed_rounds(&self) -> Result<Vec<ScanContract>>
pub async fn closed_rounds(&self) -> Result<Vec<ScanContract>>
Sourcepub async fn amulet_rules(&self) -> Result<ContractWithState>
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.
Sourcepub async fn featured_app_right(
&self,
provider: &str,
) -> Result<Option<ScanContract>>
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.
Sourcepub async fn transfer_preapproval_by_party(
&self,
party: &str,
) -> Result<Option<ContractWithState>>
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
Sourcepub async fn member_traffic_status(
&self,
synchronizer_id: &str,
member_id: &str,
) -> Result<TrafficStatus>
pub async fn member_traffic_status( &self, synchronizer_id: &str, member_id: &str, ) -> Result<TrafficStatus>
Sourcepub async fn ans_entries(
&self,
name_prefix: Option<&str>,
page_size: u32,
) -> Result<Vec<AnsEntry>>
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.
Sourcepub async fn updates(
&self,
after: Option<&HistoryPosition>,
page_size: u32,
) -> Result<Vec<ScanUpdate>>
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.
Sourcepub async fn events(
&self,
after: Option<&HistoryPosition>,
page_size: u32,
) -> Result<Vec<ScanEventItem>>
pub async fn events( &self, after: Option<&HistoryPosition>, page_size: u32, ) -> Result<Vec<ScanEventItem>>
Sourcepub async fn acs_snapshot_timestamp(
&self,
before: &str,
migration_id: i64,
) -> Result<Option<String>>
pub async fn acs_snapshot_timestamp( &self, before: &str, migration_id: i64, ) -> Result<Option<String>>
Sourcepub async fn acs_snapshot(
&self,
request: &SnapshotRequest,
) -> Result<AcsSnapshot>
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.
Sourcepub async fn holdings_state(
&self,
request: &SnapshotRequest,
) -> Result<AcsSnapshot>
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.
Sourcepub async fn holdings_summary(
&self,
request: &SnapshotRequest,
) -> Result<HoldingsSummaries>
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.
Sourcepub async fn get_json(
&self,
version: &str,
segments: &[&str],
query: &[(&str, &str)],
) -> Result<Value>
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.
Trait Implementations§
Source§impl Clone for ScanClient
impl Clone for ScanClient
Auto Trait Implementations§
impl !RefUnwindSafe for ScanClient
impl !UnwindSafe for ScanClient
impl Forget for ScanClient
impl Freeze for ScanClient
impl Move for ScanClient
impl Send for ScanClient
impl Sync for ScanClient
impl Unpin for ScanClient
impl UnsafeUnpin for ScanClient
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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