impose a maximum sector ID
This commit is contained in:
parent
4ad0db0ecd
commit
c1cd332ff7
@ -23,6 +23,8 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const MaxSectorID = 32 << 30 // 32 billion sectors should be good enough right?
|
||||||
|
|
||||||
type StorageMinerActor struct{}
|
type StorageMinerActor struct{}
|
||||||
|
|
||||||
type StorageMinerActorState struct {
|
type StorageMinerActorState struct {
|
||||||
@ -537,6 +539,9 @@ func SectorIsUnique(ctx context.Context, s types.Storage, sroot cid.Cid, sid uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func AddToSectorSet(ctx context.Context, blks amt.Blocks, ss cid.Cid, sectorID uint64, commR, commD []byte) (cid.Cid, ActorError) {
|
func AddToSectorSet(ctx context.Context, blks amt.Blocks, ss cid.Cid, sectorID uint64, commR, commD []byte) (cid.Cid, ActorError) {
|
||||||
|
if sectorID > MaxSectorID {
|
||||||
|
return cid.Undef, aerrors.Newf(25, "sector ID out of range: %d", sectorID)
|
||||||
|
}
|
||||||
ssr, err := amt.LoadAMT(blks, ss)
|
ssr, err := amt.LoadAMT(blks, ss)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, aerrors.HandleExternalError(err, "could not load sector set node")
|
return cid.Undef, aerrors.HandleExternalError(err, "could not load sector set node")
|
||||||
@ -557,6 +562,10 @@ func AddToSectorSet(ctx context.Context, blks amt.Blocks, ss cid.Cid, sectorID u
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetFromSectorSet(ctx context.Context, s types.Storage, ss cid.Cid, sectorID uint64) (bool, []byte, []byte, ActorError) {
|
func GetFromSectorSet(ctx context.Context, s types.Storage, ss cid.Cid, sectorID uint64) (bool, []byte, []byte, ActorError) {
|
||||||
|
if sectorID > MaxSectorID {
|
||||||
|
return false, nil, nil, aerrors.Newf(25, "sector ID out of range: %d", sectorID)
|
||||||
|
}
|
||||||
|
|
||||||
ssr, err := amt.LoadAMT(types.WrapStorage(s), ss)
|
ssr, err := amt.LoadAMT(types.WrapStorage(s), ss)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, nil, aerrors.HandleExternalError(err, "could not load sector set node")
|
return false, nil, nil, aerrors.HandleExternalError(err, "could not load sector set node")
|
||||||
|
Loading…
Reference in New Issue
Block a user