Improve recovery mechanism
Only consider un-mined contract deployments older than 1 hour as failed
This commit is contained in:
parent
c5cc94fd81
commit
7285987292
|
@ -173,6 +173,21 @@ AND i.repo_id = r.repo_id
|
|||
AND i.contract_address IS NULL
|
||||
AND i.transaction_hash IS NOT NULL;
|
||||
|
||||
|
||||
-- :name list-failed-deployments :? :*
|
||||
-- :doc retrieves failed contract deployments
|
||||
SELECT
|
||||
i.issue_id as issue_id,
|
||||
i.transaction_hash as transaction_hash,
|
||||
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.contract_address IS NULL
|
||||
AND i.transaction_hash IS NOT NULL
|
||||
AND i.updated < now() at time zone 'UTC' < interval '1 hour';
|
||||
|
||||
|
||||
-- Pull Requests -------------------------------------------------------------------
|
||||
|
||||
-- :name save-pull-request! :! :n
|
||||
|
|
|
@ -46,6 +46,12 @@
|
|||
(jdbc/with-db-connection [con-db *db*]
|
||||
(db/list-pending-deployments con-db)))
|
||||
|
||||
|
||||
(defn list-failed-deployments
|
||||
[]
|
||||
(jdbc/with-db-connection [con-db *db*]
|
||||
(db/list-failed-deployments con-db)))
|
||||
|
||||
(defn get-balance
|
||||
[contract-address]
|
||||
(jdbc/with-db-connection [con-db *db*]
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
[]
|
||||
(doseq [{issue-id :issue_id
|
||||
transaction-hash :transaction_hash
|
||||
owner-address :owner_address} (issues/list-pending-deployments)]
|
||||
owner-address :owner_address} (issues/list-failed-deployments)]
|
||||
(when (nil? (eth/get-transaction-receipt transaction-hash))
|
||||
(log/info "Detected nil transaction receipt for pending contract deployment for issue" issue-id ", re-deploying contract")
|
||||
(deploy-contract owner-address issue-id))))
|
||||
|
|
Loading…
Reference in New Issue