@@ -16,8 +16,7 @@ import (
16
16
)
17
17
18
18
type BandResponse struct {
19
- Height int64 `json:"height,string"`
20
- Result BandResult `json:"result"`
19
+ Request BandResult `json:"request"`
21
20
}
22
21
23
22
type RawRequests struct {
@@ -26,28 +25,11 @@ type RawRequests struct {
26
25
Calldata []byte `json:"calldata,string"`
27
26
}
28
27
29
- type Request struct {
30
- OracleScriptID uint64 `json:"oracle_script_id,string"`
31
- Calldata []byte `json:"calldata,string"`
32
- RequestedValidators []string `json:"requested_validators"`
33
- MinCount uint64 `json:"min_count,string"`
34
- RequestHeight uint64 `json:"request_height,string"`
35
- RequestTime time.Time `json:"request_time"`
36
- ClientID string `json:"client_id"`
37
- RawRequests []RawRequests `json:"raw_requests"`
38
- }
39
-
40
28
type RawReports struct {
41
29
ExternalID uint64 `json:"external_id,string"`
42
30
Data string `json:"data"`
43
31
}
44
32
45
- type Reports struct {
46
- Validator string `json:"validator"`
47
- InBeforeResolve bool `json:"in_before_resolve"`
48
- RawReports []RawReports `json:"raw_reports"`
49
- }
50
-
51
33
type RequestPacketData struct {
52
34
ClientID string `json:"client_id"`
53
35
OracleScriptID uint64 `json:"oracle_script_id,string"`
@@ -66,15 +48,22 @@ type ResponsePacketData struct {
66
48
Result []byte `json:"result,string"`
67
49
}
68
50
69
- type Packet struct {
70
- RequestPacketData RequestPacketData `json:"request_packet_data"`
71
- ResponsePacketData ResponsePacketData `json:"response_packet_data"`
51
+ type PacketResult struct {
52
+ ClientID string `json:"client_id"`
53
+ OracleScriptID int64 `json:"oracle_script_id,string"`
54
+ Calldata []byte `json:"calldata"`
55
+ AskCount uint64 `json:"ask_count,string"`
56
+ MinCount uint64 `json:"min_count,string"`
57
+ RequestID int64 `json:"request_id,string"`
58
+ AnsCount uint64 `json:"ans_count,string"`
59
+ RequestTime int64 `json:"request_time,string"`
60
+ ResolveTime int64 `json:"resolve_time,string"`
61
+ ResolveStatus string `json:"resolve_status"`
62
+ Result []byte `json:"result,string"`
72
63
}
73
64
74
65
type BandResult struct {
75
- Request Request `json:"request"`
76
- Reports []Reports `json:"reports"`
77
- Result Packet `json:"result"`
66
+ Result PacketResult `json:"result"`
78
67
}
79
68
80
69
type LunaPriceCallData struct {
@@ -102,7 +91,7 @@ func (lpcd *LunaPriceCallData) toBytes() []byte {
102
91
var (
103
92
MULTIPLIER = uint64 (1000000000 )
104
93
LUNA_PRICE_CALLDATA = LunaPriceCallData {Multiplier : MULTIPLIER }
105
- LUNA_PRICE_END_POINT = fmt .Sprintf ("/oracle/request_search?oid=13&calldata=%x&min_count=10 &ask_count=16 " , LUNA_PRICE_CALLDATA .toBytes ())
94
+ LUNA_PRICE_END_POINT = fmt .Sprintf ("/oracle/v1/ request_search?oid=13&calldata=%x&min_count=3 &ask_count=4 " , LUNA_PRICE_CALLDATA .toBytes ())
106
95
)
107
96
108
97
func (ps * PriceService ) bandLunaToKrw (logger log.Logger ) {
@@ -142,8 +131,7 @@ func (ps *PriceService) bandLunaToKrw(logger log.Logger) {
142
131
}
143
132
144
133
var lp LunaPrice
145
- Decode (br .Result .Result .ResponsePacketData .Result , & lp )
146
-
134
+ Decode (br .Request .Result .Result , & lp )
147
135
// Find median
148
136
prices := []float64 {}
149
137
for _ , order := range lp .OrderBooks [:4 ] {
@@ -159,7 +147,7 @@ func (ps *PriceService) bandLunaToKrw(logger log.Logger) {
159
147
}
160
148
161
149
price := sdk .NewDecCoinFromDec ("krw" , decAmount )
162
- timestamp := int64 (br .Result .Result . ResponsePacketData .ResolveTime )
150
+ timestamp := int64 (br .Request .Result .ResolveTime )
163
151
164
152
logger .Info (fmt .Sprintf ("Recent luna/krw: %s, timestamp: %d" , price , timestamp ))
165
153
0 commit comments