@@ -58,27 +58,22 @@ func (s *HashCurrencyPairStrategy) FromID(ctx sdk.Context, id uint64) (connectty
5858 if height != s .previousHeight {
5959 s .idCache = make (map [uint64 ]connecttypes.CurrencyPair , DefaultCacheInitialCapacity )
6060 s .previousHeight = height
61- }
62-
63- cp , found := s .idCache [id ]
64- if found {
65- return cp , nil
66- }
6761
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
7673 }
77-
78- s .idCache [hash ] = cp
7974 }
8075
81- cp , found = s .idCache [id ]
76+ cp , found : = s .idCache [id ]
8277 if ! found {
8378 return connecttypes.CurrencyPair {}, fmt .Errorf ("currency pair with sha256 hashed ID %d not found in x/oracle state" , id )
8479 }
0 commit comments