Skip to content

Commit

Permalink
Merge pull request coinbase#217 from blair/message-queue-messages-is-…
Browse files Browse the repository at this point in the history
…readonly

MessageQueue: make messages readonly.
  • Loading branch information
fb55 authored Apr 10, 2018
2 parents 8883fdc + 6b5707e commit 7c368c9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/MessageQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface MessageQueueConfig {
*/
export class MessageQueue extends Duplex {
private logger: Logger;
private messages: RBTree<OrderbookMessage>;
private readonly messages: RBTree<OrderbookMessage>;
private targetQueueLength: number;
private lastSequence: number;
private productId: string;
Expand All @@ -83,7 +83,9 @@ export class MessageQueue extends Duplex {
this.targetQueueLength = options.targetQueueLength || 10;
this.lastSequence = -1000;
this.waitForSnapshot = options.waitForSnapshot;
this.clearQueue();
this.messages = new RBTree<BaseOrderMessage>((a: BaseOrderMessage, b: BaseOrderMessage) => {
return a.sequence - b.sequence;
});
}

get product(): string {
Expand Down Expand Up @@ -128,9 +130,7 @@ export class MessageQueue extends Duplex {
}

clearQueue() {
this.messages = new RBTree<BaseOrderMessage>((a: BaseOrderMessage, b: BaseOrderMessage) => {
return a.sequence - b.sequence;
});
this.messages.clear();
}

_write(inputMessage: any, encoding: string, callback: (err: Error) => void): void {
Expand Down

0 comments on commit 7c368c9

Please sign in to comment.