fix: race condition in rpc unsubscribe

This commit is contained in:
Justin Starry 2020-02-11 22:33:50 +08:00 committed by Michael Vines
parent ca34ad2525
commit d483f7e904
1 changed files with 6 additions and 6 deletions

View File

@ -1367,7 +1367,7 @@ export class Connection {
/** /**
* @private * @private
*/ */
async _updateSubscriptions() { _updateSubscriptions() {
const accountKeys = Object.keys(this._accountChangeSubscriptions).map( const accountKeys = Object.keys(this._accountChangeSubscriptions).map(
Number, Number,
); );
@ -1404,23 +1404,23 @@ export class Connection {
} }
for (let id of accountKeys) { for (let id of accountKeys) {
const sub: AccountSubscriptionInfo = this._accountChangeSubscriptions[id]; const sub = this._accountChangeSubscriptions[id];
await this._subscribe(sub, 'accountSubscribe', [sub.publicKey]); this._subscribe(sub, 'accountSubscribe', [sub.publicKey]);
} }
for (let id of programKeys) { for (let id of programKeys) {
const sub = this._programAccountChangeSubscriptions[id]; const sub = this._programAccountChangeSubscriptions[id];
await this._subscribe(sub, 'programSubscribe', [sub.programId]); this._subscribe(sub, 'programSubscribe', [sub.programId]);
} }
for (let id of slotKeys) { for (let id of slotKeys) {
const sub = this._slotSubscriptions[id]; const sub = this._slotSubscriptions[id];
await this._subscribe(sub, 'slotSubscribe', []); this._subscribe(sub, 'slotSubscribe', []);
} }
for (let id of signatureKeys) { for (let id of signatureKeys) {
const sub = this._signatureSubscriptions[id]; const sub = this._signatureSubscriptions[id];
await this._subscribe(sub, 'signatureSubscribe', [sub.signature]); this._subscribe(sub, 'signatureSubscribe', [sub.signature]);
} }
} }