Open ch40s opened 2 years ago
Example for the 3rd use case:
I picked a random hotspot and compared the bot's output with Helium Explorer. According to the Helium Explorer the hotspot had a "Witness Beacon" activity, 18 witnesses in total, 1 invalid but not from the hotspot we are looking up. The bot's output was //Witness Beacon (Invalid)
because of the if statement below (I added some debug logging to find out):
else if(activity['path'][0]['receipt'] === null){
type = '//Witness Beacon (Invalid)';
}
Field parsing from the API is correct in my opinion because the receipt field was null indeed so I assume that the API results are not interpreted correctly. In this case the result should be defined by the following code snippet instead:
else {
type = '.Witness Beacon';
for(witness of activity['path'][0]['witnesses']){
if (witness['gateway'] === hotspot){
type = '.Witness Beacon';
if(witness['is_valid'] === false){
type = '//Witness Beacon (Invalid)';
details = formatType(witness['invalid_reason']);
meta = 'RSSI: ' + witness['signal'].toString() + 'dBm SNR: ' + witness['snr'].toFixed(1) + ' dB';
}
}
}
That's a redacted snippet from that block in API results that had the valid witness in Explorer and invalid in the bot:
{"type":"poc_receipts_v1",
"time":...,
"secret":"...",
"request_block_hash":"...",
"path":
[{"witnesses":
[
{"timestamp":...},
{"timestamp":...},
...
{"timestamp":...}
],
"receipt":null,
"geocode":{...},
"challengee_owner"..."challengee":"..."
}]
Another example, the bot says "Witness Beacon" and the Explorer says "Broadcasted Beacon" for the same event.
activity['path'][0]['receipt']['gateway']
returns the actual hotspot ID which means it should be logged as .Sent Beacon
however that doesn't work for some reason. I'm wondering if allActivity.hotspot
does not contain the hotspot ID.
My assumption was right, allActivity.hotspot
does not contain the hotspot ID because allActivity is overwritten so allActivity.hotspot
is undefined in those if statements.
Adding const hotspot = allActivity.hotspot;
at the beginning of formatHotspotActivity(allActivity)
and using hotspot
in those if statements later solves the problem for me and brings accurate results. This fixes more inconsistencies that I had noticed, like "Witness Beacon (Invalid)" instead of "Witness Beacon" in some cases.
Comparing the bot's output with Helium Explorer and Hotspotty, I noticed that some activity types are incorrect: