@@ -14,7 +14,6 @@ import (
1414 "strings"
1515 "time"
1616
17- "github.com/dgraph-io/ristretto"
1817 "github.com/ethereum/go-ethereum/accounts/abi"
1918 ethCommon "github.com/ethereum/go-ethereum/common"
2019 "github.com/jackc/pgx/v5"
@@ -42,8 +41,6 @@ import (
4241)
4342
4443const (
45- blockCost = 1
46-
4744 defaultMaxTotalCount = 1000
4845
4946 // The maximum number of items that can be provided for name filters.
@@ -66,8 +63,6 @@ type StorageClient struct {
6663 disableCirculatingSupply bool
6764 circulatingSupplyExclusions []apiTypes.Address
6865
69- blockCache * ristretto.Cache [int64 , * Block ]
70-
7166 logger * log.Logger
7267}
7368
@@ -118,21 +113,6 @@ func NewStorageClient(
118113 networkConfig * oasisConfig.Network ,
119114 l * log.Logger ,
120115) (* StorageClient , error ) {
121- // The API currently uses an in-memory block cache for a specific endpoint and no other cases.
122- // This somewhat arbitrary choice seems to have been made historically.
123- // Instead, we should review common queries and responses to implement a more consistent and general caching strategy.
124- // https://github.com/oasisprotocol/nexus/issues/887
125- blockCache , err := ristretto .NewCache (& ristretto.Config [int64 , * Block ]{
126- NumCounters : 1024 * 10 ,
127- MaxCost : 1024 ,
128- BufferItems : 64 ,
129- IgnoreInternalCost : true ,
130- })
131- if err != nil {
132- l .Error ("api client: failed to create block cache: %w" , err )
133- return nil , err
134- }
135-
136116 // Parse the provided custom EVM token ordering config into a suitable format for the EVM token query.
137117 // Per runtime list of token addresses.
138118 evmTokensCustomOrderAddresses := make (map [common.Runtime ][]* apiTypes.StakingAddress )
@@ -179,7 +159,6 @@ func NewStorageClient(
179159 evmTokensCustomOrderGroups ,
180160 cfg .DisableCirculatingSupplyEndpoint ,
181161 circulatingSupplyExclusions ,
182- blockCache ,
183162 l ,
184163 }, nil
185164}
@@ -426,17 +405,7 @@ func entityInfoFromRow(r entityInfoRow) apiTypes.EntityInfo {
426405// Blocks returns a list of consensus blocks.
427406func (c * StorageClient ) Blocks (ctx context.Context , r apiTypes.GetConsensusBlocksParams , height * int64 ) (* BlockList , error ) {
428407 if height != nil {
429- // Querying a single block by height, check cache.
430- // XXX: This cache is somewhat arbitrary and likely not very useful in practice.
431- // It has been kept for now to avoid regressions: https://github.com/oasisprotocol/nexus/issues/887
432- block , ok := c .blockCache .Get (* height )
433- if ok {
434- return & BlockList {
435- Blocks : []Block {* block },
436- }, nil
437- }
438-
439- // Otherwise continue with the query below.
408+ // Querying a single block by height, configure query parameters.
440409 r .From = height
441410 r .To = height
442411 r .Limit = common .Ptr (uint64 (1 ))
@@ -500,11 +469,6 @@ func (c *StorageClient) Blocks(ctx context.Context, r apiTypes.GetConsensusBlock
500469 bs .Blocks = append (bs .Blocks , b )
501470 }
502471
503- // Cache the block if we queried a single block.
504- if height != nil && len (bs .Blocks ) > 0 {
505- c .blockCache .Set (* height , & bs .Blocks [0 ], blockCost )
506- }
507-
508472 return & bs , nil
509473}
510474
0 commit comments