Skip to content

Commit

Permalink
Base comm (#95)
Browse files Browse the repository at this point in the history
* update gethandle

* update track

* update version
  • Loading branch information
AstaFrode authored Jul 21, 2023
1 parent 9d92f9f commit cc1d474
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion configs/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
// Name space
NameSpace = Name
// version
Version = Name + " " + "v0.2.5 pre-release 230720.1146"
Version = Name + " " + "v0.2.5"
// description
Description = "Object storage service based on cess network"
)
Expand Down
9 changes: 8 additions & 1 deletion node/getHandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (n *Node) getHandle(c *gin.Context) {
os.Remove(fpath)
}
}

var completion bool
fmeta, err := n.QueryFileMetadata(queryName)
if err != nil {
if err.Error() != pattern.ERR_Empty {
Expand All @@ -284,6 +284,7 @@ func (n *Node) getHandle(c *gin.Context) {
size = order.FileSize.Uint64()
}
} else {
completion = true
size = fmeta.FileSize.Uint64()
}

Expand Down Expand Up @@ -311,6 +312,12 @@ func (n *Node) getHandle(c *gin.Context) {
}
}

if !completion {
n.Query("err", fmt.Sprintf("[%s] Download file [%s] : %v", clientIp, queryName, "During the order transaction, please go to the original deoss to download the file."))
c.JSON(http.StatusInternalServerError, "During the order transaction, please go to the original deoss to download the file.")
return
}

// download from miner
fpath, err = n.fetchFiles(queryName, n.GetDirs().FileDir)
if err != nil {
Expand Down
16 changes: 14 additions & 2 deletions node/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/CESSProject/DeOSS/pkg/utils"
"github.com/CESSProject/cess-go-sdk/core/pattern"
sutils "github.com/CESSProject/cess-go-sdk/core/utils"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/mr-tron/base58"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -249,17 +250,18 @@ func (n *Node) backupFiles(owner []byte, segmentInfo []pattern.SegmentDataInfo,
}

// store fragment to storage
err = n.storageData(roothash, segmentInfo, storageOrder.AssignedMiner)
err = n.storageData(roothash, segmentInfo, storageOrder.AssignedMiner, storageOrder.CompleteList)
if err != nil {
return 0, errors.Wrapf(err, "[storageData]")
}
return uint8(storageOrder.Count), nil
}

func (n *Node) storageData(roothash string, segment []pattern.SegmentDataInfo, minerTaskList []pattern.MinerTaskList) error {
func (n *Node) storageData(roothash string, segment []pattern.SegmentDataInfo, minerTaskList []pattern.MinerTaskList, completeList []types.AccountID) error {
var err error
var fpath string
var failed bool
var complete bool
// query all assigned miner multiaddr
peerids, accs, err := n.QueryAssignedMiner(minerTaskList)
if err != nil {
Expand All @@ -268,6 +270,7 @@ func (n *Node) storageData(roothash string, segment []pattern.SegmentDataInfo, m

basedir := filepath.Dir(segment[0].FragmentHash[0])
for i := 0; i < len(peerids); i++ {
complete = false
addr, ok := n.GetPeer(peerids[i])
if !ok {
addr, err = n.DHTFindPeer(peerids[i])
Expand All @@ -286,6 +289,15 @@ func (n *Node) storageData(roothash string, segment []pattern.SegmentDataInfo, m
}

for j := 0; j < len(minerTaskList[i].Hash); j++ {
for k := 0; k < len(completeList); k++ {
if sutils.CompareSlice(minerTaskList[i].Account[:], completeList[k][:]) {
complete = true
break
}
}
if complete {
break
}
fpath = filepath.Join(basedir, string(minerTaskList[i].Hash[j][:]))
_, err = os.Stat(fpath)
if err != nil {
Expand Down

0 comments on commit cc1d474

Please sign in to comment.