WIP update verifyTimeStamp

This commit is contained in:
M. J. Fromberger
2021-08-27 13:18:31 -07:00
parent 5e11a581a0
commit cb70f03523
+6 -21
View File
@@ -240,27 +240,12 @@ func verifyTx(hash []byte) (*abci.TxResult, error) {
return nil, nil return nil, nil
} }
func verifyTimeStamp(tb string) error { func verifyTimeStamp(tableName string) error {
return db.QueryRow(fmt.Sprintf(`
// We assume the tx indexing time would not exceed 2 second from now SELECT DISTINCT %[1]s.created_at
sqlStmt := sq. FROM %[1]s
Select(fmt.Sprintf("%s.created_at", tb)). WHERE %[1]s.created_at >= ?;
Distinct().From(tb). `, tableName), time.Now().Add(-2*time.Second)).Err()
Where(fmt.Sprintf("%s.created_at >= $1", tb), time.Now().Add(-2*time.Second))
rows, err := sqlStmt.RunWith(db).Query()
if err != nil {
return err
}
defer rows.Close()
if rows.Next() {
var ts string
return rows.Scan(&ts)
}
return errors.New("no result")
} }
func verifyBlock(h int64) (bool, error) { func verifyBlock(h int64) (bool, error) {