Skip to content

Commit 434891f

Browse files
committed
chore(client): update capabilities to required capabilities
1 parent adca1ae commit 434891f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

mithril-client/src/client.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use std::sync::Arc;
1010

1111
use mithril_aggregator_discovery::{
1212
AggregatorDiscoverer, CapableAggregatorDiscoverer, HttpConfigAggregatorDiscoverer,
13-
MithrilNetwork,
13+
MithrilNetwork, RequiredAggregatorCapabilities,
1414
};
1515
use mithril_common::api_version::APIVersionProvider;
16-
use mithril_common::messages::AggregatorCapabilities;
1716
use mithril_common::{MITHRIL_CLIENT_TYPE_HEADER, MITHRIL_ORIGIN_TAG_HEADER};
1817

1918
use crate::MithrilResult;
@@ -179,7 +178,7 @@ impl Client {
179178
/// Builder than can be used to create a [Client] easily or with custom dependencies.
180179
pub struct ClientBuilder {
181180
aggregator_discovery: AggregatorDiscoveryType,
182-
aggregator_capabilities: Option<AggregatorCapabilities>,
181+
aggregator_capabilities: Option<RequiredAggregatorCapabilities>,
183182
aggregator_discoverer: Option<Arc<dyn AggregatorDiscoverer>>,
184183
genesis_verification_key: Option<GenesisVerificationKey>,
185184
origin_tag: Option<String>,
@@ -207,6 +206,18 @@ impl ClientBuilder {
207206
)
208207
}
209208

209+
/// Constructs a new `ClientBuilder` that automatically discovers the aggregator for the given
210+
/// Mithril network and with the given genesis verification key.
211+
pub fn automatic(network: &str, genesis_verification_key: &str) -> ClientBuilder {
212+
Self::new(AggregatorDiscoveryType::Automatic(MithrilNetwork::new(
213+
network.to_string(),
214+
)))
215+
.with_genesis_verification_key(GenesisVerificationKey::JsonHex(
216+
genesis_verification_key.to_string(),
217+
))
218+
.with_default_aggregator_discoverer()
219+
}
220+
210221
/// Constructs a new `ClientBuilder` without any dependency set.
211222
pub fn new(aggregator_discovery: AggregatorDiscoveryType) -> ClientBuilder {
212223
Self {
@@ -242,7 +253,10 @@ impl ClientBuilder {
242253
}
243254

244255
/// Sets the aggregator capabilities expected to be matched by the aggregator with which the client will interact.
245-
pub fn with_capabilities(mut self, capabilities: AggregatorCapabilities) -> ClientBuilder {
256+
pub fn with_capabilities(
257+
mut self,
258+
capabilities: RequiredAggregatorCapabilities,
259+
) -> ClientBuilder {
246260
self.aggregator_capabilities = Some(capabilities);
247261

248262
self

0 commit comments

Comments
 (0)