remove the map usage#3296
Conversation
Codecov Report
@@ Coverage Diff @@
## future/peggy2 #3296 +/- ##
=================================================
- Coverage 48.27% 48.18% -0.10%
=================================================
Files 169 171 +2
Lines 14940 15102 +162
=================================================
+ Hits 7213 7277 +64
- Misses 7307 7389 +82
- Partials 420 436 +16
|
| expectedValidatorAddress, err := sdk.ValAddressFromBech32(expectedValidatorBech32) | ||
| assert.NoError(t, err) | ||
| found := false | ||
| for _, value := range validators.ValidatorPower { |
There was a problem hiding this comment.
Use the new slice functions to find addresses rather then loop through https://pkg.go.dev/golang.org/x/exp/slices#Index to minimize repeating code.
There was a problem hiding this comment.
tried to use the Index in slices package, prefer not using it.
- we need create a new slice for all validator addresses
- validator address is not comparable
| config.SetRoot(clientCtx.HomeDir) | ||
|
|
||
| networkDescriptor, err := strconv.ParseUint(args[0], 10, 32) | ||
| networkDescriptorNum, err := strconv.ParseUint(args[0], 10, 32) |
There was a problem hiding this comment.
For lines 35~44 replace with call to func parseNetworkDescriptor(networkDescriptorStr string) (oracletypes.NetworkDescriptor, error) in x/ethbridge/client/cli/tx.go. May need to move that function to a more central location.
There was a problem hiding this comment.
I implemented it in other PR.
| validatorWhitelist := oracletypes.ValidatorWhiteList{} | ||
|
|
||
| // find and remove according to network descriptor | ||
| for index := 0; index < len(oracleGenState.ValidatorWhitelist); index++ { |
There was a problem hiding this comment.
Again here lets use the slices packages https://pkg.go.dev/golang.org/x/exp/slices#Delete or something similar
There was a problem hiding this comment.
it is not to remove a networkDescriptor from a slice of networkDescriptors. So we still need find out it at first, then remove an item from ValidatorWhitelist. we could use filter/collect if go lang support the functional programming well.
| map<uint32, uint32> consensus_needed = 4; | ||
| map<uint32, CrossChainFeeConfig> cross_chain_fee = 5; | ||
| map<string, uint64> witness_lock_burn_sequence = 6; | ||
| map<string, ProphecyInfo> prophecy_info = 7; |
There was a problem hiding this comment.
Lets make a message for NetworkConfigData which contains the address_whitelist, consensus_needed, and the cross_chain_fee so we don't have to look them up individually. And these become a repeated struct. This struct also needs to include the NetworkDescriptor number so that indexing can be done properly.
There was a problem hiding this comment.
will add NetworkConfigData
| uint32 voting_power = 2; | ||
| } | ||
|
|
||
| message GenesisValidatorWhiteList { |
There was a problem hiding this comment.
These three should be joined into one message type
There was a problem hiding this comment.
will combine these three items.
No description provided.