/
type.go
53 lines (41 loc) · 1.03 KB
/
type.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
42
43
44
45
46
47
48
49
50
51
52
53
package pbsol
import (
"time"
"github.com/mr-tron/base58"
"go.uber.org/zap/zapcore"
)
func (x *Block) GetFirehoseBlockID() string {
return x.Blockhash
}
func (x *Block) GetFirehoseBlockNumber() uint64 {
return x.Slot
}
func (b *Block) GetFirehoseBlockParentNumber() uint64 {
return b.ParentSlot
}
func (b *Block) GetFirehoseBlockVersion() int32 {
return 1
}
func (x *Block) GetFirehoseBlockParentID() string {
return x.PreviousBlockhash
}
func (x *Block) GetFirehoseBlockTime() time.Time {
if x.BlockTime == nil {
return time.Unix(0, 0)
}
return time.Unix(int64(x.BlockTime.Timestamp), 0)
}
func (x *Block) GetFirehoseBlockLIBNum() uint64 {
return x.ParentSlot
}
func (x *Block) MarshalLogObject(encoder zapcore.ObjectEncoder) error {
encoder.AddUint64("num", x.Slot)
encoder.AddString("id", x.Blockhash)
return nil
}
func (x *ConfirmedTransaction) AsBase58String() string {
return base58.Encode(x.Transaction.Signatures[0])
}
func NewUnixTimestamp(t time.Time) *UnixTimestamp {
return &UnixTimestamp{Timestamp: t.Unix()}
}