Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions routes/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var (
IsBlacklisted = []byte{1}
)

const NodeVersion = "3.4.4"

const (
// RoutePathAPIBase ...
RoutePathAPIBase = "/api/v1"
Expand All @@ -46,6 +48,8 @@ const (
RoutePathAPINodeInfo = "/api/v1/node-info"
// RoutePathAPIBlock ...
RoutePathAPIBlock = "/api/v1/block"
// RoutePathAPINodeVersion ...
RoutePathAPINodeVersion = "/api/v1/node-version"
)

// APIRoutes returns the routes for the public-facing API.
Expand Down Expand Up @@ -100,6 +104,13 @@ func (fes *APIServer) APIRoutes() []Route {
fes.APIBlock,
PublicAccess,
},
{
"APINodeVersion",
[]string{"GET"},
RoutePathAPINodeVersion,
fes.APINodeVersion,
PublicAccess,
},
}

return APIRoutes
Expand Down Expand Up @@ -1373,6 +1384,21 @@ func (fes *APIServer) APIBlock(ww http.ResponseWriter, rr *http.Request) {
}
}

type APINodeVersionResponse struct {
Version string
}

// APINodeVersion returns the version of the node.
func (fes *APIServer) APINodeVersion(ww http.ResponseWriter, rr *http.Request) {
if err := json.NewEncoder(ww).Encode(&APINodeVersionResponse{
Version: NodeVersion,
}); err != nil {
APIAddError(ww, fmt.Sprintf("APINodeVersion: Problem encoding response "+
"as JSON: %v", err))
return
}
}

// TODO: This is a somewhat redundant version of processTransaction It exists
// because the API needed to cut out the derivation of the public key from the
// user object, among other things.
Expand Down