Skip to content
This repository was archived by the owner on Apr 8, 2021. It is now read-only.

Commit e12b2f0

Browse files
committed
use a start time when reconnecting
1 parent 959e865 commit e12b2f0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/service/mirror.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let isListening = false;
1414
const textDecoder = new TextDecoder();
1515

1616
let listenAttempts = 0;
17+
let lastReceivedResponseTime: Date | number = 0;
1718

1819
export function startListening(topicId: ConsensusTopicIdLike) {
1920
// Guard against being called multiple times
@@ -23,9 +24,11 @@ export function startListening(topicId: ConsensusTopicIdLike) {
2324
// Assume that the topic _does_ exist
2425
new MirrorConsensusTopicQuery()
2526
.setTopicId(new ConsensusTopicId(topicId))
26-
.setStartTime(0)
27+
.setStartTime(lastReceivedResponseTime)
2728
.subscribe(mirrorClient, (response) => {
2829
listenAttempts = 0;
30+
lastReceivedResponseTime = response.consensusTimestamp.asDate();
31+
2932
let data;
3033

3134
try {

0 commit comments

Comments
 (0)