Expose WorkerID
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
e575b5fe8a
commit
ad905fc310
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user