diff --git a/.changeset/mean-numbers-train.md b/.changeset/mean-numbers-train.md new file mode 100644 index 000000000..b642a4125 --- /dev/null +++ b/.changeset/mean-numbers-train.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +Added consensus network API. diff --git a/libs/renterd-js/src/bus.ts b/libs/renterd-js/src/bus.ts index 259480655..e6c28a1d8 100644 --- a/libs/renterd-js/src/bus.ts +++ b/libs/renterd-js/src/bus.ts @@ -260,6 +260,10 @@ import { busSettingsS3Route, busSettingsUploadRoute, busObjectsRemoveRoute, + ConsensusNetworkParams, + ConsensusNetworkPayload, + ConsensusNetworkResponse, + busConsensusNetworkRoute, } from '@siafoundation/renterd-types' import { buildRequestHandler, initAxios } from '@siafoundation/request' @@ -282,6 +286,11 @@ export function Bus({ api, password }: { api: string; password?: string }) { ConsensusStatePayload, ConsensusStateResponse >(axios, 'get', busConsensusStateRoute), + consensusNetwork: buildRequestHandler< + ConsensusNetworkParams, + ConsensusNetworkPayload, + ConsensusNetworkResponse + >(axios, 'get', busConsensusNetworkRoute), consensusAcceptBlock: buildRequestHandler< ConsensusAcceptBlockParams, ConsensusAcceptBlockPayload, diff --git a/libs/renterd-react/src/bus.ts b/libs/renterd-react/src/bus.ts index 34fd8e6c8..e3db3cac2 100644 --- a/libs/renterd-react/src/bus.ts +++ b/libs/renterd-react/src/bus.ts @@ -248,6 +248,9 @@ import { SettingsUploadUpdateResponse, SettingsPinnedResponse, busObjectsRemoveRoute, + ConsensusNetworkParams, + ConsensusNetworkResponse, + busConsensusNetworkRoute, } from '@siafoundation/renterd-types' // state @@ -283,6 +286,15 @@ export function useConsensusState( }) } +export function useConsensusNetwork( + args?: HookArgsSwr +) { + return useGetSwr({ + ...args, + route: busConsensusNetworkRoute, + }) +} + export function useEstimatedNetworkBlockHeight(): number { const state = useBusState({ config: { diff --git a/libs/renterd-types/src/bus.ts b/libs/renterd-types/src/bus.ts index d7c37328d..2cf23fdde 100644 --- a/libs/renterd-types/src/bus.ts +++ b/libs/renterd-types/src/bus.ts @@ -26,6 +26,7 @@ import { export const busStateRoute = '/bus/state' export const busAutopilotsRoute = '/bus/autopilots' +export const busConsensusNetworkRoute = '/bus/consensus/network' export const busConsensusStateRoute = '/bus/consensus/state' export const busConsensusAcceptblockRoute = '/bus/consensus/acceptblock' export const busSyncerPeersRoute = '/bus/syncer/peers' @@ -121,6 +122,10 @@ export type ConsensusStateParams = void export type ConsensusStatePayload = void export type ConsensusStateResponse = ConsensusState +export type ConsensusNetworkParams = void +export type ConsensusNetworkPayload = void +export type ConsensusNetworkResponse = string + export type ConsensusAcceptBlockParams = void export type ConsensusAcceptBlockPayload = Block export type ConsensusAcceptBlockResponse = void