daemon: add global secp256k1 context for easy access.

This caches the tables, so you're not supposed to regenerate it all
the time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-01-22 06:41:48 +10:30
parent 2df28021ac
commit 14cbcd467f
2 changed files with 6 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ static struct lightningd_state *lightningd_state(void)
list_head_init(&state->peers);
timers_init(&state->timers, time_now());
state->secpctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN);
return state;
}

View File

@@ -3,6 +3,7 @@
#include "config.h"
#include <ccan/list/list.h>
#include <ccan/timer/timer.h>
#include <secp256k1.h>
#include <stdio.h>
/* Here's where the global variables hide! */
@@ -21,5 +22,8 @@ struct lightningd_state {
/* Our peers. */
struct list_head peers;
/* Crypto tables for global use. */
secp256k1_context *secpctx;
};
#endif /* LIGHTNING_DAEMON_LIGHTNING_H */