ChainSafe / ChainSafe/gossamer
feat(dot/sync): Gap sync state
- Dominant language
- Go
- Stars
- 454
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
### Description
The `GapSyncState` can be place in the file `dot/sync/gap_sync_state.go`, this file will be similar to `dot/state/grandpa.go`, example:
```go
type GapSyncInfo struct {
latestImportedBlock common.Hash
target common.Hash
}
type GapSyncState struct {
gapSyncDB database.Table
}
func NewGapSyncState(db database.Database, ...) {
grandpaDB := database.NewTable(db, gapSyncPrefix)
}
func (g *GapSyncState) Retrieve() (*GapSyncInfo, error) {...}
func (g *GapSyncState) Write(info *GapSyncInfo) error {
}
```
- for writing I would suggest to use scale.Marshal to encode the info into bytes
- no need to keep previous information, it is ok to replace the old info.
Contributor guide
Assessment
This issue has not been assessed yet.