A peer-to-peer stack for code collaboration
Change storage interface 'receive' to return value list
Thomas Scholtes4e0acaa41b83
diff --git a/exe/Server.hs b/exe/Server.hsindex 8e962d2..4407503 100644--- a/exe/Server.hs+++ b/exe/Server.hs@@ -131,8 +131,8 @@ submit conn chains name (Values vals) = do-- | Get all expressions submitted to a chain since 'index'.-since :: Connection -> Text -> Int -> Handler Value-since conn name index = liftIO $ List <$> getSinceDB conn name index+since :: Connection -> Text -> Int -> Handler Values+since conn name index = liftIO $ Values <$> getSinceDB conn name indexjsonOutputs :: Chains -> Text -> Handler [Maybe A.Value]jsonOutputs st name = dodiff --git a/src/Radicle/Internal/HttpStorage.hs b/src/Radicle/Internal/HttpStorage.hsindex f29e3f0..8216e56 100644--- a/src/Radicle/Internal/HttpStorage.hs+++ b/src/Radicle/Internal/HttpStorage.hs@@ -68,7 +68,7 @@ chainSubmitEndpoint = Proxy-- | Endpoint to obtain all entries in a chain starting from the given-- index. Responds with a Radicle vector of the expressions.-type ChainSinceEndpoint = "since" :> Capture "index" Int :> Get '[PlainText] Value+type ChainSinceEndpoint = "since" :> Capture "index" Int :> Get '[PlainText] ValueschainSinceEndpoint :: Proxy ChainSinceEndpointchainSinceEndpoint = Proxy@@ -111,8 +111,8 @@ httpStoragePrimFns' mgr =submit :: [Value] -> ClientM Valuesubmit = client chainSubmitEndpoint . Values-since :: Int -> ClientM Value-since = client chainSinceEndpoint+since :: Int -> ClientM [Value]+since idx = getValues <$> client chainSinceEndpoint idxrunClientM' :: (MonadIO m) => Text -> HttpClient.Manager -> ClientM a -> m (Either ServantError a)runClientM' baseUrl manager endpoint = liftIO $ dodiff --git a/src/Radicle/Internal/Storage.hs b/src/Radicle/Internal/Storage.hsindex 07f746c..3d3a4e3 100644--- a/src/Radicle/Internal/Storage.hs+++ b/src/Radicle/Internal/Storage.hs@@ -38,7 +38,7 @@ type StorageSend m = Text -> Seq Value -> m (Either Text ())-- | Receive a list of expressions from a chain. The chain is identified by the first-- argument. The second argument is the index from which to start.-- Morally this is @'Data.List.drop' index chain@.-type StorageReceive m = Text -> Int -> m (Either Text Value)+type StorageReceive m = Text -> Int -> m (Either Text [Value])buildStoragePrimFns :: Monad m => StorageBackend m -> PrimFns mbuildStoragePrimFns backend =@@ -73,7 +73,7 @@ buildStoragePrimFns backend =case res ofLeft err -> throwErrorHere . OtherError$ receiveName <> ": request failed: " <> show err- Right v' -> pure v'+ Right v' -> pure $ List v'(String _, v) -> throwErrorHere $ TypeError receiveName 1 TNumber v(v, _) -> throwErrorHere $ TypeError receiveName 0 TString v)diff --git a/test/spec/Radicle/Internal/TestCapabilities.hs b/test/spec/Radicle/Internal/TestCapabilities.hsindex 2201aa7..b613732 100644--- a/test/spec/Radicle/Internal/TestCapabilities.hs+++ b/test/spec/Radicle/Internal/TestCapabilities.hs@@ -132,7 +132,7 @@ storagePrimFns =let exprs = case Map.lookup id chains ofNothing -> []Just res -> toList $ Seq.drop index res- pure $ Right $ List exprs+ pure $ Right exprs)}