Skip to content

Commit 70aa137

Browse files
update jape dependency
1 parent b236c4a commit 70aa137

File tree

4 files changed

+56
-55
lines changed

4 files changed

+56
-55
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
19-
- name: Jape Analyzer
20-
uses: SiaFoundation/action-golang-analysis@HEAD
21-
with:
22-
analyzers: |
23-
go.sia.tech/jape.Analyzer@master
24-
directories: |
25-
api
19+
# - name: Jape Analyzer
20+
# uses: SiaFoundation/action-golang-analysis@HEAD
21+
# with:
22+
# analyzers: |
23+
# go.sia.tech/jape.Analyzer@master
24+
# directories: |
25+
# api

api/client.go

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package api
22

33
import (
4+
"context"
45
"fmt"
56
"net/url"
67
"strconv"
@@ -28,69 +29,69 @@ func NewClient(addr, password string) *Client {
2829

2930
// State returns information about the current state of the explored daemon.
3031
func (c *Client) State() (resp StateResponse, err error) {
31-
err = c.c.GET("/state", &resp)
32+
err = c.c.GET(context.Background(), "/state", &resp)
3233
return
3334
}
3435

3536
// TxpoolBroadcast broadcasts a set of transaction to the network.
3637
func (c *Client) TxpoolBroadcast(txns []types.Transaction, v2txns []types.V2Transaction) (err error) {
37-
err = c.c.POST("/txpool/broadcast", TxpoolBroadcastRequest{txns, v2txns}, nil)
38+
err = c.c.POST(context.Background(), "/txpool/broadcast", TxpoolBroadcastRequest{txns, v2txns}, nil)
3839
return
3940
}
4041

4142
// TxpoolTransactions returns all transactions in the transaction pool.
4243
func (c *Client) TxpoolTransactions() (txns []types.Transaction, v2txns []types.V2Transaction, err error) {
4344
var resp TxpoolTransactionsResponse
44-
err = c.c.GET("/txpool/transactions", &resp)
45+
err = c.c.GET(context.Background(), "/txpool/transactions", &resp)
4546
return resp.Transactions, resp.V2Transactions, err
4647
}
4748

4849
// TxpoolFee returns the recommended fee (per weight unit) to ensure a high
4950
// probability of inclusion in the next block.
5051
func (c *Client) TxpoolFee() (resp types.Currency, err error) {
51-
err = c.c.GET("/txpool/fee", &resp)
52+
err = c.c.GET(context.Background(), "/txpool/fee", &resp)
5253
return
5354
}
5455

5556
// SyncerConnect adds the address as a peer of the syncer.
5657
func (c *Client) SyncerConnect(addr string) (err error) {
57-
err = c.c.POST("/syncer/connect", addr, nil)
58+
err = c.c.POST(context.Background(), "/syncer/connect", addr, nil)
5859
return
5960
}
6061

6162
// SyncerPeers returns the peers of the syncer.
6263
func (c *Client) SyncerPeers() (resp []string, err error) {
63-
err = c.c.GET("/syncer/peers", &resp)
64+
err = c.c.GET(context.Background(), "/syncer/peers", &resp)
6465
return
6566
}
6667

6768
// SyncerBroadcastBlock broadcasts a block to all peers.
6869
func (c *Client) SyncerBroadcastBlock(b types.Block) (err error) {
69-
err = c.c.POST("/syncer/broadcast/block", b, nil)
70+
err = c.c.POST(context.Background(), "/syncer/broadcast/block", b, nil)
7071
return
7172
}
7273

7374
// ConsensusTip returns the current tip of the chain manager.
7475
func (c *Client) ConsensusTip() (resp types.ChainIndex, err error) {
75-
err = c.c.GET("/consensus/tip", &resp)
76+
err = c.c.GET(context.Background(), "/consensus/tip", &resp)
7677
return
7778
}
7879

7980
// Tip returns the current tip of the explorer.
8081
func (c *Client) Tip() (resp types.ChainIndex, err error) {
81-
err = c.c.GET("/explorer/tip", &resp)
82+
err = c.c.GET(context.Background(), "/explorer/tip", &resp)
8283
return
8384
}
8485

8586
// BestIndex returns the chain index at the specified height.
8687
func (c *Client) BestIndex(height uint64) (resp types.ChainIndex, err error) {
87-
err = c.c.GET(fmt.Sprintf("/consensus/tip/%d", height), &resp)
88+
err = c.c.GET(context.Background(), fmt.Sprintf("/consensus/tip/%d", height), &resp)
8889
return
8990
}
9091

9192
// ConsensusNetwork returns the network parameters of the consensus set.
9293
func (c *Client) ConsensusNetwork() (n *consensus.Network, err error) {
93-
err = c.c.GET("/consensus/network", &n)
94+
err = c.c.GET(context.Background(), "/consensus/network", &n)
9495
return
9596
}
9697

@@ -102,186 +103,186 @@ func (c *Client) ConsensusState() (state consensus.State, err error) {
102103
return
103104
}
104105
}
105-
err = c.c.GET("/consensus/state", &state)
106+
err = c.c.GET(context.Background(), "/consensus/state", &state)
106107
state.Network = c.n
107108
return
108109
}
109110

110111
// Block returns the block with the specified ID.
111112
func (c *Client) Block(id types.BlockID) (resp explorer.Block, err error) {
112-
err = c.c.GET(fmt.Sprintf("/blocks/%s", id), &resp)
113+
err = c.c.GET(context.Background(), fmt.Sprintf("/blocks/%s", id), &resp)
113114
return
114115
}
115116

116117
// Transaction returns the transaction with the specified ID.
117118
func (c *Client) Transaction(id types.TransactionID) (resp explorer.Transaction, err error) {
118-
err = c.c.GET(fmt.Sprintf("/transactions/%s", id), &resp)
119+
err = c.c.GET(context.Background(), fmt.Sprintf("/transactions/%s", id), &resp)
119120
return
120121
}
121122

122123
// Transactions returns the transactions with the specified IDs.
123124
func (c *Client) Transactions(ids []types.TransactionID) (resp []explorer.Transaction, err error) {
124-
err = c.c.POST("/transactions", ids, &resp)
125+
err = c.c.POST(context.Background(), "/transactions", ids, &resp)
125126
return
126127
}
127128

128129
// TransactionChainIndices returns chain indices a transaction was
129130
// included in.
130131
func (c *Client) TransactionChainIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error) {
131-
err = c.c.GET(fmt.Sprintf("/transactions/%s/indices?offset=%d&limit=%d", id, offset, limit), &resp)
132+
err = c.c.GET(context.Background(), fmt.Sprintf("/transactions/%s/indices?offset=%d&limit=%d", id, offset, limit), &resp)
132133
return
133134
}
134135

135136
// V2Transaction returns the v2 transaction with the specified ID.
136137
func (c *Client) V2Transaction(id types.TransactionID) (resp explorer.V2Transaction, err error) {
137-
err = c.c.GET(fmt.Sprintf("/v2/transactions/%s", id), &resp)
138+
err = c.c.GET(context.Background(), fmt.Sprintf("/v2/transactions/%s", id), &resp)
138139
return
139140
}
140141

141142
// V2Transactions returns the v2 transactions with the specified IDs.
142143
func (c *Client) V2Transactions(ids []types.TransactionID) (resp []explorer.V2Transaction, err error) {
143-
err = c.c.POST("/v2/transactions", ids, &resp)
144+
err = c.c.POST(context.Background(), "/v2/transactions", ids, &resp)
144145
return
145146
}
146147

147148
// V2TransactionChainIndices returns chain indices a v2 transaction was
148149
// included in.
149150
func (c *Client) V2TransactionChainIndices(id types.TransactionID, offset, limit uint64) (resp []types.ChainIndex, err error) {
150-
err = c.c.GET(fmt.Sprintf("/v2/transactions/%s/indices?offset=%d&limit=%d", id, offset, limit), &resp)
151+
err = c.c.GET(context.Background(), fmt.Sprintf("/v2/transactions/%s/indices?offset=%d&limit=%d", id, offset, limit), &resp)
151152
return
152153
}
153154

154155
// AddressSiacoinUTXOs returns the specified address' unspent outputs.
155156
func (c *Client) AddressSiacoinUTXOs(address types.Address, offset, limit uint64) (resp []explorer.SiacoinOutput, err error) {
156-
err = c.c.GET(fmt.Sprintf("/addresses/%s/utxos/siacoin?offset=%d&limit=%d", address, offset, limit), &resp)
157+
err = c.c.GET(context.Background(), fmt.Sprintf("/addresses/%s/utxos/siacoin?offset=%d&limit=%d", address, offset, limit), &resp)
157158
return
158159
}
159160

160161
// AddressSiafundUTXOs returns the specified address' unspent outputs.
161162
func (c *Client) AddressSiafundUTXOs(address types.Address, offset, limit uint64) (resp []explorer.SiafundOutput, err error) {
162-
err = c.c.GET(fmt.Sprintf("/addresses/%s/utxos/siafund?offset=%d&limit=%d", address, offset, limit), &resp)
163+
err = c.c.GET(context.Background(), fmt.Sprintf("/addresses/%s/utxos/siafund?offset=%d&limit=%d", address, offset, limit), &resp)
163164
return
164165
}
165166

166167
// OutputSiacoin returns the specified siacoin output.
167168
func (c *Client) OutputSiacoin(id types.SiacoinOutputID) (resp explorer.SiacoinOutput, err error) {
168-
err = c.c.GET(fmt.Sprintf("/outputs/siacoin/%s", id), &resp)
169+
err = c.c.GET(context.Background(), fmt.Sprintf("/outputs/siacoin/%s", id), &resp)
169170
return
170171
}
171172

172173
// OutputSiafund returns the specified siafund output.
173174
func (c *Client) OutputSiafund(id types.SiafundOutputID) (resp explorer.SiafundOutput, err error) {
174-
err = c.c.GET(fmt.Sprintf("/outputs/siafund/%s", id), &resp)
175+
err = c.c.GET(context.Background(), fmt.Sprintf("/outputs/siafund/%s", id), &resp)
175176
return
176177
}
177178

178179
// AddressEvents returns the specified address' events.
179180
func (c *Client) AddressEvents(address types.Address, offset, limit uint64) (resp []explorer.Event, err error) {
180-
err = c.c.GET(fmt.Sprintf("/addresses/%s/events?offset=%d&limit=%d", address, offset, limit), &resp)
181+
err = c.c.GET(context.Background(), fmt.Sprintf("/addresses/%s/events?offset=%d&limit=%d", address, offset, limit), &resp)
181182
return
182183
}
183184

184185
// AddressUnconfirmedEvents returns the specified address' unconfirmed events.
185186
func (c *Client) AddressUnconfirmedEvents(address types.Address) (resp []explorer.Event, err error) {
186-
err = c.c.GET(fmt.Sprintf("/addresses/%s/events/unconfirmed", address), &resp)
187+
err = c.c.GET(context.Background(), fmt.Sprintf("/addresses/%s/events/unconfirmed", address), &resp)
187188
return
188189
}
189190

190191
// Event returns the specified event.
191192
func (c *Client) Event(id types.Hash256) (resp explorer.Event, err error) {
192-
err = c.c.GET(fmt.Sprintf("/events/%s", id), &resp)
193+
err = c.c.GET(context.Background(), fmt.Sprintf("/events/%s", id), &resp)
193194
return
194195
}
195196

196197
// AddressBalance returns the specified address' balance.
197198
func (c *Client) AddressBalance(address types.Address) (resp AddressBalanceResponse, err error) {
198-
err = c.c.GET(fmt.Sprintf("/addresses/%s/balance", address), &resp)
199+
err = c.c.GET(context.Background(), fmt.Sprintf("/addresses/%s/balance", address), &resp)
199200
return
200201
}
201202

202203
// Contract returns the file contract with the specified ID.
203204
func (c *Client) Contract(id types.FileContractID) (resp explorer.ExtendedFileContract, err error) {
204-
err = c.c.GET(fmt.Sprintf("/contracts/%s", id), &resp)
205+
err = c.c.GET(context.Background(), fmt.Sprintf("/contracts/%s", id), &resp)
205206
return
206207
}
207208

208209
// Contracts returns the contracts with the specified IDs.
209210
func (c *Client) Contracts(ids []types.FileContractID) (resp []explorer.ExtendedFileContract, err error) {
210-
err = c.c.POST("/contracts", ids, &resp)
211+
err = c.c.POST(context.Background(), "/contracts", ids, &resp)
211212
return
212213
}
213214

214215
// ContractsKey returns the contracts for a particular ed25519 key.
215216
func (c *Client) ContractsKey(key types.PublicKey) (resp []explorer.ExtendedFileContract, err error) {
216-
err = c.c.GET(fmt.Sprintf("/pubkey/%s/contracts", key), &resp)
217+
err = c.c.GET(context.Background(), fmt.Sprintf("/pubkey/%s/contracts", key), &resp)
217218
return
218219
}
219220

220221
// ContractRevisions returns all the revisions of the contract with the
221222
// specified ID.
222223
func (c *Client) ContractRevisions(id types.FileContractID) (resp []explorer.ExtendedFileContract, err error) {
223-
err = c.c.GET(fmt.Sprintf("/contracts/%s/revisions", id), &resp)
224+
err = c.c.GET(context.Background(), fmt.Sprintf("/contracts/%s/revisions", id), &resp)
224225
return
225226
}
226227

227228
// V2Contract returns the v2 file contract with the specified ID.
228229
func (c *Client) V2Contract(id types.FileContractID) (resp explorer.V2FileContract, err error) {
229-
err = c.c.GET(fmt.Sprintf("/v2/contracts/%s", id), &resp)
230+
err = c.c.GET(context.Background(), fmt.Sprintf("/v2/contracts/%s", id), &resp)
230231
return
231232
}
232233

233234
// V2Contracts returns the v2 contracts with the specified IDs.
234235
func (c *Client) V2Contracts(ids []types.FileContractID) (resp []explorer.V2FileContract, err error) {
235-
err = c.c.POST("/v2/contracts", ids, &resp)
236+
err = c.c.POST(context.Background(), "/v2/contracts", ids, &resp)
236237
return
237238
}
238239

239240
// V2ContractRevisions returns all the revisions of the contract with the
240241
// specified ID.
241242
func (c *Client) V2ContractRevisions(id types.FileContractID) (resp []explorer.V2FileContract, err error) {
242-
err = c.c.GET(fmt.Sprintf("/v2/contracts/%s/revisions", id), &resp)
243+
err = c.c.GET(context.Background(), fmt.Sprintf("/v2/contracts/%s/revisions", id), &resp)
243244
return
244245
}
245246

246247
// V2ContractsKey returns the v2 contracts for a particular ed25519 key.
247248
func (c *Client) V2ContractsKey(key types.PublicKey) (resp []explorer.V2FileContract, err error) {
248-
err = c.c.GET(fmt.Sprintf("/v2/pubkey/%s/contracts", key), &resp)
249+
err = c.c.GET(context.Background(), fmt.Sprintf("/v2/pubkey/%s/contracts", key), &resp)
249250
return
250251
}
251252

252253
// Host returns information about the host with a given ed25519 key.
253254
func (c *Client) Host(key types.PublicKey) (resp explorer.Host, err error) {
254-
err = c.c.GET(fmt.Sprintf("/hosts/%s", key), &resp)
255+
err = c.c.GET(context.Background(), fmt.Sprintf("/hosts/%s", key), &resp)
255256
return
256257
}
257258

258259
// ScanHost triggers a manual host scan.
259260
func (c *Client) ScanHost(key types.PublicKey) (resp explorer.HostScan, err error) {
260-
err = c.c.POST(fmt.Sprintf("/hosts/%s/scan", key), nil, &resp)
261+
err = c.c.POST(context.Background(), fmt.Sprintf("/hosts/%s/scan", key), nil, &resp)
261262
return
262263
}
263264

264265
// BlockMetrics returns the most recent metrics about the Sia blockchain.
265266
func (c *Client) BlockMetrics() (resp explorer.Metrics, err error) {
266-
err = c.c.GET("/metrics/block", &resp)
267+
err = c.c.GET(context.Background(), "/metrics/block", &resp)
267268
return
268269
}
269270

270271
// BlockMetricsID returns various metrics about Sia at the given block ID.
271272
func (c *Client) BlockMetricsID(id types.BlockID) (resp explorer.Metrics, err error) {
272-
err = c.c.GET(fmt.Sprintf("/metrics/block/%s", id), &resp)
273+
err = c.c.GET(context.Background(), fmt.Sprintf("/metrics/block/%s", id), &resp)
273274
return
274275
}
275276

276277
// HostMetrics returns various metrics about currently available hosts.
277278
func (c *Client) HostMetrics() (resp explorer.HostMetrics, err error) {
278-
err = c.c.GET("/metrics/host", &resp)
279+
err = c.c.GET(context.Background(), "/metrics/host", &resp)
279280
return
280281
}
281282

282283
// Search returns what type of object an ID is.
283284
func (c *Client) Search(id string) (resp explorer.SearchType, err error) {
284-
err = c.c.GET(fmt.Sprintf("/search/%s", id), &resp)
285+
err = c.c.GET(context.Background(), fmt.Sprintf("/search/%s", id), &resp)
285286
return
286287
}
287288

@@ -292,12 +293,12 @@ func (c *Client) HostsList(params explorer.HostQuery, sortBy explorer.HostSortCo
292293
v.Add("dir", string(dir))
293294
v.Add("offset", strconv.FormatUint(offset, 10))
294295
v.Add("limit", strconv.FormatUint(limit, 10))
295-
err = c.c.POST("/hosts?"+v.Encode(), params, &resp)
296+
err = c.c.POST(context.Background(), "/hosts?"+v.Encode(), params, &resp)
296297
return
297298
}
298299

299300
// ExchangeRate returns the value of 1 SC in the specified currency.
300301
func (c *Client) ExchangeRate(currency string) (resp float64, err error) {
301-
err = c.c.GET(fmt.Sprintf("/exchange-rate/siacoin/%s", currency), &resp)
302+
err = c.c.GET(context.Background(), fmt.Sprintf("/exchange-rate/siacoin/%s", currency), &resp)
302303
return
303304
}

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module go.sia.tech/explored
22

3-
go 1.23.1
3+
go 1.23.2
44

5-
toolchain go1.24.1
5+
toolchain go1.24.2
66

77
require (
88
github.com/google/go-cmp v0.7.0
99
github.com/mattn/go-sqlite3 v1.14.28
1010
github.com/oschwald/geoip2-golang v1.11.0
1111
go.sia.tech/core v0.11.0
1212
go.sia.tech/coreutils v0.13.1
13-
go.sia.tech/jape v0.12.1
13+
go.sia.tech/jape v0.13.0
1414
go.uber.org/zap v1.27.0
1515
gopkg.in/yaml.v3 v3.0.1
1616
lukechampine.com/frand v1.5.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ go.sia.tech/core v0.11.0 h1:Rfb1D6DMs96bwhArluvYWqa+xlcgRAqU9uOSy75h58M=
4949
go.sia.tech/core v0.11.0/go.mod h1:1qqyJUN04kEMEBUfofp0Pkf9s2RnHzGKfy+Hec2dbCk=
5050
go.sia.tech/coreutils v0.13.1 h1:wmRL+eAc+KM/2qjmjSJ6jM2se2qOVq5b4SkpktOT/QE=
5151
go.sia.tech/coreutils v0.13.1/go.mod h1:ZLPl0GBcQEYvnBqauc7ZWydAMplfZ6/qd7jGjSo+4X0=
52-
go.sia.tech/jape v0.12.1 h1:xr+o9V8FO8ScRqbSaqYf9bjj1UJ2eipZuNcI1nYousU=
53-
go.sia.tech/jape v0.12.1/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4=
52+
go.sia.tech/jape v0.13.0 h1:kbt1DABo4Ot90BWB8Jp0pVIRstTgVnqu2Brp09KKwqk=
53+
go.sia.tech/jape v0.13.0/go.mod h1:0AKGMZZKD/fUQXOT747F6A8ZIxooEb2Fr9TdN2eSye4=
5454
go.sia.tech/mux v1.4.0 h1:LgsLHtn7l+25MwrgaPaUCaS8f2W2/tfvHIdXps04sVo=
5555
go.sia.tech/mux v1.4.0/go.mod h1:iNFi9ifFb2XhuD+LF4t2HBb4Mvgq/zIPKqwXU/NlqHA=
5656
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=

0 commit comments

Comments
 (0)