diff --git a/cmd/verkle/pedersen_hashstate.go b/cmd/verkle/pedersen_hashstate.go index 97e92a016..fe53b6c36 100644 --- a/cmd/verkle/pedersen_hashstate.go +++ b/cmd/verkle/pedersen_hashstate.go @@ -67,23 +67,12 @@ func regeneratePedersenAccounts(outTx kv.RwTx, readTx kv.Tx, workersCount uint) go func() { defer debug.LogPanic() defer cancelWorkers() - var ok bool - var o *regeneratePedersenAccountsOut - for { - select { - case o, ok = <-out: - if !ok { - return - } - - if err := collector.Collect(o.versionHash[:], o.encodedAccount); err != nil { - panic(err) - return - } - if err := collectorLookup.Collect(o.address[:], o.versionHash[:]); err != nil { - panic(err) - return - } + for o := range out { + if err := collector.Collect(o.versionHash[:], o.encodedAccount); err != nil { + panic(err) + } + if err := collectorLookup.Collect(o.address[:], o.versionHash[:]); err != nil { + panic(err) } } }() @@ -162,23 +151,12 @@ func regeneratePedersenStorage(outTx kv.RwTx, readTx kv.Tx, workersCount uint) e go func() { defer debug.LogPanic() defer cancelWorkers() - var ok bool - var o *regeneratePedersenStorageJob - for { - select { - case o, ok = <-out: - if !ok { - return - } - - if err := collector.Collect(o.storageVerkleKey[:], o.storageValue); err != nil { - panic(err) - return - } - if err := collectorLookup.Collect(append(o.address[:], o.storageKey.Bytes()...), o.storageVerkleKey[:]); err != nil { - panic(err) - return - } + for o := range out { + if err := collector.Collect(o.storageVerkleKey[:], o.storageValue); err != nil { + panic(err) + } + if err := collectorLookup.Collect(append(o.address[:], o.storageKey.Bytes()...), o.storageVerkleKey[:]); err != nil { + panic(err) } } }() @@ -267,40 +245,28 @@ func regeneratePedersenCode(outTx kv.RwTx, readTx kv.Tx, workersCount uint) erro go func() { defer debug.LogPanic() defer cancelWorkers() - var ok bool - var o *regeneratePedersenCodeOut - for { - select { - case o, ok = <-out: - if !ok { - return - } + for o := range out { + // Write Code Size + codeSizeBytes := make([]byte, 32) + binary.LittleEndian.PutUint32(codeSizeBytes, uint32(o.codeSize)) - // Write Code Size - codeSizeBytes := make([]byte, 32) - binary.LittleEndian.PutUint32(codeSizeBytes, uint32(o.codeSize)) - - if err := collector.Collect(o.codeSizeHash[:], codeSizeBytes); err != nil { + if err := collector.Collect(o.codeSizeHash[:], codeSizeBytes); err != nil { + panic(err) + } + // Write code chunks + if o.codeSize == 0 { + continue + } + for i := range o.chunks { + if err := collector.Collect(o.chunksKeys[i][:], o.chunks[i]); err != nil { panic(err) - return } - // Write code chunks - if o.codeSize == 0 { - continue - } - for i := range o.chunks { - if err := collector.Collect(o.chunksKeys[i][:], o.chunks[i]); err != nil { - panic(err) - return - } - // Build lookup [address + index] - lookupKey := make([]byte, 24) - copy(lookupKey, o.address[:]) - binary.BigEndian.PutUint32(lookupKey[20:], uint32(i)) - if err := collectorLookup.Collect(lookupKey, o.chunksKeys[i][:]); err != nil { - panic(err) - return - } + // Build lookup [address + index] + lookupKey := make([]byte, 24) + copy(lookupKey, o.address[:]) + binary.BigEndian.PutUint32(lookupKey[20:], uint32(i)) + if err := collectorLookup.Collect(lookupKey, o.chunksKeys[i][:]); err != nil { + panic(err) } } } @@ -318,7 +284,7 @@ func regeneratePedersenCode(outTx kv.RwTx, readTx kv.Tx, workersCount uint) erro return err } codeSizeKey := make([]byte, 32) - copy(codeSizeKey[:], versionKey) + copy(codeSizeKey, versionKey) codeSizeKey[31] = vtree.CodeSizeLeafKey acc := accounts.NewAccount()