Skip to content
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

Use separate eventstream per namespace #135

Merged
merged 16 commits into from
Feb 29, 2024

Conversation

nguyer
Copy link
Contributor

@nguyer nguyer commented Nov 6, 2023

Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
@@ -15,7 +15,7 @@
// limitations under the License.

import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import * as LRUCache from 'lru-cache';
import LRUCache from 'lru-cache';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely make sure the Docker still works with this. We've seen weird differences in Node depending on the default import syntax.

@@ -1,5 +1,5 @@
PORT=3000
ETHCONNECT_URL=http://127.0.0.1:5102
ETHCONNECT_INSTANCE=/contracts/erc1155
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this one is old. Why did it pop back up? Do we still rely on it anywhere? Definitely tried to move to CONTRACT_ADDRESS a while back.

//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE -2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

await this.createPoolSubscription(ctx, defaultContract, BASE_SUBSCRIPTION_NAME);
}
}
async onConnect() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be removed, along with the supporting methods that wanted it to exist...

this.logger.log('Using event stream with name ' + name);
this.stream = await this.eventstream.createOrUpdateStream(ctx, name, name);
return this.stream;
await this.migrationCheck(ctx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in ERC20, I think this should be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... looks like you have already repurposed it in this case to do the purge instead of just the check. That's probably fine.

this.currentClient = undefined;
// Iterate over all the namespaces this client was subscribed to
this.namespaceClients.forEach((clientSet, namespace) => {
clientSet.delete(client);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note as ERC20 - shouldn't we check the return to see if the clientSet actually included this client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now that awaitingAck is scoped to the client itself, none of the rest of this loop will have any effect if the client wasn't listening on the namespace

@@ -186,6 +195,7 @@ export class TokenListener implements EventListener {
interfaceFormat: InterfaceFormat.ABI,
poolData: unpackedSub.poolData,
poolLocator: packedPoolLocator,
alternateLocators: oldLocator ? [oldLocator] : [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad this turned out to be a (relatively) simple migration path.

@@ -50,6 +50,18 @@ export interface WebSocketMessage {
data: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can delete this type if it's unused.

Copy link
Contributor

@awrichar awrichar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - basically all the same feedback as hyperledger/firefly-tokens-erc20-erc721#140. Thanks for figuring out the weirdness with the pool locator migration on this one too.

Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
@nguyer nguyer merged commit 572b515 into hyperledger:main Feb 29, 2024
3 checks passed
@nguyer nguyer deleted the eventstreams branch February 29, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants