Expose WorkerID
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
e575b5fe8a
commit
ad905fc310
@ -781,6 +781,7 @@ type IpldObject struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ActiveSync struct {
|
type ActiveSync struct {
|
||||||
|
WorkerID uint64
|
||||||
Base *types.TipSet
|
Base *types.TipSet
|
||||||
Target *types.TipSet
|
Target *types.TipSet
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ func (sm *syncManager) SetPeerHead(ctx context.Context, p peer.ID, ts *types.Tip
|
|||||||
|
|
||||||
func (sm *syncManager) State() []SyncerStateSnapshot {
|
func (sm *syncManager) State() []SyncerStateSnapshot {
|
||||||
sm.mx.Lock()
|
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 {
|
for _, ws := range sm.state {
|
||||||
workerStates = append(workerStates, ws)
|
workerStates = append(workerStates, ws)
|
||||||
}
|
}
|
||||||
@ -285,6 +285,7 @@ func (sm *syncManager) spawnWorker(target *types.TipSet) {
|
|||||||
ts: target,
|
ts: target,
|
||||||
ss: new(SyncerState),
|
ss: new(SyncerState),
|
||||||
}
|
}
|
||||||
|
ws.ss.data.WorkerID = id
|
||||||
|
|
||||||
sm.mx.Lock()
|
sm.mx.Lock()
|
||||||
sm.state[id] = ws
|
sm.state[id] = ws
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SyncerStateSnapshot struct {
|
type SyncerStateSnapshot struct {
|
||||||
|
WorkerID uint64
|
||||||
Target *types.TipSet
|
Target *types.TipSet
|
||||||
Base *types.TipSet
|
Base *types.TipSet
|
||||||
Stage api.SyncStateStage
|
Stage api.SyncStateStage
|
||||||
|
@ -45,8 +45,8 @@ var syncStatusCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("sync status:")
|
fmt.Println("sync status:")
|
||||||
for i, ss := range state.ActiveSyncs {
|
for _, ss := range state.ActiveSyncs {
|
||||||
fmt.Printf("worker %d:\n", i)
|
fmt.Printf("worker %d:\n", ss.WorkerID)
|
||||||
var base, target []cid.Cid
|
var base, target []cid.Cid
|
||||||
var heightDiff int64
|
var heightDiff int64
|
||||||
var theight abi.ChainEpoch
|
var theight abi.ChainEpoch
|
||||||
|
@ -37,6 +37,7 @@ func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
|
|||||||
for i := range states {
|
for i := range states {
|
||||||
ss := &states[i]
|
ss := &states[i]
|
||||||
out.ActiveSyncs = append(out.ActiveSyncs, api.ActiveSync{
|
out.ActiveSyncs = append(out.ActiveSyncs, api.ActiveSync{
|
||||||
|
WorkerID: ss.WorkerID,
|
||||||
Base: ss.Base,
|
Base: ss.Base,
|
||||||
Target: ss.Target,
|
Target: ss.Target,
|
||||||
Stage: ss.Stage,
|
Stage: ss.Stage,
|
||||||
|
Loading…
Reference in New Issue
Block a user