Skip to content

Commit

Permalink
disable payload batch endpoint for p2p only
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble committed Aug 25, 2024
1 parent ea6734d commit 34df7ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Chainweb/Payload/RestAPI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ newtype PayloadBatchLimit = PayloadBatchLimit Natural
deriving newtype (Ord, Enum, Num, Real, Integral, ToJSON, FromJSON)

p2pPayloadBatchLimit :: PayloadBatchLimit
p2pPayloadBatchLimit = 20
p2pPayloadBatchLimit = 0

defaultServicePayloadBatchLimit :: PayloadBatchLimit
defaultServicePayloadBatchLimit = 1000
Expand Down
10 changes: 7 additions & 3 deletions src/Chainweb/Payload/RestAPI/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ payloadHandler db k mh = liftIO (lookupPayloadDataWithHeight db mh k) >>= \case
[ "reason" .= ("key not found" :: String)
, "key" .= k
]
Just e -> return e
Just e -> return e

-- -------------------------------------------------------------------------- --
-- POST Payload Batch Handler
Expand All @@ -89,8 +89,12 @@ payloadBatchHandler
-> PayloadDb tbl
-> BatchBody
-> Handler PayloadDataList
payloadBatchHandler _batchLimit _db _ks =
throwError (ServerError 404 "" "" [])
payloadBatchHandler batchLimit db ks
= liftIO (PayloadDataList . catMaybes <$> lookupPayloadDataWithHeightBatch db ks')
where
limit = take (int batchLimit)
ks' | WithoutHeights xs <- ks = limit (fmap (Nothing,) xs)
| WithHeights xs <- ks = limit (fmap (over _1 Just) xs)

-- -------------------------------------------------------------------------- --
-- GET Outputs Handler
Expand Down

0 comments on commit 34df7ad

Please sign in to comment.