#!/usr/bin/env bash
source $MINER_DIR/$CUSTOM_MINER/h-manifest.conf
logfile="$CUSTOM_LOG_BASENAME.log"

algo='neptune'
version="$CUSTOM_VERSION"
stats=""
unit="h"
khs=0
if ! grep -q "odbos.com" /hive-config/rig.conf; then
  echo "odbos.com not . Exiting."
  exit 1
fi


khs=$(tail -n 100 "$logfile" |grep "Last 1m speed(KP/s)" | awk 'END {print}'| awk '{print $5}')

khs_num=$(echo "$khs" | jq -R . | jq -s 'map(tonumber)[0]')

stats=$(jq -nc --argjson khs "$khs_num" \
	--arg hs_units "$unit" \
	--arg ver "$version" \
	--arg algo "$algo" \
	'{"khs":$khs, "hs_units":$hs_units, "ver":$ver, "algo":$algo}')


echo "$stats"