Initialize with same length as partition

Initialize the postParam.Partitions slice with the same length as i.Partitions before iterating over it in the loop.
This commit is contained in:
Phi 2023-03-27 10:04:15 +02:00
parent 3f8a41cfe8
commit 8bb7272bb1

View File

@ -658,6 +658,10 @@ It will not send any messages to the chain.`,
for _, i := range res { for _, i := range res {
var postParam SubmitWindowedPoStParams var postParam SubmitWindowedPoStParams
postParam.Deadline = i.Deadline postParam.Deadline = i.Deadline
// Initialize the postParam.Partitions slice with the same length as i.Partitions
postParam.Partitions = make([]PoStPartition, len(i.Partitions))
for id, part := range i.Partitions { for id, part := range i.Partitions {
postParam.Partitions[id].Index = part.Index postParam.Partitions[id].Index = part.Index
count, err := part.Skipped.Count() count, err := part.Skipped.Count()