Skip to content

Commit

Permalink
resume from last max height - 3 to guarantee we will not miss transac…
Browse files Browse the repository at this point in the history
…tions (but this introduces duplicates)
  • Loading branch information
Takadenoshi committed May 9, 2023
1 parent f4a1525 commit ee6ffaa
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/libs/chainweb-stream-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,12 @@ class ChainwebStream extends EventEmitter {
if (this.limit !== undefined) {
urlParamArgs.push(['limit', String(this.limit)]);
}
// TODO
// This currently has a sliding window edge case when reconnecting
// chains can currently be +/- 3 height from each other
// lastHeight can be the height of the leading chain
// to never miss events from other chains we need to send lastHeight - 3
// i.e. the lowest possible height of the trailing chain
// but in that case we would see duplicate events
// Should we track emitted events and suppress duplicates?
// TODO This reconnection strategy of -3 from last max height
// guarrantees that we will not miss events, but it also means
// that confirmed transactions will be emitted more than once
// Discussion here: https://github.com/kadena-community/kadena.js/issues/275
if (this._lastHeight !== undefined) {
urlParamArgs.push(['minHeight', String(this._lastHeight)]);
urlParamArgs.push(['minHeight', String(this._lastHeight - 3)]);
}
if (urlParamArgs.length) {
path += '?' + new URLSearchParams(urlParamArgs).toString();
Expand Down

0 comments on commit ee6ffaa

Please sign in to comment.