From 135625ccc079a2ca90d831aab033e82e92e22cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Mon, 23 Nov 2020 14:42:04 +0100 Subject: [PATCH] fix context backing name --- src/context.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/context.ts b/src/context.ts index 03bdd12..98b56d5 100644 --- a/src/context.ts +++ b/src/context.ts @@ -4,7 +4,7 @@ import { IBls } from "./interface"; export type Backing = "herumi" | "blst-native" | "blst-wasm"; -let backing: Backing|undefined = undefined; +let contextBacking: Backing|undefined = undefined; let context: IBls|undefined = undefined; //to maintain api compatible, add all backing context to return type @@ -13,7 +13,7 @@ export async function init(backing: Backing = "herumi"): Promise { switch(backing) { case "herumi": { context = await herumiToIBls(); - backing = backing; + contextBacking = backing; } break; default: throw new Error(`Unsupported backing - ${backing}`) } @@ -27,7 +27,7 @@ export function destroy(): void { context.destroy(); } context = undefined; - backing = undefined; + contextBacking = undefined; } export function getContext(): IBls { @@ -36,3 +36,11 @@ export function getContext(): IBls { } return context; } + + +export function getContextBacking(): Backing { + if (!context) { + throw new Error("BLS not initialized"); + } + return contextBacking; +}