@@ -58,27 +58,22 @@ func (s *HashCurrencyPairStrategy) FromID(ctx sdk.Context, id uint64) (connectty
58
58
if height != s .previousHeight {
59
59
s .idCache = make (map [uint64 ]connecttypes.CurrencyPair , DefaultCacheInitialCapacity )
60
60
s .previousHeight = height
61
- }
62
-
63
- cp , found := s .idCache [id ]
64
- if found {
65
- return cp , nil
66
- }
67
61
68
- // if the currency pair is not found in the cache, attempt to retrieve it from
69
- // the x/oracle state by populating the cache with all currency pairs. This
70
- // should only be executed once per block height.
71
- allCPs := s .oracleKeeper .GetAllCurrencyPairs (ctx )
72
- for _ , cp := range allCPs {
73
- hash , err := CurrencyPairToHashID (cp .String ())
74
- if err != nil {
75
- return connecttypes.CurrencyPair {}, fmt .Errorf ("failed to hash currency pair %s: %w" , cp .String (), err )
62
+ // if the currency pair is not found in the cache, attempt to retrieve it from
63
+ // the x/oracle state by populating the cache with all currency pairs. This
64
+ // should only be executed once per block height.
65
+ allCPs := s .oracleKeeper .GetAllCurrencyPairs (ctx )
66
+ for _ , cp := range allCPs {
67
+ hash , err := CurrencyPairToHashID (cp .String ())
68
+ if err != nil {
69
+ return connecttypes.CurrencyPair {}, fmt .Errorf ("failed to hash currency pair %s: %w" , cp .String (), err )
70
+ }
71
+
72
+ s .idCache [hash ] = cp
76
73
}
77
-
78
- s .idCache [hash ] = cp
79
74
}
80
75
81
- cp , found = s .idCache [id ]
76
+ cp , found : = s .idCache [id ]
82
77
if ! found {
83
78
return connecttypes.CurrencyPair {}, fmt .Errorf ("currency pair with sha256 hashed ID %d not found in x/oracle state" , id )
84
79
}
0 commit comments