Skip to content

Commit

Permalink
remove selector (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstaFrode authored Aug 17, 2024
1 parent a6e541a commit 20b10d2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 35 deletions.
7 changes: 0 additions & 7 deletions node/put_chunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,6 @@ func (n *Node) PutChunksHandle(c *gin.Context) {
return
}

err = n.MoveFileToCache(fid, newPath)
if err != nil {
n.Logchunk("err", clientIp+" MoveFileToCache: "+err.Error())
c.JSON(http.StatusInternalServerError, err.Error())
return
}

blockhash, err := n.PlaceStorageOrder(fid, filename, bucketName, territoryName, segment, pkey, uint64(fstat.Size()))
if err != nil {
n.Logchunk("err", clientIp+" PlaceStorageOrder: "+err.Error())
Expand Down
5 changes: 0 additions & 5 deletions node/put_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,6 @@ func (n *Node) Put_file(c *gin.Context) {
return
}

err = n.MoveFileToCache(fid, newPath)
if err != nil {
n.Logput("err", clientIp+" MoveFileToCache: "+err.Error())
}

blockhash, err := n.PlaceStorageOrder(fid, filename, bucketName, territoryName, segment, pkey, uint64(length))
if err != nil {
n.Logput("err", clientIp+" PlaceStorageOrder: "+err.Error())
Expand Down
5 changes: 0 additions & 5 deletions node/put_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ func (n *Node) Put_object(c *gin.Context) {
return
}

err = n.MoveFileToCache(fid, newPath)
if err != nil {
n.Logput("err", clientIp+" MoveFileToCache: "+err.Error())
}

blockhash, err := n.PlaceStorageOrder(fid, filename, bucketName, territoryName, segmentInfo, pkey, uint64(length))
if err != nil {
n.Logput("err", clientIp+" PlaceStorageOrder: "+err.Error())
Expand Down
9 changes: 4 additions & 5 deletions node/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

schain "github.com/CESSProject/cess-go-sdk/chain"
sconfig "github.com/CESSProject/cess-go-sdk/config"
"github.com/CESSProject/cess-go-tools/scheduler"
"github.com/CESSProject/p2p-go/out"
"github.com/mr-tron/base58"
)
Expand Down Expand Up @@ -95,10 +94,10 @@ func (n *Node) RefreshMiner(ch chan<- bool) {
if minerinfo.IdleSpace.Uint64() >= sconfig.FragmentSize {
peerid := base58.Encode([]byte(string(minerinfo.PeerId[:])))
n.SavePeerAccount(n.GetSignatureAcc(), peerid)
addrinfo, ok := n.GetPeer(peerid)
if ok {
n.FlushPeerNodes(scheduler.DEFAULT_TIMEOUT, addrinfo)
}
// addrinfo, ok := n.GetPeer(peerid)
// if ok {
// n.FlushPeerNodes(scheduler.DEFAULT_TIMEOUT, addrinfo)
// }
}
}
}
Expand Down
27 changes: 14 additions & 13 deletions node/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (n *Node) trackFile(trackfile string) error {
}

err = n.storageData(recordFile, storageOrder.CompleteList)
n.FlushlistedPeerNodes(5*time.Second, n.GetDHTable()) //refresh the user-configured storage node list
//n.FlushlistedPeerNodes(5*time.Second, n.GetDHTable()) //refresh the user-configured storage node list
if err != nil {
n.Logtrack("err", err.Error())
return err
Expand Down Expand Up @@ -302,7 +302,7 @@ func (n *Node) shuntAllStorage(record TrackerInfo, dataGroup map[uint8]datagroup
value.Miner = acconut
value.Peerid = addr.ID.String()
dataGroup[index] = value
n.Feedback(addr.ID.String(), true)
//n.Feedback(addr.ID.String(), true)
n.Logtrack("info", fmt.Sprintf("[%s] %dth batch of all fragments is transferred to %s", record.Fid, index, addr.ID.String()))
break
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func (n *Node) shuntPartStorage(record TrackerInfo, dataGroup map[uint8]datagrou
value.Miner = acconut
value.Peerid = addr.ID.String()
dataGroup[index] = value
n.Feedback(addr.ID.String(), true)
//n.Feedback(addr.ID.String(), true)
n.Logtrack("info", fmt.Sprintf("[%s] shunt part: %dth batch fragments all transferred to: %s %s", record.Fid, index, acconut, addr.ID.String()))
break
}
Expand Down Expand Up @@ -420,7 +420,7 @@ func (n *Node) rangeStorage(record TrackerInfo, dataGroup map[uint8]datagroup) e
value.Complete = true
value.Peerid = peer.ID.String()
dataGroup[index] = value
n.Feedback(peer.ID.String(), true)
//n.Feedback(peer.ID.String(), true)
n.Logtrack("info", fmt.Sprintf("[%s] %dth batch of all fragments is transferred to %s", record.Fid, index, peer.ID.String()))
break
}
Expand Down Expand Up @@ -482,7 +482,7 @@ func (n *Node) highPriorityStorage(record TrackerInfo, dataGroup map[uint8]datag
value.Complete = true
value.Peerid = peerid
dataGroup[index] = value
n.Feedback(peerid, true)
//n.Feedback(peerid, true)
n.Logtrack("info", fmt.Sprintf("[%s] %dth batch of all fragments is transferred to %s", record.Fid, index, peerid))
break
}
Expand All @@ -493,21 +493,22 @@ func (n *Node) highPriorityStorage(record TrackerInfo, dataGroup map[uint8]datag
}

func (n *Node) lastStorage(record TrackerInfo, dataGroup map[uint8]datagroup) error {
// allpeers := n.GetAllStoragePeerId()
itor, err := n.NewPeersIterator(sconfig.DataShards + sconfig.ParShards)
if err != nil {
return err
}
var err error
failed := true
allpeers := n.GetAllPeerId()
var sucPeer = make(map[string]struct{}, 0)
for index, v := range dataGroup {
if v.Complete {
sucPeer[v.Peerid] = struct{}{}
continue
}
failed = true
for peer, ok := itor.GetPeer(); ok; peer, ok = itor.GetPeer() {
if _, ok := sucPeer[peer.ID.String()]; ok {
for _, peerid := range allpeers {
if _, ok := sucPeer[peerid]; ok {
continue
}
peer, ok := n.GetPeer(peerid)
if !ok {
continue
}
n.Logtrack("info", fmt.Sprintf("[%s] last storage: use peer: %s", record.Fid, peer.ID.String()))
Expand All @@ -534,7 +535,7 @@ func (n *Node) lastStorage(record TrackerInfo, dataGroup map[uint8]datagroup) er
value.Complete = true
value.Peerid = peer.ID.String()
dataGroup[index] = value
n.Feedback(peer.ID.String(), true)
//n.Feedback(peer.ID.String(), true)
n.Logtrack("info", fmt.Sprintf("[%s] last storage: the %dth batch of fragments all transferred to: %s", record.Fid, index, peer.ID.String()))
break
}
Expand Down

0 comments on commit 20b10d2

Please sign in to comment.