mirror of
https://github.com/status-im/open-bounty.git
synced 2025-02-09 08:03:41 +00:00
Scheduled task for re-deploying failed bounty contracts
* as a secondary pre-caution, look for bounty issues where the deploy contract transaction has failed and re-deploy the contract (Fixes #32)
This commit is contained in:
parent
b788f91149
commit
f0f7bf9c7d
@ -206,6 +206,20 @@ SET
|
|||||||
|
|
||||||
-- Bounties ------------------------------------------------------------------------
|
-- Bounties ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
-- :name pending-contracts :? :*
|
||||||
|
-- :doc bounty issues where deploy contract has failed
|
||||||
|
SELECT
|
||||||
|
i.issue_id AS issue_id,
|
||||||
|
u.address AS owner_address
|
||||||
|
FROM issues i, users u, repositories r
|
||||||
|
WHERE
|
||||||
|
r.user_id = u.id
|
||||||
|
AND i.repo_id = r.repo_id
|
||||||
|
AND i.transaction_hash IS NULL
|
||||||
|
AND i.contract_address IS NULL;
|
||||||
|
|
||||||
|
|
||||||
-- :name pending-bounties-list :? :*
|
-- :name pending-bounties-list :? :*
|
||||||
-- :doc lists all recently closed issues awaiting to be signed
|
-- :doc lists all recently closed issues awaiting to be signed
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defn pending-contracts
|
||||||
|
[]
|
||||||
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
|
(db/pending-contracts con-db)))
|
||||||
|
|
||||||
(defn list-owner-bounties
|
(defn list-owner-bounties
|
||||||
[owner]
|
[owner]
|
||||||
(jdbc/with-db-connection [con-db *db*]
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
|
@ -43,6 +43,20 @@
|
|||||||
balance
|
balance
|
||||||
balance-str))))))
|
balance-str))))))
|
||||||
|
|
||||||
|
|
||||||
|
(defn deploy-pending-contracts
|
||||||
|
"Under high-concurrency circumstances or in case geth is in defunct state, a bounty contract may not deploy successfully when the bounty label is addded to an issue. This function deploys such contracts."
|
||||||
|
[]
|
||||||
|
(doseq [{issue-id :issue_id
|
||||||
|
owner-address :owner_address} (db-bounties/pending-contracts)]
|
||||||
|
(log/debug "Trying to re-deploy failed bounty contract deployment, issue-id:" issue-id)
|
||||||
|
(let [transaction-hash (eth/deploy-contract owner-address)]
|
||||||
|
(if (nil? transaction-hash)
|
||||||
|
(log/error "Failed to deploy contract to" owner-address)
|
||||||
|
(log/info "Contract deployed, transaction-hash:"
|
||||||
|
transaction-hash ))
|
||||||
|
(issues/update-transaction-hash issue-id transaction-hash))))
|
||||||
|
|
||||||
(defn self-sign-bounty
|
(defn self-sign-bounty
|
||||||
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
"Walks through all issues eligible for bounty payout and signs corresponding transaction"
|
||||||
[]
|
[]
|
||||||
@ -130,6 +144,7 @@
|
|||||||
(defn run-periodic-tasks [time]
|
(defn run-periodic-tasks [time]
|
||||||
(do
|
(do
|
||||||
(log/debug "run-periodic-tasks" time)
|
(log/debug "run-periodic-tasks" time)
|
||||||
|
(deploy-pending-contracts)
|
||||||
(update-issue-contract-address)
|
(update-issue-contract-address)
|
||||||
(update-confirm-hash)
|
(update-confirm-hash)
|
||||||
(update-payout-receipt)
|
(update-payout-receipt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user