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