-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LW-11656 Optimize the aggregation of addresses subscribed by clients #1506
Conversation
|
…scribed by clients
67086fb
to
9bbae51
Compare
const addressesObj: Record<Cardano.PaymentAddress, true> = {}; | ||
|
||
// Benchmarks | ||
// https://jsbenchmark.com/#eyJjYXNlcyI6W3siaWQiOiI5aTVXR2E3bXp0MEE2LU1FZFJDaVQiLCJjb2RlIjoiY29uc3QgeyB3c3MgfSA9IERBVEE7XG5cbmNvbnN0IGFkZHJlc3Nlc01hcCA9IG5ldyBNYXAoKTtcbmZvciAoY29uc3Qgd3Mgb2Ygd3NzLmNsaWVudHMpXG4gIGZvciAoY29uc3QgYWRkcmVzcyBvZiB3cy5hZGRyZXNzZXMpXG4gICAgYWRkcmVzc2VzTWFwLnNldChhZGRyZXNzLCB0cnVlKTtcbmNvbnN0IGFkZHJlc3NlcyA9IFsuLi5hZGRyZXNzZXNNYXAua2V5cygpXTsiLCJkZXBlbmRlbmNpZXMiOltdLCJuYW1lIjoiT3JpZ2luYWwifSx7ImlkIjoibVFoLUFZM3JwX1dPWC1keDN6RTJVIiwiY29kZSI6ImNvbnN0IHsgd3NzIH0gPSBEQVRBO1xuICAgICAgICAgIFxuY29uc3QgYWRkcmVzc2VzTWFwID0gWy4uLndzcy5jbGllbnRzXVxuICAuZmxhdE1hcChpdCA9PiBpdC5hZGRyZXNzZXMpXG4gIC5yZWR1Y2UoKHJlc3VsdCwgaXQpID0-ICh7Li4ucmVzdWx0LCBbaXRdOiB0cnVlfSksIHt9KTtcbmNvbnN0IGFkZHJlc3NlcyA9IFtPYmplY3Qua2V5cyhhZGRyZXNzZXNNYXApXTsiLCJuYW1lIjoiRmlyc3QgcHJvcG9zYWwiLCJkZXBlbmRlbmNpZXMiOltdfSx7ImlkIjoib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ICAgd3MuYWRkcmVzc2VzLnB1c2goYWRkcmVzc2VzW01hdGguZmxvb3IoTWF0aC5yYW5kb20oKSAqIGFkZHJlc3Nlcy5sZWd0aCldKTtcbiAgICAgIGVsc2Uge1xuICAgICAgICAvLyBBcGFydCBmcm9tIHRoZSBmaXhlZCBwcmVmaXhcbiAgICAgICAgLy8gYWRkcmVzc2VzIGFuZCB1dWlkcyBhcmUgbG9uZyBzZXF1ZW5jZXMgb2YgcmFuZG9tIGNoYXJhY3RlcnNcbiAgICAgICAgY29uc3QgYWRkcmVzcyA9IFwiYWRkcl9cIiArIHV1aWQoKTtcblxuICAgICAgICBhZGRyZXNzZXNbYUlkeCsrXSA9IGFkZHJlc3M7XG4gICAgICAgIHdzLmFkZHJlc3Nlcy5wdXNoKGFkZHJlc3MpO1xuICAgICAgfVxuXG4gICAgICBjbGllbnRzLnB1c2god3MpO1xuICAgIH1cbn1cblxucmV0dXJuIHsgd3NzOiB7IGNsaWVudHM6IG5ldyBTZXQoY2xpZW50cykgfSB9OyJ9fQ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof....
// https://jsbenchmark.com/#eyJjYXNlcyI6W3siaWQiOiI5aTVXR2E3bXp0MEE2LU1FZFJDaVQiLCJjb2RlIjoiY29uc3QgeyB3c3MgfSA9IERBVEE7XG5cbmNvbnN0IGFkZHJlc3Nlc01hcCA9IG5ldyBNYXAoKTtcbmZvciAoY29uc3Qgd3Mgb2Ygd3NzLmNsaWVudHMpXG4gIGZvciAoY29uc3QgYWRkcmVzcyBvZiB3cy5hZGRyZXNzZXMpXG4gICAgYWRkcmVzc2VzTWFwLnNldChhZGRyZXNzLCB0cnVlKTtcbmNvbnN0IGFkZHJlc3NlcyA9IFsuLi5hZGRyZXNzZXNNYXAua2V5cygpXTsiLCJkZXBlbmRlbmNpZXMiOltdLCJuYW1lIjoiT3JpZ2luYWwifSx7ImlkIjoibVFoLUFZM3JwX1dPWC1keDN6RTJV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5yYW5kb20oKSA8IDAuMDEpXG4gICAgY2xpZW50cy5wdXNoKGNsaWVudHNbW01hdGguZmxvb3IoTWF0aC5yYW5kb20oKSAqIGNsaWVudHMubGVndGgpXV0pO1xuICBlbHNlXG4gICAgZm9yKGxldCBpID0gMDsgaSA8IDEwMDsgKytpKSB7XG4gICAgICAvLyBTaW11bGF0ZSAwLjElIG9mIGFkZHJlc3NlcyBpcyBzdWJzY3JpYmVkIGJ5IGRpc3RpbmN0IHVzZXJzXG4gICAgICAvLyBpLmUuIHNoYXJlZCB3YWxsZXRzXG4gICAgICBpZihjSWR4ICYmIE1hdGgucmFuZG9tKCkgPCAwLjAwMSlcbiAgICAgICAgd3MuYWRkcmVzc2VzLnB1c2goYWRkcmVzc2VzW01hdGguZmxvb3IoTWF0aC5yYW5kb20oKSAqIGFkZHJlc3Nlcy5sZWd0aCldKTtcbiAgICAgIGVsc2Uge1xuICAgICAgICAvLyBBcGFydCBmcm9tIHRoZSBmaXhlZCBwcmVmaXhcbiAgICAgICAgLy8gYWRkcmVzc2VzIGFuZCB1dWlkcyBhcmUgbG9uZyBzZXF1ZW5jZXMgb2YgcmFuZG9tIGNoYXJhY3RlcnNcbiAgICAgICAgY29uc3QgYWRkcmVzcyA9IFwiYWRkcl9cIiArIHV1aWQoKTtcblxuICAgICAgICBhZGRyZXNzZXNbYUlkeCsrXSA9IGFkZHJlc3M7XG4gICAgICAgIHdzLmFkZHJlc3Nlcy5wdXNoKGFkZHJlc3MpO1xuICAgICAgfVxuXG4gICAgICBjbGllbnRzLnB1c2god3MpO1xuICAgIH1cbn1cblxucmV0dXJuIHsgd3NzOiB7IGNsaWVudHM6IG5ldyBTZXQoY2xpZW50cykgfSB9OyJ9fQ | |
// Benchmarks: https://t.ly/L4Z9s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually link shrinkers have a shorten link limited life time.
Is this one forever? Anyway it means to trust them, as soon as they close the service, we loose the information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They do not specify the lifetime, hopefully 'long enough'? Can you think of any other alternatives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a link in a comment... we already spent on it much more time than how much it deserves.
I have only three options:
- remove the link
- leave it as is
- apply your suggestion accepting the risk we will loose the info in a couple of months
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave it as it is. Also lets create a cloudflare account in the background, it should be useful for cases like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know. Thanks.
Optimized the code snippet as suggested by @gytis-ivaskevicius with these benchmarks.