-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,8 @@ func Start(state interfaces.IState) { | |
server.Post("/v2", HandleV2) | ||
server.Get("/v2", HandleV2) | ||
|
||
server.Get("/status", HandleStatus) | ||
|
||
// start the debugging api if we are not on the main network | ||
if state.GetNetworkName() != "MAIN" { | ||
server.Post("/debug", HandleDebug) | ||
|
@@ -801,6 +803,77 @@ func HandleHeights(ctx *web.Context) { | |
returnMsg(ctx, jsonResp.Result, true) | ||
} | ||
|
||
type statusResponse struct { | ||
Version string | ||
NodeName string | ||
BootTime int64 | ||
CurrentTime int64 | ||
CurrentBlockStartTime int64 | ||
CurrentMinuteStartTime int64 | ||
CurrentMinute int | ||
LeaderHeight uint32 | ||
HighestSavedBlock uint32 | ||
HighestKnownBlock uint32 | ||
DBHeightComplete uint32 | ||
This comment has been minimized.
Sorry, something went wrong. |
||
EntryBlockDBHeightComplete uint32 | ||
EntryBlockDBHeightProcessing uint32 | ||
Syncing bool | ||
SyncingEOMs bool | ||
SyncingDBSigs bool | ||
Running bool | ||
IgnoreDone bool | ||
This comment has been minimized.
Sorry, something went wrong.
stackdump
Author
Contributor
|
||
Role string | ||
} | ||
|
||
func HandleStatus(ctx *web.Context) { | ||
ServersMutex.Lock() | ||
s := ctx.Server.Env["state"].(interfaces.IState) | ||
ServersMutex.Unlock() | ||
|
||
feds := s.GetFedServers(s.GetLLeaderHeight()) | ||
audits := s.GetAuditServers(s.GetLLeaderHeight()) | ||
role := "follower" | ||
foundRole := false | ||
for _, fed := range feds { | ||
if !foundRole && s.GetIdentityChainID().IsSameAs(fed.GetChainID()) { | ||
role = "leader" | ||
break | ||
} | ||
} | ||
for _, aud := range audits { | ||
if !foundRole && s.GetIdentityChainID().IsSameAs(aud.GetChainID()) { | ||
role = "audit" | ||
} | ||
} | ||
|
||
jsonResp := primitives.NewJSON2Response() | ||
jsonResp.ID = 0 | ||
jsonResp.Result = statusResponse{ | ||
This comment has been minimized.
Sorry, something went wrong.
stackdump
Author
Contributor
|
||
s.GetFactomdVersion(), | ||
s.GetFactomNodeName(), | ||
s.GetBootTime(), | ||
s.GetCurrentTime(), | ||
s.GetCurrentBlockStartTime(), | ||
s.GetCurrentMinuteStartTime(), | ||
s.GetCurrentMinute(), | ||
s.GetLeaderHeight(), | ||
s.GetHighestSavedBlk(), | ||
s.GetHighestKnownBlock(), | ||
s.GetEntryBlockDBHeightComplete(), | ||
s.GetDBHeightComplete(), | ||
s.GetEntryBlockDBHeightProcessing(), | ||
s.IsSyncing(), | ||
s.IsSyncingEOMs(), | ||
s.IsSyncingDBSigs(), | ||
s.Running(), | ||
s.GetIgnoreDone(), | ||
role, | ||
} | ||
|
||
// REVIEW: should we only conditionally return status 200 if some precondition is met | ||
ctx.Write([]byte(jsonResp.String())) | ||
} | ||
|
||
/********************************************************* | ||
* Support Functions | ||
*********************************************************/ | ||
|
DBHeightComplete shows 0 all the time – need to fix it [DeFacto] Anton IlzheevToday at 10:55 AM