Expose WorkerID

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-10-28 20:22:07 +01:00
parent e575b5fe8a
commit ad905fc310
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
5 changed files with 23 additions and 19 deletions

View File

@ -781,8 +781,9 @@ type IpldObject struct {
}
type ActiveSync struct {
Base *types.TipSet
Target *types.TipSet
WorkerID uint64
Base *types.TipSet
Target *types.TipSet
Stage SyncStateStage
Height abi.ChainEpoch

View File

@ -135,7 +135,7 @@ func (sm *syncManager) SetPeerHead(ctx context.Context, p peer.ID, ts *types.Tip
func (sm *syncManager) State() []SyncerStateSnapshot {
sm.mx.Lock()
workerStates := make([]*workerState, 0, len(sm.state))
workerStates := make([]*workerState, 0, len(sm.state)+len(sm.history))
for _, ws := range sm.state {
workerStates = append(workerStates, ws)
}
@ -285,6 +285,7 @@ func (sm *syncManager) spawnWorker(target *types.TipSet) {
ts: target,
ss: new(SyncerState),
}
ws.ss.data.WorkerID = id
sm.mx.Lock()
sm.state[id] = ws

View File

@ -12,13 +12,14 @@ import (
)
type SyncerStateSnapshot struct {
Target *types.TipSet
Base *types.TipSet
Stage api.SyncStateStage
Height abi.ChainEpoch
Message string
Start time.Time
End time.Time
WorkerID uint64
Target *types.TipSet
Base *types.TipSet
Stage api.SyncStateStage
Height abi.ChainEpoch
Message string
Start time.Time
End time.Time
}
type SyncerState struct {

View File

@ -45,8 +45,8 @@ var syncStatusCmd = &cli.Command{
}
fmt.Println("sync status:")
for i, ss := range state.ActiveSyncs {
fmt.Printf("worker %d:\n", i)
for _, ss := range state.ActiveSyncs {
fmt.Printf("worker %d:\n", ss.WorkerID)
var base, target []cid.Cid
var heightDiff int64
var theight abi.ChainEpoch

View File

@ -37,13 +37,14 @@ func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
for i := range states {
ss := &states[i]
out.ActiveSyncs = append(out.ActiveSyncs, api.ActiveSync{
Base: ss.Base,
Target: ss.Target,
Stage: ss.Stage,
Height: ss.Height,
Start: ss.Start,
End: ss.End,
Message: ss.Message,
WorkerID: ss.WorkerID,
Base: ss.Base,
Target: ss.Target,
Stage: ss.Stage,
Height: ss.Height,
Start: ss.Start,
End: ss.End,
Message: ss.Message,
})
}
return out, nil