Skip to content

Commit

Permalink
feat: handle PreCommitSectorBatch2 message
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Aug 30, 2023
1 parent 40bd408 commit f263721
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion storageprovider/ondealsectorcommitted.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"

miner2 "github.com/filecoin-project/go-state-types/builtin/v11/miner"
"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/pkg/events"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/market"
Expand Down Expand Up @@ -107,7 +108,9 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context,

// Watch for a pre-commit message to the provider.
matchEvent := func(msg *types.Message) (bool, error) {
matched := msg.To == provider && (msg.Method == builtin.MethodsMiner.PreCommitSector || msg.Method == builtin.MethodsMiner.PreCommitSectorBatch)
matched := msg.To == provider && (msg.Method == builtin.MethodsMiner.PreCommitSector ||
msg.Method == builtin.MethodsMiner.PreCommitSectorBatch || msg.Method == builtin.MethodsMiner.PreCommitSectorBatch2 ||
msg.Method == builtin.MethodsMiner.ProveReplicaUpdates)
return matched, nil
}

Expand Down Expand Up @@ -333,6 +336,21 @@ func dealSectorInPreCommitMsg(msg *types.Message, res CurrentDealInfo) (*abi.Sec
return nil, fmt.Errorf("unmarshal pre commit: %w", err)
}

for _, precommit := range params.Sectors {
// Check through the deal IDs associated with this message
for _, did := range precommit.DealIDs {
if did == res.DealID {
// Found the deal ID in this message. Callback with the sector ID.
return &precommit.SectorNumber, nil
}
}
}
case builtin.MethodsMiner.PreCommitSectorBatch2:
var params miner2.PreCommitSectorBatchParams2
if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil {
return nil, fmt.Errorf("unmarshal pre commit: %w", err)
}

for _, precommit := range params.Sectors {
// Check through the deal IDs associated with this message
for _, did := range precommit.DealIDs {
Expand Down

0 comments on commit f263721

Please sign in to comment.