|
|
|
@ -16,6 +16,7 @@ const ( |
|
|
|
|
Finish SyncStageID = "Finish" // Nominal stage after all other stages
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// GetStageName returns the stage name in string
|
|
|
|
|
func GetStageName(stage string, isBeacon bool, prune bool) string { |
|
|
|
|
name := stage |
|
|
|
|
if isBeacon { |
|
|
|
@ -27,18 +28,11 @@ func GetStageName(stage string, isBeacon bool, prune bool) string { |
|
|
|
|
return name |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetStageID returns the stage name in bytes
|
|
|
|
|
func GetStageID(stage SyncStageID, isBeacon bool, prune bool) []byte { |
|
|
|
|
return []byte(GetStageName(string(stage), isBeacon, prune)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func GetBucketName(bucketName string, isBeacon bool) string { |
|
|
|
|
name := bucketName |
|
|
|
|
if isBeacon { |
|
|
|
|
name = "Beacon" + name |
|
|
|
|
} |
|
|
|
|
return name |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetStageProgress retrieves saved progress of a given sync stage from the database
|
|
|
|
|
func GetStageProgress(db kv.Getter, stage SyncStageID, isBeacon bool) (uint64, error) { |
|
|
|
|
stgID := GetStageID(stage, isBeacon, false) |
|
|
|
@ -65,6 +59,7 @@ func GetStageCleanUpProgress(db kv.Getter, stage SyncStageID, isBeacon bool) (ui |
|
|
|
|
return unmarshalData(v) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SaveStageCleanUpProgress stores the progress of the clean up for a given sync stage to the database
|
|
|
|
|
func SaveStageCleanUpProgress(db kv.Putter, stage SyncStageID, isBeacon bool, progress uint64) error { |
|
|
|
|
stgID := GetStageID(stage, isBeacon, true) |
|
|
|
|
return db.Put(kv.SyncStageProgress, stgID, marshalData(progress)) |
|
|
|
|