Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2022-09-04 14:30:59 +01:00 committed by GitHub
parent 435de928b7
commit c9ae7310e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()