-
Notifications
You must be signed in to change notification settings - Fork 2
/
database.go
41 lines (30 loc) · 899 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
40
41
package blocks
import (
"time"
"github.com/archway-network/cosmologger/database"
"github.com/archway-network/valuter/types"
)
func DBRowToBlockRecord(row database.RowType) types.BlockRecord {
if row == nil {
return types.BlockRecord{}
}
for i := range row {
if row[i] == nil {
row[i] = ""
}
}
return types.BlockRecord{
BlockHash: string(row[database.FIELD_BLOCKS_BLOCK_HASH].([]uint8)),
Height: uint64(row[database.FIELD_BLOCKS_HEIGHT].(int64)),
NumOfTxs: uint64(row[database.FIELD_BLOCKS_NUM_OF_TXS].(int64)),
Time: row[database.FIELD_BLOCKS_TIME].(time.Time),
// Signers: []BlockSignersRecord, //TODO: Check if we really need to have signers here as well
}
}
func DBRowsToBlockRecords(row []database.RowType) []types.BlockRecord {
var res []types.BlockRecord
for i := range row {
res = append(res, DBRowToBlockRecord(row[i]))
}
return res
}