summaryrefslogtreecommitdiff
path: root/src/or/nodelist.c
diff options
context:
space:
mode:
authorArunaMaurya221B <aruna.maurya12@gmail.com>2017-12-29 20:11:06 +0530
committerArunaMaurya221B <aruna.maurya12@gmail.com>2017-12-29 20:11:06 +0530
commit01efbe3bd3d7e7d3bd372c04531ea2825ac9f706 (patch)
treecf4f09fd0c2de5cd1e98a670fff51362aa433f6c /src/or/nodelist.c
parentf5d89fab2525fd8a105f9f0ea9258147bf16290e (diff)
downloadtor-01efbe3bd3d7e7d3bd372c04531ea2825ac9f706.tar.gz
tor-01efbe3bd3d7e7d3bd372c04531ea2825ac9f706.zip
node_has_curve25519_onion_key() is refactored and duplicate code removed
Diffstat (limited to 'src/or/nodelist.c')
-rw-r--r--src/or/nodelist.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index e6eaefb216..f73719514d 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -1630,24 +1630,18 @@ microdesc_has_curve25519_onion_key(const microdesc_t *md)
int
node_has_curve25519_onion_key(const node_t *node)
{
- if (!node)
- return 0;
-
- if (node->ri)
- return routerinfo_has_curve25519_onion_key(node->ri);
- else if (node->md)
- return microdesc_has_curve25519_onion_key(node->md);
- else
- return 0;
+ return(node_get_curve25519_onion_key(node)!=NULL);
}
/** Return the curve25519 key of <b>node</b>, or NULL if none. */
const curve25519_public_key_t *
node_get_curve25519_onion_key(const node_t *node)
{
- if (node->ri)
+ if (!node)
+ return NULL;
+ if (routerinfo_has_curve25519_onion_key(node->ri))
return node->ri->onion_curve25519_pkey;
- else if (node->md)
+ else if (microdesc_has_curve25519_onion_key(node->md))
return node->md->onion_curve25519_pkey;
else
return NULL;