-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parachain): availability store skeleton (#3521)
- Loading branch information
1 parent
d998e76
commit 341a25c
Showing
4 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2023 ChainSafe Systems (ON) | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
package availability_store | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ChainSafe/gossamer/internal/log" | ||
) | ||
|
||
var logger = log.NewFromGlobal(log.AddContext("pkg", "parachain-availability-store")) | ||
|
||
type AvailabilityStoreSubsystem struct { | ||
SubSystemToOverseer chan<- any | ||
OverseerToSubSystem <-chan any | ||
//db interface{} // Define the actual database type | ||
//config Config // Define the actual config type | ||
//pruningConfig PruningConfig | ||
//clock Clock | ||
//metrics Metrics | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) Run(ctx context.Context, OverseerToSubsystem chan any, | ||
SubsystemToOverseer chan any) error { | ||
av.processMessages() | ||
return nil | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) processMessages() { | ||
for msg := range av.OverseerToSubSystem { | ||
logger.Debugf("received message %v", msg) | ||
switch msg := msg.(type) { | ||
case QueryAvailableData: | ||
av.handleQueryAvailableData(msg) | ||
case QueryDataAvailability: | ||
av.handleQueryDataAvailability(msg) | ||
case QueryChunk: | ||
av.handleQueryChunk(msg) | ||
case QueryChunkSize: | ||
av.handleQueryChunkSize(msg) | ||
case QueryAllChunks: | ||
av.handleQueryAllChunks(msg) | ||
case QueryChunkAvailability: | ||
av.handleQueryChunkAvailability(msg) | ||
case StoreChunk: | ||
av.handleStoreChunk(msg) | ||
case StoreAvailableData: | ||
av.handleStoreAvailableData(msg) | ||
} | ||
} | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleQueryAvailableData(msg QueryAvailableData) { | ||
// TODO: handle query available data | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleQueryDataAvailability(msg QueryDataAvailability) { | ||
// TODO: handle query data availability | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleQueryChunk(msg QueryChunk) { | ||
// TODO: handle query chunk | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleQueryChunkSize(msg QueryChunkSize) { | ||
// TODO: handle query chunk size | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleQueryAllChunks(msg QueryAllChunks) { | ||
// TODO: handle query all chunks | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleQueryChunkAvailability(msg QueryChunkAvailability) { | ||
// TODO: handle query chunk availability | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleStoreChunk(msg StoreChunk) { | ||
// TODO: handle store chunk | ||
} | ||
|
||
func (av *AvailabilityStoreSubsystem) handleStoreAvailableData(msg StoreAvailableData) { | ||
// TODO: handle store available data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2023 ChainSafe Systems (ON) | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
package availability_store | ||
|
||
import ( | ||
"github.com/ChainSafe/gossamer/lib/common" | ||
) | ||
|
||
// QueryAvailableData query a AvailableData from the AV store | ||
type QueryAvailableData struct { | ||
CandidateHash common.Hash | ||
AvailableData AvailableData | ||
} | ||
|
||
type QueryDataAvailability struct { | ||
CandidateHash common.Hash | ||
Sender chan AvailableData | ||
} | ||
|
||
type QueryChunk struct { | ||
CandidateHash common.Hash | ||
ValidatorIndex uint32 | ||
Sender chan []byte | ||
} | ||
|
||
type QueryChunkSize struct { | ||
CandidateHash common.Hash | ||
Sender chan uint32 | ||
} | ||
|
||
type QueryAllChunks struct { | ||
CandidateHash common.Hash | ||
Sender chan []byte | ||
} | ||
|
||
type QueryChunkAvailability struct { | ||
CandidateHash common.Hash | ||
ValidatorIndex uint32 | ||
Sender chan bool | ||
} | ||
|
||
type StoreChunk struct { | ||
CandidateHash common.Hash | ||
Chunk []byte | ||
Sender chan any | ||
} | ||
|
||
type StoreAvailableData struct { | ||
CandidateHash common.Hash | ||
NValidators uint32 | ||
AvailableData AvailableData | ||
ExpectedErasureRoot common.Hash | ||
Sender chan any | ||
} | ||
|
||
type AvailableData struct{} // Define your AvailableData type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2023 ChainSafe Systems (ON) | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
package availability_store | ||
|
||
func Register(overseerChan chan<- any) (*AvailabilityStoreSubsystem, error) { | ||
availabilityStore := AvailabilityStoreSubsystem{ | ||
SubSystemToOverseer: overseerChan, | ||
} | ||
|
||
return &availabilityStore, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters