deals: Almost sealing client data
This commit is contained in:
committed by
whyrusleeping
parent
5a865177e6
commit
c79cb7bf31
+5
-12
@@ -3,6 +3,7 @@ package impl
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
|
||||
@@ -20,20 +21,12 @@ type StorageMinerAPI struct {
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) StoreGarbageData(ctx context.Context) (uint64, error) {
|
||||
maxSize := uint64(1016) // this is the most data we can fit in a 1024 byte sector
|
||||
data := make([]byte, maxSize)
|
||||
fi, err := ioutil.TempFile("", "lotus-garbage")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if _, err := fi.Write(data); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
fi.Close()
|
||||
maxSize := 1016 // this is the most data we can fit in a 1024 byte sector
|
||||
|
||||
name := fmt.Sprintf("fake-file-%d", rand.Intn(100000000))
|
||||
sectorId, err := sm.SectorBuilder.AddPiece(name, maxSize, fi.Name())
|
||||
|
||||
sectorId, err := sm.SectorBuilder.AddPiece(ctx, name, uint64(maxSize),
|
||||
ioutil.NopCloser(io.LimitReader(rand.New(rand.NewSource(rand.Int63())), int64(maxSize))))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user