-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * rename * sectorUnsealedCopies and SectorProvingState
- Loading branch information
Showing
8 changed files
with
281 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package gql | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/filecoin-project/boost/db" | ||
gqltypes "github.com/filecoin-project/boost/gql/types" | ||
"github.com/filecoin-project/boost/sectorstatemgr" | ||
) | ||
|
||
type dealData struct { | ||
Indexed gqltypes.Uint64 | ||
FlaggedUnsealed gqltypes.Uint64 | ||
FlaggedSealed gqltypes.Uint64 | ||
} | ||
|
||
type pieces struct { | ||
Indexed int32 | ||
FlaggedUnsealed int32 | ||
FlaggedSealed int32 | ||
} | ||
|
||
type sectorUnsealedCopies struct { | ||
Unsealed int32 | ||
Sealed int32 | ||
} | ||
|
||
type sectorProvingState struct { | ||
Active int32 | ||
Inactive int32 | ||
} | ||
|
||
type lidState struct { | ||
DealData dealData | ||
Pieces pieces | ||
SectorUnsealedCopies sectorUnsealedCopies | ||
SectorProvingState sectorProvingState | ||
FlaggedPieces int32 | ||
} | ||
|
||
// query: lid: [LID] | ||
func (r *resolver) LID(ctx context.Context) (*lidState, error) { | ||
var lu *sectorstatemgr.SectorStateUpdates | ||
for lu == nil { | ||
r.ssm.LatestUpdateMu.Lock() | ||
lu = r.ssm.LatestUpdate | ||
r.ssm.LatestUpdateMu.Unlock() | ||
if lu == nil { | ||
time.Sleep(2 * time.Second) | ||
} | ||
} | ||
|
||
var sealed, unsealed int32 | ||
for _, s := range lu.SectorStates { // TODO: consider adding this data directly in SSM | ||
if s == db.SealStateUnsealed { | ||
unsealed++ | ||
} else if s == db.SealStateSealed { | ||
sealed++ | ||
} | ||
} | ||
|
||
fp, err := r.piecedirectory.FlaggedPiecesCount(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ls := &lidState{ | ||
FlaggedPieces: int32(fp), | ||
DealData: dealData{ | ||
Indexed: gqltypes.Uint64(12094627905536), | ||
FlaggedUnsealed: gqltypes.Uint64(1094627905536), | ||
FlaggedSealed: gqltypes.Uint64(18094627905536), | ||
}, | ||
Pieces: pieces{ | ||
Indexed: 360, | ||
FlaggedUnsealed: 33, | ||
FlaggedSealed: 480, | ||
}, | ||
SectorUnsealedCopies: sectorUnsealedCopies{ | ||
Sealed: sealed, | ||
Unsealed: unsealed, | ||
}, | ||
SectorProvingState: sectorProvingState{ | ||
Active: int32(len(lu.ActiveSectors)), | ||
Inactive: int32(len(lu.SectorStates) - len(lu.ActiveSectors)), // TODO: add an explicit InactiveSectors in ssm | ||
}, | ||
} | ||
|
||
return ls, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.