Skip to content

Commit

Permalink
refactor: standardize syncer peers response data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Nov 4, 2024
1 parent d2a2083 commit d794e60
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-doors-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/hostd-types': minor
---

The syncer peers response now includes more information and matches walletd.
5 changes: 5 additions & 0 deletions .changeset/thirty-nails-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/walletd-types': minor
---

The syncer peers response type updated to include address rather than addr.
2 changes: 1 addition & 1 deletion apps/walletd/components/Node/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function Node() {
<div className="flex-1">
<PeerList
isLoading={peers.isValidating}
peers={peers.data?.map((p) => p.addr)}
peers={peers.data?.map((p) => p.address)}
connectPeer={() => openDialog('connectPeer')}
/>
</div>
Expand Down
5 changes: 5 additions & 0 deletions libs/hostd-types/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ export type IndexTipResponse = ChainIndex

type Peer = {
address: string
inbound: boolean
version: string
firstSeen?: string
connectedSince?: string
syncedBlocks?: number
syncDuration?: number
}

export type SyncerPeersParams = void
Expand Down
16 changes: 8 additions & 8 deletions libs/walletd-mock/src/mocks/peers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import { Page } from 'playwright'
export function getMockPeersResponse(): SyncerPeersResponse {
return [
{
addr: '51.81.242.140:9881',
address: '51.81.242.140:9881',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T17:14:43Z',
connectedSince: '2024-03-25T21:08:49Z',
syncDuration: 1321006459,
},
{
addr: '3.36.68.121:9881',
address: '3.36.68.121:9881',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T13:39:10Z',
connectedSince: '2024-03-25T21:08:50Z',
syncDuration: 4230014834,
},
{
addr: '185.200.116.131:9807',
address: '185.200.116.131:9807',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T17:14:43Z',
Expand All @@ -29,15 +29,15 @@ export function getMockPeersResponse(): SyncerPeersResponse {
syncDuration: 6018991169,
},
{
addr: '62.30.63.90:9881',
address: '62.30.63.90:9881',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T13:39:10Z',
connectedSince: '2024-03-25T21:09:07Z',
syncDuration: 6341708209,
},
{
addr: '43.203.121.70:9881',
address: '43.203.121.70:9881',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T17:14:44Z',
Expand All @@ -46,15 +46,15 @@ export function getMockPeersResponse(): SyncerPeersResponse {
syncDuration: 6860545337,
},
{
addr: '23.239.8.40:9881',
address: '23.239.8.40:9881',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T13:39:10Z',
connectedSince: '2024-03-25T21:09:08Z',
syncDuration: 580416082,
},
{
addr: '141.94.161.198:9881',
address: '141.94.161.198:9881',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T13:39:10Z',
Expand All @@ -63,7 +63,7 @@ export function getMockPeersResponse(): SyncerPeersResponse {
syncDuration: 4894896166,
},
{
addr: '64.227.180.244:9881',
address: '64.227.180.244:9881',
inbound: false,
version: '1.5.4',
firstSeen: '2024-03-20T13:39:25Z',
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-types/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SpendPolicy, UnlockConditions } from '@siafoundation/types'

export type GatewayPeer = {
addr: string
address: string
inbound: boolean
version: string
firstSeen?: string
Expand Down

0 comments on commit d794e60

Please sign in to comment.