Skip to content

Commit

Permalink
move extraction of address from key to be in app logic rather than in…
Browse files Browse the repository at this point in the history
… accountKeeper
  • Loading branch information
randy75828 committed Jan 17, 2023
1 parent 6835839 commit e7af659
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions x/auth/keeper/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,19 @@ func (ak AccountKeeper) IterateEthToCosmosAddressMapping(ctx sdk.Context, cb fun

defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
addressKey := make([]byte, len(iterator.Key())-len(types.KeyPrefix(types.EthAddressToCosmosAddressKey)))
copy(addressKey, iterator.Key()[len(types.KeyPrefix(types.EthAddressToCosmosAddressKey)):])
if cb(addressKey, iterator.Value()) {
if cb(iterator.Key(), iterator.Value()) {
break
}
}

}
func (ak AccountKeeper) IterateCosmosToEthAddressMapping(ctx sdk.Context, cb func(cosmosAddress, ethAddress sdk.AccAddress) bool) {
func (ak AccountKeeper) IterateCosmosToEthAddressMapping(ctx sdk.Context, cb func(key []byte, ethAddress sdk.AccAddress) bool) {
store := ctx.KVStore(ak.key)
iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefix(types.CosmosAddressToEthAddressKey))

defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
addressKey := make([]byte, len(iterator.Key())-len(types.KeyPrefix(types.CosmosAddressToEthAddressKey)))
copy(addressKey, iterator.Key()[len(types.KeyPrefix(types.CosmosAddressToEthAddressKey)):])
if cb(addressKey, iterator.Value()) {
if cb(iterator.Key(), iterator.Value()) {
break
}
}
Expand Down

0 comments on commit e7af659

Please sign in to comment.