Skip to content

Commit

Permalink
*: improve for range loops with 1.22+ syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Khimov <roman@nspcc.ru>
  • Loading branch information
roman-khimov committed Aug 21, 2024
1 parent d548b6d commit d22500b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dbft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ func TestDBFT_OnReceiveRecoveryRequestResponds(t *testing.T) {
var params []recoveryset

for _, nodes := range []int{4, 5, 7, 10} { // 5 is a bad BFT number, but we want to test the logic anyway.
for sender := 0; sender < nodes; sender++ {
for recv := 0; recv < nodes; recv++ {
for sender := range nodes {
for recv := range nodes {
params = append(params, recoveryset{nodes, sender, recv, false})

for i := 1; i <= ((nodes-1)/3)+1; i++ {
Expand Down Expand Up @@ -1221,7 +1221,7 @@ func newConsensusPayload(c *dbft.Context[crypto.Uint256], t dbft.MessageType, ms
}

func getTestValidators(n int) (privs []dbft.PrivateKey, pubs []dbft.PublicKey) {
for i := 0; i < n; i++ {
for range n {
priv, pub := crypto.Generate(rand.Reader)
privs = append(privs, priv)
pubs = append(pubs, pub)
Expand Down
2 changes: 1 addition & 1 deletion internal/consensus/amev_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewAMEVBlock(pre dbft.PreBlock[crypto.Uint256], cnData [][]byte, m int) dbf
// Some artificial rules of new tx creation are invented here, but in Neo X there will
// be well-defined custom rules for Envelope transactions.
var sum uint32
for i := 0; i < m; i++ {
for i := range m {
sum += binary.BigEndian.Uint32(cnData[i])
}
tx := Tx64(math.MaxInt64 - int64(sum))
Expand Down
2 changes: 1 addition & 1 deletion internal/merkle/merkle_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func buildTree(leaves ...TreeNode) *TreeNode {
}

parents := make([]TreeNode, (l+1)/2)
for i := 0; i < len(parents); i++ {
for i := range parents {
parents[i].Left = &leaves[i*2]
leaves[i*2].Parent = &parents[i]

Expand Down
2 changes: 1 addition & 1 deletion internal/merkle/merkle_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestNewMerkleTree(t *testing.T) {

t.Run("predefined tree on 4 leaves", func(t *testing.T) {
hashes := make([]crypto.Uint256, 5)
for i := 0; i < 5; i++ {
for i := range hashes {
hashes[i] = sha256.Sum256([]byte{byte(i)})
}

Expand Down
2 changes: 1 addition & 1 deletion internal/simulation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (n *simNode) VerifyPayload(p dbft.ConsensusPayload[crypto.Uint256]) error {
}

func (n *simNode) addTx(count int) {
for i := 0; i < count; i++ {
for i := range count {
tx := consensus.Tx64(uint64(i))
n.pool.Add(&tx)
}
Expand Down

0 comments on commit d22500b

Please sign in to comment.