In the JS implementation, there is a “middleware” called deduplicate.ts that creates a cache of incoming packets and (occasionally) returns a promise for the result of a previously encountered packet instead of processing the actual packet.
What is the theoretical rationale for this middleware? Is it intending to protect the sender? Or is this middleware actually meant to protect the Connector itself? Some other purpose? (It seems like the current design of ILP is meant to tolerate the occasional duplicate/lost packet…)
Does anyone have experience with this middleware in production to know:
- If this functionality worth the overhead? I would expect it to be rarely useful (duplicate packets should be rare), but the cache inside of this middleware consumes memory on every packet call.
- Is the performance hit very noticable? I would expect it to be a moderate hit because there is a fair amount of byte-array parsing and a hash-per-packet.
This middleware seems to “step on” identical packets that have larger amounts and/or expiries, which is surprising. Is there any reason that an otherwise identical 2nd Prepare packet having a larger amount than the previous one shouldn’t be treated as a different packet?