diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b7c68e51e..da864e9fcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,9 @@ Changes before Tatum release are not documented in this file. - **BREAKING CHANGE:** Replace methods `StreamrClient#updateStream()` and `Stream#update()`: (https://github.com/streamr-dev/network/pull/2826, https://github.com/streamr-dev/network/pull/2855, https://github.com/streamr-dev/network/pull/2859, https://github.com/streamr-dev/network/pull/2862) - use `StreamrClient#setStreamMetadata()` and `Stream#setMetadata()` instead - both methods overwrite metadata instead of merging it -- Change storage node address caching (https://github.com/streamr-dev/network/pull/2877, https://github.com/streamr-dev/network/pull/2878) +- Caching changes: + - storage node addresses (https://github.com/streamr-dev/network/pull/2877, https://github.com/streamr-dev/network/pull/2878) + - stream metadata and permissions (https://github.com/streamr-dev/network/pull/2889) - Upgrade `StreamRegistry` from v4 to v5 (https://github.com/streamr-dev/network/pull/2780) - Network-level changes: - avoid routing through proxy connections (https://github.com/streamr-dev/network/pull/2801) diff --git a/packages/sdk/src/StreamrClient.ts b/packages/sdk/src/StreamrClient.ts index 88fd7dd2d8..eb8a2090c8 100644 --- a/packages/sdk/src/StreamrClient.ts +++ b/packages/sdk/src/StreamrClient.ts @@ -357,7 +357,7 @@ export class StreamrClient { */ async getStream(streamIdOrPath: string): Promise { const streamId = await this.streamIdBuilder.toStreamID(streamIdOrPath) - const metadata = await this.streamRegistry.getStreamMetadata(streamId, false) + const metadata = await this.streamRegistry.getStreamMetadata(streamId) return new Stream(streamId, metadata, this) } @@ -501,7 +501,7 @@ export class StreamrClient { */ async isStreamPublisher(streamIdOrPath: string, userId: HexString): Promise { const streamId = await this.streamIdBuilder.toStreamID(streamIdOrPath) - return this.streamRegistry.isStreamPublisher(streamId, toUserId(userId), false) + return this.streamRegistry.isStreamPublisher(streamId, toUserId(userId)) } /** @@ -509,7 +509,7 @@ export class StreamrClient { */ async isStreamSubscriber(streamIdOrPath: string, userId: HexString): Promise { const streamId = await this.streamIdBuilder.toStreamID(streamIdOrPath) - return this.streamRegistry.isStreamSubscriber(streamId, toUserId(userId), false) + return this.streamRegistry.isStreamSubscriber(streamId, toUserId(userId)) } // -------------------------------------------------------------------------------------------- diff --git a/packages/sdk/src/contracts/StreamRegistry.ts b/packages/sdk/src/contracts/StreamRegistry.ts index 52ef9c6e4e..2a3aca108c 100644 --- a/packages/sdk/src/contracts/StreamRegistry.ts +++ b/packages/sdk/src/contracts/StreamRegistry.ts @@ -172,13 +172,13 @@ export class StreamRegistry { cacheKey: ([streamId]) => formCacheKeyPrefix(streamId) }) this.isStreamPublisher_cached = new CachingMap((streamId: StreamID, userId: UserID) => { - return this.isStreamPublisher(streamId, userId, false) + return this.isStreamPublisherOrSubscriber_nonCached(streamId, userId, StreamPermission.PUBLISH) }, { ...config.cache, cacheKey: ([streamId, userId]) =>`${formCacheKeyPrefix(streamId)}${userId}` }) this.isStreamSubscriber_cached = new CachingMap((streamId: StreamID, userId: UserID) => { - return this.isStreamSubscriber(streamId, userId, false) + return this.isStreamPublisherOrSubscriber_nonCached(streamId, userId, StreamPermission.SUBSCRIBE) }, { ...config.cache, cacheKey: ([streamId, userId]) =>`${formCacheKeyPrefix(streamId)}${userId}` @@ -511,28 +511,16 @@ export class StreamRegistry { // Caching // -------------------------------------------------------------------------------------------- - getStreamMetadata(streamId: StreamID, useCache = true): Promise { - if (useCache) { - return this.getStreamMetadata_cached.get(streamId) - } else { - return this.getStreamMetadata_nonCached(streamId) - } + getStreamMetadata(streamId: StreamID): Promise { + return this.getStreamMetadata_cached.get(streamId) } - isStreamPublisher(streamId: StreamID, userId: UserID, useCache = true): Promise { - if (useCache) { - return this.isStreamPublisher_cached.get(streamId, userId) - } else { - return this.isStreamPublisherOrSubscriber_nonCached(streamId, userId, StreamPermission.PUBLISH) - } + isStreamPublisher(streamId: StreamID, userId: UserID): Promise { + return this.isStreamPublisher_cached.get(streamId, userId) } - isStreamSubscriber(streamId: StreamID, userId: UserID, useCache = true): Promise { - if (useCache) { - return this.isStreamSubscriber_cached.get(streamId, userId) - } else { - return this.isStreamPublisherOrSubscriber_nonCached(streamId, userId, StreamPermission.SUBSCRIBE) - } + isStreamSubscriber(streamId: StreamID, userId: UserID): Promise { + return this.isStreamSubscriber_cached.get(streamId, userId) } hasPublicSubscribePermission(streamId: StreamID): Promise {