diff --git a/chain/file.go b/chain/file.go index 93242b2..a17a54b 100644 --- a/chain/file.go +++ b/chain/file.go @@ -25,7 +25,6 @@ import ( keyring "github.com/CESSProject/go-keyring" "github.com/btcsuite/btcutil/base58" "github.com/centrifuge/go-substrate-rpc-client/v4/types" - "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" ) @@ -584,14 +583,14 @@ func (c *chainClient) RetrieveObject(url, fid string) (io.ReadCloser, error) { // } // } -func (c *chainClient) QueryAssignedMinerPeerId(minerTaskList []pattern.MinerTaskList) ([]peer.ID, error) { - var peerids = make([]peer.ID, len(minerTaskList)) - for i := 0; i < len(minerTaskList); i++ { - minerInfo, err := c.QueryStorageMiner(minerTaskList[i].Account[:]) - if err != nil { - return peerids, err - } - peerids[i], _ = peer.Decode(string(minerInfo.PeerId[:])) - } - return peerids, nil -} +// func (c *chainClient) QueryAssignedMinerPeerId(minerTaskList []pattern.MinerTaskList) ([]peer.ID, error) { +// var peerids = make([]peer.ID, len(minerTaskList)) +// for i := 0; i < len(minerTaskList); i++ { +// minerInfo, err := c.QueryStorageMiner(minerTaskList[i].Account[:]) +// if err != nil { +// return peerids, err +// } +// peerids[i], _ = peer.Decode(string(minerInfo.PeerId[:])) +// } +// return peerids, nil +// } diff --git a/chain/fileBank.go b/chain/fileBank.go index 0c0908a..596b513 100644 --- a/chain/fileBank.go +++ b/chain/fileBank.go @@ -913,7 +913,7 @@ func (c *chainClient) DeleteFile(puk []byte, filehash []string) (string, []patte } } -func (c *chainClient) SubmitFileReport(roothash pattern.FileHash, accs []types.AccountID) (string, error) { +func (c *chainClient) SubmitFileReport(index types.U8, roothash pattern.FileHash, accs []types.AccountID) (string, error) { c.lock.Lock() defer func() { c.lock.Unlock() @@ -927,11 +927,19 @@ func (c *chainClient) SubmitFileReport(roothash pattern.FileHash, accs []types.A accountInfo types.AccountInfo ) + if index == 0 || int(index) > (pattern.DataShards+pattern.ParShards) { + return "", errors.New("invalid index") + } + + if len(accs) == 0 || len(accs) > 3 { + return "", errors.New("invalid tee list length") + } + if !c.GetChainState() { return txhash, pattern.ERR_RPC_CONNECTION } - call, err := types.NewCall(c.metadata, pattern.TX_FILEBANK_FILEREPORT, roothash) + call, err := types.NewCall(c.metadata, pattern.TX_FILEBANK_FILEREPORT, index, roothash, accs) if err != nil { return txhash, errors.Wrap(err, "[NewCall]") } @@ -1007,7 +1015,7 @@ func (c *chainClient) SubmitFileReport(roothash pattern.FileHash, accs []types.A } } -func (c *chainClient) ReportFile(roothash string, accs []string) (string, error) { +func (c *chainClient) ReportFile(index uint8, roothash string, accs []string) (string, error) { var hashs pattern.FileHash var accounts = make([]types.AccountID, 0) for j := 0; j < len(roothash); j++ { @@ -1025,7 +1033,7 @@ func (c *chainClient) ReportFile(roothash string, accs []string) (string, error) accounts = append(accounts, *accountID) } - return c.SubmitFileReport(hashs, accounts) + return c.SubmitFileReport(types.U8(index), hashs, accounts) } // QueryRestoralOrder diff --git a/core/pattern/pattern.go b/core/pattern/pattern.go index 1dae665..af20049 100644 --- a/core/pattern/pattern.go +++ b/core/pattern/pattern.go @@ -321,8 +321,9 @@ type SegmentList struct { } type MinerTaskList struct { - Account types.AccountID - Hash []FileHash + Index types.U8 + Miner types.Option[types.AccountID] + FragmentList []FileHash } type SegmentInfo struct { @@ -341,10 +342,8 @@ type StorageOrder struct { Count types.U8 FileSize types.U128 SegmentList []SegmentList - NeededList []SegmentList User UserBrief - AssignedMiner []MinerTaskList - ShareInfo []SegmentInfo + MinerTaskList []MinerTaskList CompleteList []types.AccountID } diff --git a/core/sdk/sdk.go b/core/sdk/sdk.go index bdefb6d..9834522 100644 --- a/core/sdk/sdk.go +++ b/core/sdk/sdk.go @@ -93,8 +93,8 @@ type SDK interface { // RestoralComplete reports order recovery completion. RestoralComplete(restoralFragmentHash string) (string, error) // SubmitFileReport submits a stored file report. - SubmitFileReport(roothash pattern.FileHash, accs []types.AccountID) (string, error) - ReportFile(roothash string, accs []string) (string, error) + SubmitFileReport(index types.U8, roothash pattern.FileHash, accs []types.AccountID) (string, error) + ReportFile(index uint8, roothash string, accs []string) (string, error) // UploadDeclaration creates a storage order. UploadDeclaration(filehash string, dealinfo []pattern.SegmentList, hashs [][]pattern.FileHash, user pattern.UserBrief, filesize uint64) (string, error) // GenerateStorageOrder for generating storage orders