Skip to content

Commit

Permalink
comment out caching to test
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Feb 22, 2024
1 parent 734b2eb commit 245ffc4
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions tools/walletextension/wallet_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,25 @@ func (w *WalletExtension) ProxyEthRequest(request *common.RPCRequest, conn userc
requestStartTime := time.Now()

// Check if the request is in the cache
isCacheable, key, ttl := cache.IsCacheable(request)

// in case of cache hit return the response from the cache
if isCacheable {
if value, ok := w.cache.Get(key); ok {
// do a shallow copy of the map to avoid concurrent map iteration and map write
returnValue := make(map[string]interface{})
for k, v := range value {
returnValue[k] = v
}

requestEndTime := time.Now()
duration := requestEndTime.Sub(requestStartTime)
// adjust requestID
returnValue[common.JSONKeyID] = request.ID
w.fileLogger.Info(fmt.Sprintf("Request method: %s, request params: %s, encryptionToken of sender: %s, response: %s, duration: %d ", request.Method, request.Params, hexUserID, returnValue, duration.Milliseconds()))
return returnValue, nil
}
}
//isCacheable, key, ttl := cache.IsCacheable(request)
//
//// in case of cache hit return the response from the cache
//if isCacheable {
// if value, ok := w.cache.Get(key); ok {
// // do a shallow copy of the map to avoid concurrent map iteration and map write
// returnValue := make(map[string]interface{})
// for k, v := range value {
// returnValue[k] = v
// }
//
// requestEndTime := time.Now()
// duration := requestEndTime.Sub(requestStartTime)
// // adjust requestID
// returnValue[common.JSONKeyID] = request.ID
// w.fileLogger.Info(fmt.Sprintf("Request method: %s, request params: %s, encryptionToken of sender: %s, response: %s, duration: %d ", request.Method, request.Params, hexUserID, returnValue, duration.Milliseconds()))
// return returnValue, nil
// }
//}

// proxyRequest will find the correct client to proxy the request (or try them all if appropriate)
var rpcResp interface{}
Expand Down Expand Up @@ -172,9 +172,9 @@ func (w *WalletExtension) ProxyEthRequest(request *common.RPCRequest, conn userc
w.fileLogger.Info(fmt.Sprintf("Request method: %s, request params: %s, encryptionToken of sender: %s, response: %s, duration: %d ", request.Method, request.Params, hexUserID, response, duration.Milliseconds()))

// if the request is cacheable, store the response in the cache
if isCacheable {
w.cache.Set(key, response, ttl)
}
//if isCacheable {
// w.cache.Set(key, response, ttl)
//}

return response, nil
}
Expand Down

0 comments on commit 245ffc4

Please sign in to comment.