Skip to content

Commit

Permalink
fix: dont load log on updateRole when closed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Dec 5, 2023
1 parent 6b107e4 commit 110517f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/programs/data/shared-log/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,19 @@ export class SharedLog<T = Uint8Array> extends Program<
this.role,
this.node.identity.publicKey
);
if (!this._loadedOnce) {
await this.log.load();
this._loadedOnce = true;
}
await this.rpc.subscribe();
await this.rpc.send(new ResponseRoleMessage(role));
if (!this.closed) {
if (!this._loadedOnce) {
await this.log.load();
this._loadedOnce = true;
}
await this.rpc.subscribe();
await this.rpc.send(new ResponseRoleMessage(role));

if (onRoleChange) {
this.onRoleChange(undefined, this._role, this.node.identity.publicKey);
if (onRoleChange) {
this.onRoleChange(undefined, this._role, this.node.identity.publicKey);
}
}

return changed;
}

Expand Down

0 comments on commit 110517f

Please sign in to comment.