Skip to content

Commit

Permalink
RoutingTableView: gracefully handle missing distance vectors (#9394)
Browse files Browse the repository at this point in the history
The RoutingTableView in the debug UI includes a table over the direct peers of the node:

<img width="516" alt="image" src="https://github.com/near/nearcore/assets/3241341/c8c1f0b8-1e0a-458e-a2ad-f09f20fcb57c">

Each active connection of the node has one row in the table. The last column is populated using the most recent distance vector shared by the direct peer.

In some cases there may be a direct connection for which we have not received a distance vector yet. This PR allows the debug UI to gracefully handle such cases and display "null" instead of producing an error.
  • Loading branch information
saketh-are authored and nikurt committed Aug 24, 2023
1 parent 5bed6b2 commit 45dc42f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/debug-ui/src/RoutingTableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ export const RoutingTableView = ({ addr }: RoutingTableViewProps) => {
<tbody>
{direct_peers.map((peer_id) => {
const peer_label = peerLabels[peer_id];

const peer_distances = routingInfo.peer_distances[peer_id];
const formatted_distances = peer_distances == null ? "null" :
peer_distances.distance.map((x) => x || '_').join(', ');

return (
<tr key={peer_label}>
<td>{peer_id.substring(8, 14)}...</td>
<td>{peer_label}</td>
<td>{routingInfo.peer_distances[peer_id].distance.join(', ')}</td>
<td>{formatted_distances}</td>
</tr>
);
})}
Expand Down

0 comments on commit 45dc42f

Please sign in to comment.