Improve recovery mechanism

Only consider un-mined contract deployments older than 1 hour as
failed
This commit is contained in:
Teemu Patja 2017-05-31 10:44:45 +03:00
parent c5cc94fd81
commit 7285987292
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
3 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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*]

View File

@ -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))))