VDB-120 include tic in dent and tend (#118)
* Add constants for TTL and tic for fakeHeader * Add tic to tend transformer * Update tests for tend * Fix string conversion bug in fakes * Fix tend integration tests after staging rebase * Add tic to dent transformer * Update dent tests * Change integration tests to use hardcoded block timestamp
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
package constants
|
||||
|
||||
var DataItemLength = 32
|
||||
|
||||
// TODO Grab this from DB, since it can change through governance
|
||||
var TTL = int64(10800) // 60 * 60 * 3 == 10800 seconds == 3 hours
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
"math/big"
|
||||
)
|
||||
@@ -78,3 +79,15 @@ func convert(conversion string, value string, precision int) string {
|
||||
}
|
||||
return result.Text('f', precision)
|
||||
}
|
||||
|
||||
// Grabs the block timestamp for an headerID, and adds the TTL constant
|
||||
func GetTicInTx(headerID int64, tx *sql.Tx) (int64, error) {
|
||||
var blockTimestamp int64
|
||||
err := tx.QueryRow(`SELECT block_timestamp FROM public.headers WHERE id = $1;`, headerID).Scan(&blockTimestamp)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
tic := blockTimestamp + constants.TTL
|
||||
return tic, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user