forked from archway-network/valuter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.go
39 lines (29 loc) · 874 Bytes
/
database.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package blocksigners
import (
"time"
"github.com/celestiaorg/cosmologger/database"
"github.com/celestiaorg/valuter/types"
)
func DBRowToBlockSignersRecord(row database.RowType) types.BlockSignersRecord {
if row == nil {
return types.BlockSignersRecord{}
}
for i := range row {
if row[i] == nil {
row[i] = ""
}
}
return types.BlockSignersRecord{
BlockHeight: row[database.FIELD_BLOCK_SIGNERS_BLOCK_HEIGHT].(uint64),
ValConsAddr: row[database.FIELD_BLOCK_SIGNERS_VAL_CONS_ADDR].(string),
Time: row[database.FIELD_BLOCK_SIGNERS_TIME].(time.Time),
Signature: row[database.FIELD_BLOCK_SIGNERS_SIGNATURE].(string),
}
}
func DBRowsToBlockSignersRecords(row []database.RowType) []types.BlockSignersRecord {
var res []types.BlockSignersRecord
for i := range row {
res = append(res, DBRowToBlockSignersRecord(row[i]))
}
return res
}