2019-01-31 23:14:42 +00:00
|
|
|
// VulcanizeDB
|
2019-03-12 15:46:42 +00:00
|
|
|
// Copyright © 2019 Vulcanize
|
2019-01-31 23:14:42 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package repository
|
2018-11-08 17:07:54 +00:00
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
import "github.com/jmoiron/sqlx"
|
2019-01-31 23:14:42 +00:00
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
func MarkContractWatcherHeaderCheckedInTransaction(headerID int64, tx *sqlx.Tx, checkedHeadersColumn string) error {
|
2018-11-08 17:07:54 +00:00
|
|
|
_, err := tx.Exec(`INSERT INTO public.checked_headers (header_id, `+checkedHeadersColumn+`)
|
2019-02-08 16:35:46 +00:00
|
|
|
VALUES ($1, $2)
|
2018-11-08 17:07:54 +00:00
|
|
|
ON CONFLICT (header_id) DO
|
2019-08-06 21:57:08 +00:00
|
|
|
UPDATE SET `+checkedHeadersColumn+` = checked_headers.`+checkedHeadersColumn+` + 1`, headerID, 1)
|
2018-11-08 17:07:54 +00:00
|
|
|
return err
|
|
|
|
}
|