refactor: debug api connection - ping peer method
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
import type { NodeAddresses, ChequebookAddressResponse, ChequebookBalanceResponse, BalanceResponse,
|
import type { NodeAddresses, ChequebookAddressResponse, ChequebookBalanceResponse, BalanceResponse,
|
||||||
LastChequesResponse, AllSettlements, LastCashoutActionResponse, Health, Peer, Topology } from '@ethersphere/bee-js'
|
LastChequesResponse, AllSettlements, LastCashoutActionResponse, Health, Peer, Topology, PingResponse } from '@ethersphere/bee-js'
|
||||||
|
|
||||||
import { beeDebugApi, beeApi } from '../services/bee';
|
import { beeDebugApi, beeApi } from '../services/bee';
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ export const useApiSettlements = () => {
|
|||||||
|
|
||||||
|
|
||||||
export const useApiPingPeer = (peerId: string) => {
|
export const useApiPingPeer = (peerId: string) => {
|
||||||
const [peerRTP, setPeerRTP] = useState<string>('')
|
const [peerRTP, setPeerRTP] = useState<PingResponse | null>()
|
||||||
const [isPingingPeer, setPingingPeer] = useState<boolean>(false)
|
const [isPingingPeer, setPingingPeer] = useState<boolean>(false)
|
||||||
const [error, setError] = useState<Error | null>(null)
|
const [error, setError] = useState<Error | null>(null)
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ export const useApiPingPeer = (peerId: string) => {
|
|||||||
setPingingPeer(true)
|
setPingingPeer(true)
|
||||||
beeDebugApi.connectivity.ping(peerId)
|
beeDebugApi.connectivity.ping(peerId)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
setPeerRTP(res.data)
|
setPeerRTP(res)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
setError(error)
|
setError(error)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function PeerTable(props: Props) {
|
|||||||
setPeerLatency([...peerLatency, { peerId: peerId, rtt: '', loading: true }])
|
setPeerLatency([...peerLatency, { peerId: peerId, rtt: '', loading: true }])
|
||||||
beeDebugApi.connectivity.ping(peerId)
|
beeDebugApi.connectivity.ping(peerId)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
setPeerLatency([...peerLatency, { peerId: peerId, rtt: res.data.rtt, loading: false }])
|
setPeerLatency([...peerLatency, { peerId: peerId, rtt: res.rtt, loading: false }])
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
setPeerLatency([...peerLatency, { peerId: peerId, rtt: 'error', loading: false }])
|
setPeerLatency([...peerLatency, { peerId: peerId, rtt: 'error', loading: false }])
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const beeDebugApi = {
|
|||||||
return beeJSDebugClient().getTopology()
|
return beeJSDebugClient().getTopology()
|
||||||
},
|
},
|
||||||
ping(peerId: string) {
|
ping(peerId: string) {
|
||||||
return beeDebugApiClient().post(`/pingpong/${peerId}`)
|
return beeJSDebugClient().pingPeer(peerId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
balance: {
|
balance: {
|
||||||
|
|||||||
Reference in New Issue
Block a user