ChainSafe / ChainSafe/gossamer

feat(dot/sync): Gap sync state

Open
#4,217 0 comments 0 reactions 1 assignee Claimed by @dimartiro View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.