From faada6af8d77eee40499be06acfab80d0ffac97f Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 14 Jan 2020 12:54:56 -0500 Subject: hs-v3: Implement hs_ob_service_is_instance() Signed-off-by: David Goulet --- src/feature/hs/hs_ob.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/feature/hs/hs_ob.c') diff --git a/src/feature/hs/hs_ob.c b/src/feature/hs/hs_ob.c index 7e84af3d99..62db3bd434 100644 --- a/src/feature/hs/hs_ob.c +++ b/src/feature/hs/hs_ob.c @@ -193,6 +193,24 @@ build_subcredential(const ed25519_public_key_t *pkey, uint64_t tp, * Public API. */ +/** Return true iff the given service is configured as an onion balance + * instance. To satisfy that condition, there must at least be one master + * ed25519 public key configured. */ +bool +hs_ob_service_is_instance(const hs_service_t *service) +{ + if (BUG(service == NULL)) { + return false; + } + + /* No list, we are not an instance. */ + if (!service->config.ob_master_pubkeys) { + return false; + } + + return smartlist_len(service->config.ob_master_pubkeys) > 0; +} + /** Read and parse the config file at fname on disk. The service config object * is populated with the options if any. * -- cgit v1.2.3-54-g00ecf