-
Notifications
You must be signed in to change notification settings - Fork 19
/
statistics.go
123 lines (98 loc) · 4.33 KB
/
statistics.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Copyright (C) 2023 Gobalsky Labs Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package gql
import (
"context"
"strconv"
"time"
"code.vegaprotocol.io/vega/core/vegatime"
vega "code.vegaprotocol.io/vega/protos/vega/api/v1"
)
type statisticsResolver VegaResolverRoot
func (s *statisticsResolver) CurrentTime(ctx context.Context, obj *vega.Statistics) (int64, error) {
t, err := vegatime.Parse(obj.CurrentTime)
if err != nil {
return 0, err
}
return t.UnixNano(), nil
}
func (s *statisticsResolver) GenesisTime(ctx context.Context, obj *vega.Statistics) (int64, error) {
t, err := vegatime.Parse(obj.GenesisTime)
if err != nil {
return 0, err
}
return t.UnixNano(), nil
}
func (s *statisticsResolver) VegaTime(ctx context.Context, obj *vega.Statistics) (int64, error) {
t, err := vegatime.Parse(obj.VegaTime)
if err != nil {
return 0, err
}
return t.UnixNano(), nil
}
func (s *statisticsResolver) BlockHeight(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.BlockHeight, 10), nil
}
func (s *statisticsResolver) BacklogLength(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.BacklogLength, 10), nil
}
func (s *statisticsResolver) TotalPeers(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TotalPeers, 10), nil
}
func (s *statisticsResolver) TxPerBlock(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TxPerBlock, 10), nil
}
func (s *statisticsResolver) AverageTxBytes(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.AverageTxBytes, 10), nil
}
func (s *statisticsResolver) AverageOrdersPerBlock(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.AverageOrdersPerBlock, 10), nil
}
func (s *statisticsResolver) TradesPerSecond(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TradesPerSecond, 10), nil
}
func (s *statisticsResolver) OrdersPerSecond(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.OrdersPerSecond, 10), nil
}
func (s *statisticsResolver) TotalMarkets(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TotalMarkets, 10), nil
}
func (s *statisticsResolver) TotalAmendOrder(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TotalAmendOrder, 10), nil
}
func (s *statisticsResolver) TotalCancelOrder(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TotalCancelOrder, 10), nil
}
func (s *statisticsResolver) TotalCreateOrder(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TotalCreateOrder, 10), nil
}
func (s *statisticsResolver) EventCount(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.EventCount, 10), nil
}
func (s *statisticsResolver) EventsPerSecond(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.EventsPerSecond, 10), nil
}
func (s *statisticsResolver) TotalOrders(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TotalOrders, 10), nil
}
func (s *statisticsResolver) TotalTrades(ctx context.Context, obj *vega.Statistics) (string, error) {
return strconv.FormatUint(obj.TotalTrades, 10), nil
}
func (s *statisticsResolver) BlockDuration(ctx context.Context, obj *vega.Statistics) (string, error) {
return time.Duration(obj.BlockDuration).String(), nil
}
func (s *statisticsResolver) Status(ctx context.Context, obj *vega.Statistics) (string, error) {
return obj.Status.String(), nil
}