Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1313 from antsystem/supernode_support_seed_task_pr
Browse files Browse the repository at this point in the history
Supernode support seed task pr
  • Loading branch information
lowzj authored May 8, 2020
2 parents 0ca3333 + 4525cb4 commit 849f36f
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
23 changes: 22 additions & 1 deletion apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ paths:
200:
description: "no error"
schema:
$ref: "#/definitions/ResultInfo"
$ref: "#/definitions/HeartBeatResponse"
500:
$ref: "#/responses/500ErrorResponse"

Expand Down Expand Up @@ -1552,6 +1552,27 @@ definitions:
This dfget is treated a client and carries a client ID.
Thus, multiple dfget processes on the same peer have different CIDs.
HeartBeatResponse:
type: "object"
description: ""
properties:
version:
type: "string"
description: |
The version of supernode. If supernode restarts, version should be different, so dfdaemon could know
the restart of supernode.
needRegister:
type: "boolean"
description: |
If peer do not register in supernode, set needRegister to be true, else set to be false.
seedTaskIDs:
type: "array"
description: |
The array of seed taskID which now are selected as seed for the peer. If peer have other seed file which
is not included in the array, these seed file should be weed out.
items:
type: "string"

ErrorResponse:
type: "object"
description: |
Expand Down
54 changes: 54 additions & 0 deletions apis/types/heart_beat_response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions supernode/server/0.3_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,11 @@ func (s *Server) reportPieceError(ctx context.Context, rw http.ResponseWriter, r
rw.WriteHeader(http.StatusOK)
return nil
}

func (s *Server) fetchP2PNetworkInfo(ctx context.Context, rw http.ResponseWriter, req *http.Request) (err error) {
return EncodeResponse(rw, http.StatusOK, &types.NetworkInfoFetchResponse{})
}

func (s *Server) reportPeerHealth(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
return EncodeResponse(rw, http.StatusOK, &types.HeartBeatResponse{})
}
2 changes: 2 additions & 0 deletions supernode/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func initRoute(s *Server) *mux.Router {
{Method: http.MethodGet, Path: "/peer/piece/suc", HandlerFunc: s.reportPiece},
{Method: http.MethodGet, Path: "/peer/service/down", HandlerFunc: s.reportServiceDown},
{Method: http.MethodGet, Path: "/peer/piece/error", HandlerFunc: s.reportPieceError},
{Method: http.MethodPost, Path: "/peer/network", HandlerFunc: s.fetchP2PNetworkInfo},
{Method: http.MethodPost, Path: "/peer/heartbeat", HandlerFunc: s.reportPeerHealth},

// v1
// peer
Expand Down

0 comments on commit 849f36f

Please sign in to comment.