Skip to content

Commit

Permalink
[core] Cache keys between restart
Browse files Browse the repository at this point in the history
  • Loading branch information
devlikepro committed Dec 6, 2024
1 parent 0a099a9 commit 6296115
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/engines/noweb/session.noweb.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
return {
agent: agent,
fetchAgent: agent,
auth: {
creds: state.creds,
/** caching makes the store faster to send/recv messages */
keys: makeCacheableSignalKeyStore(state.keys, this.engineLogger),
},
auth: state,
printQRInTerminal: false,
browser: browser,
logger: this.engineLogger,
Expand All @@ -291,10 +287,16 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {

async makeSocket(): Promise<any> {
if (!this.authNOWEBStore) {
this.authNOWEBStore = await this.authFactory.buildAuth(
const store = await this.authFactory.buildAuth(
this.sessionStore,
this.name,
);
/** caching makes the store faster to send/recv messages */
store.state.keys = makeCacheableSignalKeyStore(
store.state.keys,
this.engineLogger,
);
this.authNOWEBStore = store;
}
const { state, saveCreds } = this.authNOWEBStore;
const agent = this.makeAgent();
Expand Down

0 comments on commit 6296115

Please sign in to comment.