From 8be46ad19798bb12b621dff14c6d09004efd6343 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Thu, 12 Sep 2024 08:27:07 -0700 Subject: [PATCH] VoidResult --- src/blockstore/fragment-gateway.ts | 10 ++++++---- src/blockstore/gateway.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/blockstore/fragment-gateway.ts b/src/blockstore/fragment-gateway.ts index a68edd5e..1086b142 100644 --- a/src/blockstore/fragment-gateway.ts +++ b/src/blockstore/fragment-gateway.ts @@ -3,6 +3,7 @@ import { bs, ensureSuperLog, Logger, Result, SuperThis } from "@fireproof/core"; import { base58btc } from "multiformats/bases/base58"; import { encode, decode } from "cborg"; +import { VoidResult } from "./gateway"; function getFragSize(url: URI): number { const fragSize = url.getParam("fragSize"); @@ -167,11 +168,12 @@ export class FragmentGateway implements bs.Gateway { return Result.Ok(buffer || new Uint8Array(0)); } - async subscribe(url: URI, callback: (msg: Uint8Array) => void): Promise { - if (!this.innerGW.subscribe) { - throw this.logger.Error().Msg("Subscribe not supported").AsError(); + async subscribe(url: URI, callback: (msg: Uint8Array) => void): Promise { + if (this.innerGW.subscribe) { + return this.innerGW.subscribe(url, callback); + } else { + return Result.Err(this.logger.Error().Msg("Subscribe not supported").AsError()); } - return this.innerGW.subscribe(url, callback); } async delete(url: URI): Promise { diff --git a/src/blockstore/gateway.ts b/src/blockstore/gateway.ts index c0d6fb76..0d913760 100644 --- a/src/blockstore/gateway.ts +++ b/src/blockstore/gateway.ts @@ -25,5 +25,5 @@ export interface Gateway { get(url: URI): Promise; delete(url: URI): Promise; // be notified of remote meta - subscribe?(url: URI, callback: (meta: Uint8Array) => void): Promise; + subscribe?(url: URI, callback: (meta: Uint8Array) => void): Promise; }