refactor: cleaner & faster app state sync management

1. Is orders of magnitude faster than the previous edition
2. Stores lesser data, so more memory efficient
3. This breaks the current app state in baileys, but baileys will auto-resync & update the state
This commit is contained in:
Adhiraj Singh
2021-11-24 20:04:36 +05:30
parent 920e60815b
commit efc7dffbeb
2 changed files with 94 additions and 110 deletions

View File

@@ -1,6 +1,6 @@
import type { Contact } from "./Contact"
import type { proto } from "../../WAProto"
import type { WAPatchName, ChatMutation } from "./Chat"
import type { WAPatchName } from "./Chat"
export type KeyPair = { public: Uint8Array, private: Uint8Array }
export type SignedKeyPair = { keyPair: KeyPair, signature: Uint8Array, keyId: number }
@@ -14,7 +14,13 @@ export type SignalIdentity = {
identifierKey: Uint8Array
}
export type LTHashState = { version: number, hash: Buffer, mutations: ChatMutation[] }
export type LTHashState = {
version: number
hash: Buffer
indexValueMap: {
[indexMacBase64: string]: { valueMac: Uint8Array | Buffer }
}
}
export type SignalCreds = {
readonly signedIdentityKey: KeyPair