Skip to content

Commit

Permalink
compare-deposits: Replace sort.Search with slices.BinarySearchFunc
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed Aug 19, 2024
1 parent 5464568 commit a8938f9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/compare-deposits/compare-deposits.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

import (
"cmp"
"context"
"errors"
"fmt"
"math/big"
"os"
"slices"
"sort"
"time"

"github.com/nspcc-dev/neo-go/pkg/encoding/address"
Expand Down Expand Up @@ -154,11 +154,17 @@ func cliMain(c *cli.Context) error {
maxBlock = h
}
}
n := sort.Search(int(maxBlock-minBlock), func(i int) bool {
size := int64(maxBlock - minBlock)
blocks := make([]int64, size)
for i := int64(0); i < size; i++ {
blocks[i] = i
}

n, _ := slices.BinarySearchFunc(blocks, nextSupply, func(i int64, i2 int64) int {
var h = minBlock + uint32(i)
s := getSupply(cFS, balanceHash, h)
knownBlocks[h] = s
return s > nextSupply
return cmp.Compare(s, i2)
})
for _, s := range knownBlocks {
if s > nextSupply && (s < tmpSupply || tmpSupply == 0) {
Expand Down

0 comments on commit a8938f9

Please sign in to comment.