fix context backing name
This commit is contained in:
parent
0d273a7d36
commit
135625ccc0
|
@ -4,7 +4,7 @@ import { IBls } from "./interface";
|
||||||
|
|
||||||
export type Backing = "herumi" | "blst-native" | "blst-wasm";
|
export type Backing = "herumi" | "blst-native" | "blst-wasm";
|
||||||
|
|
||||||
let backing: Backing|undefined = undefined;
|
let contextBacking: Backing|undefined = undefined;
|
||||||
let context: IBls|undefined = undefined;
|
let context: IBls|undefined = undefined;
|
||||||
|
|
||||||
//to maintain api compatible, add all backing context to return type
|
//to maintain api compatible, add all backing context to return type
|
||||||
|
@ -13,7 +13,7 @@ export async function init(backing: Backing = "herumi"): Promise<IBls> {
|
||||||
switch(backing) {
|
switch(backing) {
|
||||||
case "herumi": {
|
case "herumi": {
|
||||||
context = await herumiToIBls();
|
context = await herumiToIBls();
|
||||||
backing = backing;
|
contextBacking = backing;
|
||||||
} break;
|
} break;
|
||||||
default: throw new Error(`Unsupported backing - ${backing}`)
|
default: throw new Error(`Unsupported backing - ${backing}`)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ export function destroy(): void {
|
||||||
context.destroy();
|
context.destroy();
|
||||||
}
|
}
|
||||||
context = undefined;
|
context = undefined;
|
||||||
backing = undefined;
|
contextBacking = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getContext(): IBls {
|
export function getContext(): IBls {
|
||||||
|
@ -36,3 +36,11 @@ export function getContext(): IBls {
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getContextBacking(): Backing {
|
||||||
|
if (!context) {
|
||||||
|
throw new Error("BLS not initialized");
|
||||||
|
}
|
||||||
|
return contextBacking;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue