-
Notifications
You must be signed in to change notification settings - Fork 9
/
IAccumulatorState.ts
36 lines (32 loc) · 1.08 KB
/
IAccumulatorState.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Interface for accumulator state. This should be implemented by the persistence layer that stores the accumulator
* members. It is advised to update the state when elements are added or removed from the accumulator.
*/
export interface IAccumulatorState {
add(element: Uint8Array): Promise<void>;
remove(element: Uint8Array): Promise<void>;
/**
* Check if element is a member of the state.
* @param element
*/
has(element: Uint8Array): Promise<boolean>;
}
/**
* Additional interface for universal accumulator to expose a method that allows to iterate over the
* accumulator members.
*/
export interface IUniversalAccumulatorState extends IAccumulatorState {
elements(): Promise<Iterable<Uint8Array>>;
}
export interface IKBUniversalAccumulatorState extends IAccumulatorState {
/**
* Whether this element is in the domain (could be a member or not)
* @param element
*/
inDomain(element: Uint8Array): Promise<boolean>;
/**
* Takes an element not in the domain and adds it.
* @param element
*/
addToDomain(element: Uint8Array): Promise<void>;
}