Skip to content

Commit c7f6cea

Browse files
committed
Delete affinity in algod
1 parent 86fd07e commit c7f6cea

File tree

3 files changed

+15
-80
lines changed

3 files changed

+15
-80
lines changed

daemon/algod/api/client/restClient.go

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ const (
4646
maxRawResponseBytes = 50e6
4747
)
4848

49-
// APIVersion is used to define which server side API version would be used when making http requests to the server
50-
type APIVersion string
51-
52-
const (
53-
// APIVersionV1 suggests that the RestClient would use v1 calls whenever it's available for the given request.
54-
APIVersionV1 APIVersion = "v1"
55-
// APIVersionV2 suggests that the RestClient would use v2 calls whenever it's available for the given request.
56-
APIVersionV2 APIVersion = "v2"
57-
)
58-
5949
// rawRequestPaths is a set of paths where the body should not be urlencoded
6050
var rawRequestPaths = map[string]bool{
6151
"/v1/transactions": true,
@@ -91,27 +81,18 @@ func (e HTTPError) Error() string {
9181

9282
// RestClient manages the REST interface for a calling user.
9383
type RestClient struct {
94-
serverURL url.URL
95-
apiToken string
96-
versionAffinity APIVersion
84+
serverURL url.URL
85+
apiToken string
9786
}
9887

9988
// MakeRestClient is the factory for constructing a RestClient for a given endpoint
10089
func MakeRestClient(url url.URL, apiToken string) RestClient {
10190
return RestClient{
102-
serverURL: url,
103-
apiToken: apiToken,
104-
versionAffinity: APIVersionV1,
91+
serverURL: url,
92+
apiToken: apiToken,
10593
}
10694
}
10795

108-
// SetAPIVersionAffinity sets the client affinity to use a specific version of the API
109-
func (client *RestClient) SetAPIVersionAffinity(affinity APIVersion) (previousAffinity APIVersion) {
110-
previousAffinity = client.versionAffinity
111-
client.versionAffinity = affinity
112-
return
113-
}
114-
11596
// filterASCII filter out the non-ascii printable characters out of the given input string.
11697
// It's used as a security qualifier before adding network provided data into an error message.
11798
// The function allows only characters in the range of [32..126], which excludes all the
@@ -251,31 +232,13 @@ func (client RestClient) post(response interface{}, path string, request interfa
251232
// the StatusResponse includes data like the consensus version and current round
252233
// Not supported
253234
func (client RestClient) Status() (response generatedV2.NodeStatusResponse, err error) {
254-
switch client.versionAffinity {
255-
case APIVersionV2:
256-
err = client.get(&response, "/v2/status", nil)
257-
default:
258-
var nodeStatus v1.NodeStatus
259-
err = client.get(&nodeStatus, "/v1/status", nil)
260-
if err == nil {
261-
response = fillNodeStatusResponse(nodeStatus)
262-
}
263-
}
235+
err = client.get(&response, "/v2/status", nil)
264236
return
265237
}
266238

267239
// WaitForBlock returns the node status after waiting for the given round.
268240
func (client RestClient) WaitForBlock(round basics.Round) (response generatedV2.NodeStatusResponse, err error) {
269-
switch client.versionAffinity {
270-
case APIVersionV2:
271-
err = client.get(&response, fmt.Sprintf("/v2/status/wait-for-block-after/%d/", round), nil)
272-
default:
273-
var nodeStatus v1.NodeStatus
274-
err = client.get(&nodeStatus, fmt.Sprintf("/v1/status/wait-for-block-after/%d/", round), nil)
275-
if err == nil {
276-
response = fillNodeStatusResponse(nodeStatus)
277-
}
278-
}
241+
err = client.get(&response, fmt.Sprintf("/v2/status/wait-for-block-after/%d/", round), nil)
279242
return
280243
}
281244

@@ -302,17 +265,7 @@ func fillNodeStatusResponse(nodeStatus v1.NodeStatus) generatedV2.NodeStatusResp
302265
// blocks on the node end
303266
// Not supported
304267
func (client RestClient) StatusAfterBlock(blockNum uint64) (response generatedV2.NodeStatusResponse, err error) {
305-
switch client.versionAffinity {
306-
case APIVersionV2:
307-
err = client.get(&response, fmt.Sprintf("/v2/status/wait-for-block-after/%d", blockNum), nil)
308-
default:
309-
var nodeStatus v1.NodeStatus
310-
err = client.get(&nodeStatus, fmt.Sprintf("/v1/status/wait-for-block-after/%d", blockNum), nil)
311-
if err == nil {
312-
response = fillNodeStatusResponse(nodeStatus)
313-
}
314-
}
315-
268+
err = client.get(&response, fmt.Sprintf("/v2/status/wait-for-block-after/%d", blockNum), nil)
316269
return
317270
}
318271

@@ -546,16 +499,9 @@ func (client RestClient) Block(round uint64) (response v1.Block, err error) {
546499

547500
// RawBlock gets the encoded, raw msgpack block for the given round
548501
func (client RestClient) RawBlock(round uint64) (response []byte, err error) {
549-
switch client.versionAffinity {
550-
case APIVersionV2:
551-
var blob Blob
552-
err = client.getRaw(&blob, fmt.Sprintf("/v2/blocks/%d", round), rawFormat{Format: "msgpack"})
553-
response = blob
554-
default:
555-
var raw v1.RawBlock
556-
err = client.getRaw(&raw, fmt.Sprintf("/v1/block/%d", round), rawblockParams{1})
557-
response = raw
558-
}
502+
var blob Blob
503+
err = client.getRaw(&blob, fmt.Sprintf("/v2/blocks/%d", round), rawFormat{Format: "msgpack"})
504+
response = blob
559505
return
560506
}
561507

libgoal/libgoal.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ const DefaultKMDDataDir = nodecontrol.DefaultKMDDataDir
5555

5656
// Client represents the entry point for all libgoal functions
5757
type Client struct {
58-
nc nodecontrol.NodeController
59-
kmdStartArgs nodecontrol.KMDStartArgs
60-
dataDir string
61-
cacheDir string
62-
consensus config.ConsensusProtocols
63-
algodVersionAffinity algodclient.APIVersion
58+
nc nodecontrol.NodeController
59+
kmdStartArgs nodecontrol.KMDStartArgs
60+
dataDir string
61+
cacheDir string
62+
consensus config.ConsensusProtocols
6463

6564
suggestedParamsCache v1.TransactionParams
6665
suggestedParamsExpire time.Time
@@ -147,7 +146,6 @@ func (c *Client) init(config ClientConfig, clientType ClientType) error {
147146
}
148147
c.dataDir = dataDir
149148
c.cacheDir = config.CacheDir
150-
c.algodVersionAffinity = algodclient.APIVersionV1
151149

152150
// Get node controller
153151
nc, err := getNodeController(config.BinDir, config.AlgodDataDir)
@@ -202,7 +200,6 @@ func (c *Client) ensureAlgodClient() (*algodclient.RestClient, error) {
202200
if err != nil {
203201
return nil, err
204202
}
205-
algod.SetAPIVersionAffinity(c.algodVersionAffinity)
206203
return &algod, err
207204
}
208205

@@ -1051,19 +1048,13 @@ func (c *Client) ConsensusParams(round uint64) (consensus config.ConsensusParams
10511048
return params, nil
10521049
}
10531050

1054-
// SetAPIVersionAffinity sets the desired client API version affinity of the algod and kmd clients.
1055-
func (c *Client) SetAPIVersionAffinity(algodVersionAffinity algodclient.APIVersion) {
1056-
c.algodVersionAffinity = algodVersionAffinity
1057-
}
1058-
10591051
// AbortCatchup aborts the currently running catchup
10601052
func (c *Client) AbortCatchup() error {
10611053
algod, err := c.ensureAlgodClient()
10621054
if err != nil {
10631055
return err
10641056
}
10651057
// we need to ensure we're using the v2 status so that we would get the catchpoint information.
1066-
algod.SetAPIVersionAffinity(algodclient.APIVersionV2)
10671058
resp, err := algod.Status()
10681059
if err != nil {
10691060
return err

test/e2e-go/features/catchup/catchpointCatchup_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ func TestBasicCatchpointCatchup(t *testing.T) {
198198
targetCatchpointRound := (basics.Round(expectedBlocksToDownload+minRound)/catchpointInterval + 1) * catchpointInterval
199199
targetRound := uint64(targetCatchpointRound) + 1
200200
primaryNodeRestClient := fixture.GetAlgodClientForController(primaryNode)
201-
primaryNodeRestClient.SetAPIVersionAffinity(algodclient.APIVersionV2)
202201
log.Infof("Building ledger history..")
203202
for {
204203
err = fixture.ClientWaitForRound(primaryNodeRestClient, currentRound, 45*time.Second)
@@ -378,7 +377,6 @@ func TestCatchpointLabelGeneration(t *testing.T) {
378377
currentRound := uint64(1)
379378
targetRound := uint64(21)
380379
primaryNodeRestClient := fixture.GetAlgodClientForController(primaryNode)
381-
primaryNodeRestClient.SetAPIVersionAffinity(algodclient.APIVersionV2)
382380
log.Infof("Building ledger history..")
383381
for {
384382
err = fixture.ClientWaitForRound(primaryNodeRestClient, currentRound, 45*time.Second)

0 commit comments

Comments
 (0)