OT-Hub / OTHub

OT Hub is a community-made project for live insights into the OriginTrail Decentralized Network.
https://othub.origin-trail.network/
MIT License
5 stars 2 forks source link

Help with supporting batch payouts for node on specific blockchain #74

Closed lukeskinner closed 3 years ago

lukeskinner commented 3 years ago

New API call to return jobs which could be payed out. Look at the amount paid out in the DB and compare to the total, use that for if present or not - also check litigation is not failed.

Return a new offer id on each line. No JSON, no XML.

Think about some level of support with cosmic overlay? Think about a script to read this and run docker exec otnode curl -s -X GET http://127.0.0.1:8900/api/latest/payout?offer_id=XXXXX

lukeskinner commented 3 years ago

What does this script do?

This will ask OT Hub for jobs which you are eligible for a payout. From there it will ask your node to payout the jobs via the OT node api. You need to do the setup steps on your node for this to work.

Criteria for jobs being paid out
  1. No prior payout in the last 24 hours
  2. You have not fully paid out the job yet
  3. You have not lost litigation on the job

How to setup

Please note that you will need to do this separately for each identity you want to use it on. Most likely due to current ETH gas prices you will only want to set this up once for the xDai identity.

  1. Go to a folder where you want to save the script (I used ~/scripts)
  2. nano dopayouts
  3. Paste script below:
offersToPayout=$(curl -X GET "https://v5api.othub.info/api/Payouts/getofferidsforpayout/ENTERIDENTITYHERE" -H "accept: text/plain")
for offerID in ${offersToPayout//\\n/ }
do
echo "Asking node to pay out offer ID $offerID"
docker exec otnode curl -s -X GET "http://127.0.0.1:8900/api/latest/payout?offer_id=$offerID"
done
  1. Edit the identity where it says ENTERIDENTITYHERE. This should be your ERC Identity that starts with 0x.
  2. Save file
  3. Run the following command in the same folder:
    bash dopayouts

In the future you just need to do step 6 to repeat the process.