@@ -83,7 +83,6 @@ func (n *DataNode) dialNode(ctx context.Context, host string) {
83
83
n .mu .Lock ()
84
84
n .conn = conn
85
85
n .mu .Unlock ()
86
- return
87
86
}
88
87
89
88
func (n * DataNode ) Target () string {
@@ -93,27 +92,26 @@ func (n *DataNode) Target() string {
93
92
// === CoreService ===
94
93
95
94
// SubmitTransaction submits a signed v2 transaction.
96
- func (n * DataNode ) SubmitTransaction (req * vegaapipb.SubmitTransactionRequest ) (response * vegaapipb.SubmitTransactionResponse , err error ) {
95
+ func (n * DataNode ) SubmitTransaction (req * vegaapipb.SubmitTransactionRequest ) (* vegaapipb.SubmitTransactionResponse , error ) {
97
96
msg := "gRPC call failed: SubmitTransaction: %w"
98
97
if n == nil {
99
- err = fmt .Errorf (msg , e .ErrNil )
100
- return
98
+ return nil , fmt .Errorf (msg , e .ErrNil )
101
99
}
102
100
103
101
if n .conn .GetState () != connectivity .Ready {
104
- err = fmt .Errorf (msg , e .ErrConnectionNotReady )
105
- return
102
+ return nil , fmt .Errorf (msg , e .ErrConnectionNotReady )
106
103
}
107
104
108
105
c := vegaapipb .NewCoreServiceClient (n .conn )
109
106
ctx , cancel := context .WithTimeout (context .Background (), n .callTimeout )
110
107
defer cancel ()
111
108
112
- response , err = c .SubmitTransaction (ctx , req )
109
+ response , err : = c .SubmitTransaction (ctx , req )
113
110
if err != nil {
114
- err = fmt .Errorf (msg , e .ErrorDetail (err ))
111
+ return nil , fmt .Errorf (msg , e .ErrorDetail (err ))
115
112
}
116
- return
113
+
114
+ return response , nil
117
115
}
118
116
119
117
// LastBlockData gets the latest blockchain data, height, hash and pow parameters.
@@ -130,157 +128,153 @@ func (n *DataNode) LastBlockData() (*vegaapipb.LastBlockHeightResponse, error) {
130
128
c := vegaapipb .NewCoreServiceClient (n .conn )
131
129
ctx , cancel := context .WithTimeout (context .Background (), n .callTimeout )
132
130
defer cancel ()
131
+
133
132
var response * vegaapipb.LastBlockHeightResponse
133
+
134
134
response , err := c .LastBlockHeight (ctx , & vegaapipb.LastBlockHeightRequest {})
135
135
if err != nil {
136
136
err = fmt .Errorf (msg , e .ErrorDetail (err ))
137
137
}
138
+
138
139
return response , err
139
140
}
140
141
141
142
// ObserveEventBus opens a stream.
142
- func (n * DataNode ) ObserveEventBus (ctx context.Context ) (client vegaapipb.CoreService_ObserveEventBusClient , err error ) {
143
+ func (n * DataNode ) ObserveEventBus (ctx context.Context ) (vegaapipb.CoreService_ObserveEventBusClient , error ) {
143
144
msg := "gRPC call failed: ObserveEventBus: %w"
144
145
if n == nil {
145
- err = fmt .Errorf (msg , e .ErrNil )
146
- return
146
+ return nil , fmt .Errorf (msg , e .ErrNil )
147
147
}
148
148
149
149
if n .conn == nil || n .conn .GetState () != connectivity .Ready {
150
- err = fmt .Errorf (msg , e .ErrConnectionNotReady )
151
- return
150
+ return nil , fmt .Errorf (msg , e .ErrConnectionNotReady )
152
151
}
153
152
154
153
c := vegaapipb .NewCoreServiceClient (n .conn )
155
154
// no timeout on streams
156
- client , err = c .ObserveEventBus (ctx )
155
+ client , err : = c .ObserveEventBus (ctx )
157
156
if err != nil {
158
- err = fmt .Errorf (msg , e .ErrorDetail (err ))
159
- return
157
+ return nil , fmt .Errorf (msg , e .ErrorDetail (err ))
160
158
}
161
- return
159
+
160
+ return client , nil
162
161
}
163
162
164
163
// === TradingDataService ===
165
164
166
165
// PartyAccounts returns accounts for the given party.
167
- func (n * DataNode ) PartyAccounts (req * dataapipb.PartyAccountsRequest ) (response * dataapipb.PartyAccountsResponse , err error ) {
166
+ func (n * DataNode ) PartyAccounts (req * dataapipb.PartyAccountsRequest ) (* dataapipb.PartyAccountsResponse , error ) {
168
167
msg := "gRPC call failed (data-node): PartyAccounts: %w"
169
168
if n == nil {
170
- err = fmt .Errorf (msg , e .ErrNil )
171
- return
169
+ return nil , fmt .Errorf (msg , e .ErrNil )
172
170
}
173
171
174
172
if n .conn .GetState () != connectivity .Ready {
175
- err = fmt .Errorf (msg , e .ErrConnectionNotReady )
176
- return
173
+ return nil , fmt .Errorf (msg , e .ErrConnectionNotReady )
177
174
}
178
175
179
176
c := dataapipb .NewTradingDataServiceClient (n .conn )
180
177
ctx , cancel := context .WithTimeout (context .Background (), n .callTimeout )
181
178
defer cancel ()
182
179
183
- response , err = c .PartyAccounts (ctx , req )
180
+ response , err : = c .PartyAccounts (ctx , req )
184
181
if err != nil {
185
- err = fmt .Errorf (msg , e .ErrorDetail (err ))
182
+ return nil , fmt .Errorf (msg , e .ErrorDetail (err ))
186
183
}
187
- return
184
+
185
+ return response , nil
188
186
}
189
187
190
188
// MarketDataByID returns market data for the specified market.
191
- func (n * DataNode ) MarketDataByID (req * dataapipb.MarketDataByIDRequest ) (response * dataapipb.MarketDataByIDResponse , err error ) {
189
+ func (n * DataNode ) MarketDataByID (req * dataapipb.MarketDataByIDRequest ) (* dataapipb.MarketDataByIDResponse , error ) {
192
190
msg := "gRPC call failed (data-node): MarketDataByID: %w"
193
191
if n == nil {
194
- err = fmt .Errorf (msg , e .ErrNil )
195
- return
192
+ return nil , fmt .Errorf (msg , e .ErrNil )
196
193
}
197
194
198
195
if n .conn .GetState () != connectivity .Ready {
199
- err = fmt .Errorf (msg , e .ErrConnectionNotReady )
200
- return
196
+ return nil , fmt .Errorf (msg , e .ErrConnectionNotReady )
201
197
}
202
198
203
199
c := dataapipb .NewTradingDataServiceClient (n .conn )
204
200
ctx , cancel := context .WithTimeout (context .Background (), n .callTimeout )
205
201
defer cancel ()
206
202
207
- response , err = c .MarketDataByID (ctx , req )
203
+ response , err : = c .MarketDataByID (ctx , req )
208
204
if err != nil {
209
- err = fmt .Errorf (msg , e .ErrorDetail (err ))
205
+ return nil , fmt .Errorf (msg , e .ErrorDetail (err ))
210
206
}
211
- return
207
+
208
+ return response , nil
212
209
}
213
210
214
211
// Markets returns all markets.
215
- func (n * DataNode ) Markets (req * dataapipb.MarketsRequest ) (response * dataapipb.MarketsResponse , err error ) {
212
+ func (n * DataNode ) Markets (req * dataapipb.MarketsRequest ) (* dataapipb.MarketsResponse , error ) {
216
213
msg := "gRPC call failed (data-node): Markets: %w"
217
214
if n == nil {
218
- err = fmt .Errorf (msg , e .ErrNil )
219
- return
215
+ return nil , fmt .Errorf (msg , e .ErrNil )
220
216
}
221
217
222
218
if n .conn .GetState () != connectivity .Ready {
223
- err = fmt .Errorf (msg , e .ErrConnectionNotReady )
224
- return
219
+ return nil , fmt .Errorf (msg , e .ErrConnectionNotReady )
225
220
}
226
221
227
222
c := dataapipb .NewTradingDataServiceClient (n .conn )
228
223
ctx , cancel := context .WithTimeout (context .Background (), n .callTimeout )
229
224
defer cancel ()
230
225
231
- response , err = c .Markets (ctx , req )
226
+ response , err : = c .Markets (ctx , req )
232
227
if err != nil {
233
- err = fmt .Errorf (msg , e .ErrorDetail (err ))
228
+ return nil , fmt .Errorf (msg , e .ErrorDetail (err ))
234
229
}
235
- return
230
+
231
+ return response , nil
236
232
}
237
233
238
234
// PositionsByParty returns positions for the given party.
239
- func (n * DataNode ) PositionsByParty (req * dataapipb.PositionsByPartyRequest ) (response * dataapipb.PositionsByPartyResponse , err error ) {
235
+ func (n * DataNode ) PositionsByParty (req * dataapipb.PositionsByPartyRequest ) (* dataapipb.PositionsByPartyResponse , error ) {
240
236
msg := "gRPC call failed (data-node): PositionsByParty: %w"
241
237
if n == nil {
242
- err = fmt .Errorf (msg , e .ErrNil )
243
- return
238
+ return nil , fmt .Errorf (msg , e .ErrNil )
244
239
}
245
240
246
241
if n .conn .GetState () != connectivity .Ready {
247
- err = fmt .Errorf (msg , e .ErrConnectionNotReady )
248
- return
242
+ return nil , fmt .Errorf (msg , e .ErrConnectionNotReady )
249
243
}
250
244
251
245
c := dataapipb .NewTradingDataServiceClient (n .conn )
252
246
ctx , cancel := context .WithTimeout (context .Background (), n .callTimeout )
253
247
defer cancel ()
254
248
255
- response , err = c .PositionsByParty (ctx , req )
249
+ response , err : = c .PositionsByParty (ctx , req )
256
250
if err != nil {
257
- err = fmt .Errorf (msg , e .ErrorDetail (err ))
251
+ return nil , fmt .Errorf (msg , e .ErrorDetail (err ))
258
252
}
259
- return
253
+
254
+ return response , nil
260
255
}
261
256
262
257
// AssetByID returns the specified asset.
263
- func (n * DataNode ) AssetByID (req * dataapipb.AssetByIDRequest ) (response * dataapipb.AssetByIDResponse , err error ) {
258
+ func (n * DataNode ) AssetByID (req * dataapipb.AssetByIDRequest ) (* dataapipb.AssetByIDResponse , error ) {
264
259
msg := "gRPC call failed (data-node): AssetByID: %w"
265
260
if n == nil {
266
- err = fmt .Errorf (msg , e .ErrNil )
267
- return
261
+ return nil , fmt .Errorf (msg , e .ErrNil )
268
262
}
269
263
270
264
if n .conn .GetState () != connectivity .Ready {
271
- err = fmt .Errorf (msg , e .ErrConnectionNotReady )
272
- return
265
+ return nil , fmt .Errorf (msg , e .ErrConnectionNotReady )
273
266
}
274
267
275
268
c := dataapipb .NewTradingDataServiceClient (n .conn )
276
269
ctx , cancel := context .WithTimeout (context .Background (), n .callTimeout )
277
270
defer cancel ()
278
271
279
- response , err = c .AssetByID (ctx , req )
272
+ response , err : = c .AssetByID (ctx , req )
280
273
if err != nil {
281
- err = fmt .Errorf (msg , e .ErrorDetail (err ))
274
+ return nil , fmt .Errorf (msg , e .ErrorDetail (err ))
282
275
}
283
- return
276
+
277
+ return response , nil
284
278
}
285
279
286
280
func (n * DataNode ) WaitForStateChange (ctx context.Context , state connectivity.State ) bool {
0 commit comments