chore: use range-over-integer (Go 1.22+)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
aefec104d4
commit
33a0b57d72
8 changed files with 9 additions and 9 deletions
|
|
@ -48,7 +48,7 @@ func (c *Chain) NextDifficulty(height uint64, forks []config.HardFork) (uint64,
|
|||
timestamps := make([]uint64, count)
|
||||
cumulDiffs := make([]*big.Int, count)
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
for i := range count {
|
||||
meta, err := c.getBlockMeta(startHeight + uint64(i))
|
||||
if err != nil {
|
||||
// Fewer blocks than expected — use what we have.
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func CheckDifficulty(hash types.Hash, difficulty uint64) bool {
|
|||
// Convert hash to big.Int (little-endian as per CryptoNote convention).
|
||||
// Reverse to big-endian for big.Int.
|
||||
var be [32]byte
|
||||
for i := 0; i < 32; i++ {
|
||||
for i := range 32 {
|
||||
be[i] = hash[31-i]
|
||||
}
|
||||
hashInt := new(big.Int).SetBytes(be[:])
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ type PeerlistEntry struct {
|
|||
func DecodePeerlist(blob []byte) []PeerlistEntry {
|
||||
n := len(blob) / PeerlistEntrySize
|
||||
entries := make([]PeerlistEntry, n)
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
off := i * PeerlistEntrySize
|
||||
entries[i] = PeerlistEntry{
|
||||
IP: binary.LittleEndian.Uint32(blob[off : off+4]),
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ func (r *ResponseChainEntry) Decode(data []byte) error {
|
|||
func splitHashes(blob []byte, size int) [][]byte {
|
||||
n := len(blob) / size
|
||||
out := make([][]byte, n)
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
out[i] = blob[i*size : (i+1)*size]
|
||||
}
|
||||
return out
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ func (m *ExplorerModel) loadBlocks() {
|
|||
}
|
||||
|
||||
rows := make([]blockRow, count)
|
||||
for i := 0; i < count; i++ {
|
||||
for i := range count {
|
||||
h := height - 1 - uint64(i)
|
||||
blk, meta, err := m.chain.GetBlockByHeight(h)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ func base58Encode(data []byte) string {
|
|||
fullBlocks := len(data) / 8
|
||||
lastBlockSize := len(data) % 8
|
||||
|
||||
for i := 0; i < fullBlocks; i++ {
|
||||
for i := range fullBlocks {
|
||||
block := data[i*8 : (i+1)*8]
|
||||
encoded := encodeBlock(block, 11)
|
||||
result = append(result, encoded...)
|
||||
|
|
@ -227,7 +227,7 @@ func base58Decode(s string) ([]byte, error) {
|
|||
|
||||
var result []byte
|
||||
|
||||
for i := 0; i < fullBlocks; i++ {
|
||||
for i := range fullBlocks {
|
||||
blockStr := s[i*11 : (i+1)*11]
|
||||
decoded, err := decodeBlock(blockStr, 8)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ func MnemonicDecode(phrase string) ([32]byte, error) {
|
|||
|
||||
n := uint32(numWords)
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
for i := range 8 {
|
||||
w1, ok1 := wordIndex[words[i*3]]
|
||||
w2, ok2 := wordIndex[words[i*3+1]]
|
||||
w3, ok3 := wordIndex[words[i*3+2]]
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func (d *Decoder) ReadVarint() uint64 {
|
|||
}
|
||||
var val uint64
|
||||
var shift uint
|
||||
for i := 0; i < MaxVarintLen; i++ {
|
||||
for range MaxVarintLen {
|
||||
_, d.err = io.ReadFull(d.r, d.buf[:1])
|
||||
if d.err != nil {
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue