Skip to content
Snippets Groups Projects
Commit e89c3fc4 authored by vjrj's avatar vjrj
Browse files

Fix for new node checks

parent 52aa4c66
No related branches found
No related tags found
No related merge requests found
...@@ -313,7 +313,9 @@ Future<void> fetchNodesIfNotReady() async { ...@@ -313,7 +313,9 @@ Future<void> fetchNodesIfNotReady() async {
NodeType.duniter, NodeType.duniter,
NodeType.endpoint, NodeType.endpoint,
NodeType.duniterIndexer, NodeType.duniterIndexer,
NodeType.cesiumPlus NodeType.cesiumPlus,
NodeType.datapodEndpoint,
NodeType.ipfsGateway
]) { ]) {
if (NodeManager().nodesWorking(type) < 3) { if (NodeManager().nodesWorking(type) < 3) {
fetchFutures.add(fetchNodes(type, true)); fetchFutures.add(fetchNodes(type, true));
...@@ -600,6 +602,8 @@ Future<NodeCheckResult> _pingNode(String node, NodeType type) async { ...@@ -600,6 +602,8 @@ Future<NodeCheckResult> _pingNode(String node, NodeType type) async {
NodeType.gva: testGVAV1Node, NodeType.gva: testGVAV1Node,
NodeType.endpoint: testEndPointV2, NodeType.endpoint: testEndPointV2,
NodeType.duniterIndexer: testDuniterIndexerV2, NodeType.duniterIndexer: testDuniterIndexerV2,
NodeType.datapodEndpoint: testDuniterDatapodV2,
NodeType.ipfsGateway: testIpfsGateway
}; };
final Future<NodeCheckResult> Function(String node, Duration timeout) final Future<NodeCheckResult> Function(String node, Duration timeout)
...@@ -1178,7 +1182,8 @@ Future<NodeCheckResult> testDuniterDatapodV2( ...@@ -1178,7 +1182,8 @@ Future<NodeCheckResult> testDuniterDatapodV2(
'Node $node has errors: ${removeNewlines(response.linkException!.originalException.toString())}'); 'Node $node has errors: ${removeNewlines(response.linkException!.originalException.toString())}');
result = NodeCheckResult(currentBlock: 0, latency: wrongNodeDuration); result = NodeCheckResult(currentBlock: 0, latency: wrongNodeDuration);
} else { } else {
final int currentBlock = response.data?.hashCode ?? 0; final int currentBlock =
response.data?.profiles_aggregate?.aggregate?.count ?? 0;
result = NodeCheckResult( result = NodeCheckResult(
currentBlock: currentBlock, currentBlock: currentBlock,
latency: currentBlock > 0 ? stopwatch.elapsed : wrongNodeDuration); latency: currentBlock > 0 ? stopwatch.elapsed : wrongNodeDuration);
...@@ -1186,6 +1191,17 @@ Future<NodeCheckResult> testDuniterDatapodV2( ...@@ -1186,6 +1191,17 @@ Future<NodeCheckResult> testDuniterDatapodV2(
return result; return result;
} }
Future<NodeCheckResult> testIpfsGateway(String node, Duration timeout) async {
final Stopwatch stopwatch = Stopwatch()..start();
final Response response = await http.get(Uri.parse(node)).timeout(timeout);
stopwatch.stop();
final Duration latency = stopwatch.elapsed;
final int currentBlock = response.statusCode;
final NodeCheckResult result =
NodeCheckResult(latency: latency, currentBlock: currentBlock);
return result;
}
Future<NodeCheckResult> testGVAV1Node(String node, Duration timeout) async { Future<NodeCheckResult> testGVAV1Node(String node, Duration timeout) async {
final Stopwatch stopwatch = Stopwatch()..start(); final Stopwatch stopwatch = Stopwatch()..start();
// Test GVA with a query // Test GVA with a query
......
...@@ -77,11 +77,17 @@ class NodeListPage extends StatelessWidget { ...@@ -77,11 +77,17 @@ class NodeListPage extends StatelessWidget {
nodes: duniterIndexerNodes, nodes: duniterIndexerNodes,
type: NodeType.duniterIndexer, type: NodeType.duniterIndexer,
currentBlock: duniterIndexerNodes[0].currentBlock), currentBlock: duniterIndexerNodes[0].currentBlock),
NodeListHeader(
type: NodeType.datapodEndpoint,
nodesCount: defaultDatapodEndpointNodes.length),
if (duniterDataNodes.isNotEmpty) if (duniterDataNodes.isNotEmpty)
NodeListWidget( NodeListWidget(
nodes: duniterDataNodes, nodes: duniterDataNodes,
type: NodeType.datapodEndpoint, type: NodeType.datapodEndpoint,
currentBlock: duniterDataNodes[0].currentBlock), currentBlock: duniterDataNodes[0].currentBlock),
NodeListHeader(
type: NodeType.ipfsGateway,
nodesCount: defaultIpfsGateways.length),
if (ipfsGateways.isNotEmpty) if (ipfsGateways.isNotEmpty)
NodeListWidget( NodeListWidget(
nodes: ipfsGateways, nodes: ipfsGateways,
......
...@@ -38,7 +38,7 @@ class NodeListWidget extends StatelessWidget { ...@@ -38,7 +38,7 @@ class NodeListWidget extends StatelessWidget {
title: Text(node.url), title: Text(node.url),
subtitle: node.latency < wrongNode subtitle: node.latency < wrongNode
? Text( ? Text(
'${type != NodeType.cesiumPlus ? 'Current block: ${node.currentBlock}, ' : 'Current docs: ${node.currentBlock}, '}errors: ${node.errors}, latency (ms): ${node.latency}') '${type != NodeType.cesiumPlus ? (type == NodeType.datapodEndpoint ? 'Current profiles: ${node.currentBlock}, ' : 'Current block: ${node.currentBlock}, ') : 'Current docs: ${node.currentBlock}, '}errors: ${node.errors}, latency (ms): ${node.latency}')
: null, : null,
leading: node.currentBlock == currentBlock && leading: node.currentBlock == currentBlock &&
node.latency < wrongNode node.latency < wrongNode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment