2018-07-24 16:38:49 +00:00
|
|
|
package pep
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
2018-07-26 18:57:38 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds"
|
2018-07-24 16:38:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type IPepRepository interface {
|
2018-07-26 18:57:38 +00:00
|
|
|
CreatePep(pep price_feeds.PriceUpdate) error
|
2018-07-24 16:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PepRepository struct {
|
|
|
|
db *postgres.DB
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPepRepository(db *postgres.DB) PepRepository {
|
|
|
|
return PepRepository{
|
|
|
|
db: db,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-26 18:57:38 +00:00
|
|
|
func (repository PepRepository) CreatePep(pep price_feeds.PriceUpdate) error {
|
2018-07-24 16:38:49 +00:00
|
|
|
_, err := repository.db.Exec(`INSERT INTO maker.peps (block_number, header_id, usd_value) VALUES ($1, $2, $3::NUMERIC)`, pep.BlockNumber, pep.HeaderID, pep.UsdValue)
|
2018-07-26 18:57:38 +00:00
|
|
|
return err
|
2018-07-24 16:38:49 +00:00
|
|
|
}
|