Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local sha = require("sha2")
- local inet = component.internet
- local username = "HappyWindinkg" -- Ник кошелька Duino Coin
- while true do
- local socket, reason = inet.connect("149.91.88.18", 6004) -- IP duino-пула - https://server.duinocoin.com/getPool
- if not socket then
- print("Connection failed: " .. reason)
- os.sleep(10) -- Ждем перед повторной попыткой
- goto continue
- end
- print("Asking for a new job for user: " .. username)
- socket.write("JOB," .. username .. ",ESP32") -- ESP32 сложность майнинга
- os.sleep(3)
- local job = socket.read()
- if not job then
- print("Failed to read job")
- socket.close()
- os.sleep(10)
- goto continue
- end
- print("Raw job received: " .. job)
- local newjob = job:sub(4)
- local t = {}
- for s in newjob:gmatch("([^,]+)") do
- t[#t + 1] = s
- end
- if #t < 3 then
- print("Invalid job received: " .. job)
- socket.close()
- os.sleep(10)
- goto continue
- end
- local lastBlockHash, expectedHash, difficulty = table.unpack(t)
- print("Job received: " .. lastBlockHash .. " " .. expectedHash .. " " .. difficulty)
- local range = 100 * tonumber(difficulty) + 1
- local found = false
- for result = 0, range do
- local ducos1 = sha.sha1(lastBlockHash .. tostring(result))
- if ducos1 == expectedHash then
- local send = tostring(result) .. "," .. "LuaMiner 1.0"
- socket.write(send)
- local response = socket.read()
- print("Response: " .. response)
- found = true
- break
- end
- end
- if not found then
- print("No valid hash found")
- end
- socket.close()
- ::continue::
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement