Skip to content

Commit fea69f5

Browse files
committed
fix(warm-storage): check metadata withCDN key in addition to cdnRailId for CDN status
Fixes: #184
1 parent 6a3b5cc commit fea69f5

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/synapse-sdk/src/storage/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export class StorageContext {
436436
)
437437
}
438438

439-
const withCDN = dataSetInfo.cdnRailId > 0
439+
const withCDN = dataSetInfo.cdnRailId > 0 && METADATA_KEYS.WITH_CDN in dataSetMetadata
440440
if (options.withCDN != null && withCDN !== options.withCDN) {
441441
throw createError(
442442
'StorageContext',

packages/synapse-sdk/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export interface EnhancedDataSetInfo extends DataSetInfo {
237237
isLive: boolean
238238
/** Whether this data set is managed by the current Warm Storage contract */
239239
isManaged: boolean
240-
/** Whether the data set is using CDN (derived from cdnRailId > 0) */
240+
/** Whether the data set is using CDN (cdnRailId > 0 and withCDN metadata key present) */
241241
withCDN: boolean
242242
/** Metadata associated with this data set (key-value pairs) */
243243
metadata: Record<string, string>

packages/synapse-sdk/src/warm-storage/service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ import type { PaymentsService } from '../payments/service.ts'
3131
import type { DataSetCreationStatusResponse, PDPServer } from '../pdp/server.ts'
3232
import { PDPVerifier } from '../pdp/verifier.ts'
3333
import type { DataSetInfo, EnhancedDataSetInfo } from '../types.ts'
34-
import { CONTRACT_ADDRESSES, SIZE_CONSTANTS, TIME_CONSTANTS, TIMING_CONSTANTS } from '../utils/constants.ts'
34+
import {
35+
CONTRACT_ADDRESSES,
36+
METADATA_KEYS,
37+
SIZE_CONSTANTS,
38+
TIME_CONSTANTS,
39+
TIMING_CONSTANTS,
40+
} from '../utils/constants.ts'
3541
import { CONTRACT_ABIS, createError, getFilecoinNetworkType, TOKENS } from '../utils/index.ts'
3642

3743
/**
@@ -378,7 +384,7 @@ export class WarmStorageService {
378384
currentPieceCount: Number(nextPieceId),
379385
isLive,
380386
isManaged,
381-
withCDN: base.cdnRailId > 0,
387+
withCDN: base.cdnRailId > 0 && METADATA_KEYS.WITH_CDN in metadata,
382388
metadata,
383389
}
384390
} catch (error) {

0 commit comments

Comments
 (0)