store

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package store. This memory store is for testing purposes only. True production store will be implemented later. So im adding a TODO comment here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Engine string `mapstructure:"engine" yaml:"engine"`
	Path   string `mapstructure:"path"   yaml:"path"`
}

Config holds storage configuration

func DefaultConfig

func DefaultConfig() Config

type L2BlockStore

type L2BlockStore interface {
	StoreL2Block(ctx context.Context, block *pb.L2Block) error
	GetL2Block(ctx context.Context, chainID []byte, blockNumber uint64) (*pb.L2Block, error)
	GetL2BlockByHash(ctx context.Context, blockHash []byte) (*pb.L2Block, error)
	GetLatestL2Block(ctx context.Context, chainID []byte) (*pb.L2Block, error)
	GetL2BlocksForSlot(ctx context.Context, slot uint64) ([]*pb.L2Block, error)
	DeleteL2BlocksBeforeSlot(ctx context.Context, slot uint64) error
}

type MemoryL2BlockStore

type MemoryL2BlockStore struct {
	// contains filtered or unexported fields
}

MemoryL2BlockStore provides in-memory storage for L2 blocks.

func NewMemoryL2BlockStore

func NewMemoryL2BlockStore() *MemoryL2BlockStore

func (*MemoryL2BlockStore) DeleteL2BlocksBeforeSlot

func (s *MemoryL2BlockStore) DeleteL2BlocksBeforeSlot(_ context.Context, slot uint64) error

func (*MemoryL2BlockStore) GetL2Block

func (s *MemoryL2BlockStore) GetL2Block(_ context.Context, chainID []byte, blockNumber uint64) (*pb.L2Block, error)

func (*MemoryL2BlockStore) GetL2BlockByHash

func (s *MemoryL2BlockStore) GetL2BlockByHash(_ context.Context, blockHash []byte) (*pb.L2Block, error)

func (*MemoryL2BlockStore) GetL2BlocksForSlot

func (s *MemoryL2BlockStore) GetL2BlocksForSlot(_ context.Context, slot uint64) ([]*pb.L2Block, error)

func (*MemoryL2BlockStore) GetLatestL2Block

func (s *MemoryL2BlockStore) GetLatestL2Block(_ context.Context, chainID []byte) (*pb.L2Block, error)

func (*MemoryL2BlockStore) StoreL2Block

func (s *MemoryL2BlockStore) StoreL2Block(_ context.Context, block *pb.L2Block) error

type MemorySuperblockStore

type MemorySuperblockStore struct {
	// contains filtered or unexported fields
}

MemorySuperblockStore provides in-memory storage for superblocks.

func NewMemorySuperblockStore

func NewMemorySuperblockStore() *MemorySuperblockStore

func (*MemorySuperblockStore) DeleteSuperblock

func (s *MemorySuperblockStore) DeleteSuperblock(_ context.Context, number uint64) error

func (*MemorySuperblockStore) GetLatestSuperblock

func (s *MemorySuperblockStore) GetLatestSuperblock(context.Context) (*Superblock, error)

func (*MemorySuperblockStore) GetSuperblock

func (s *MemorySuperblockStore) GetSuperblock(_ context.Context, number uint64) (*Superblock, error)

func (*MemorySuperblockStore) GetSuperblockByHash

func (s *MemorySuperblockStore) GetSuperblockByHash(_ context.Context, hash []byte) (*Superblock, error)

func (*MemorySuperblockStore) GetSuperblockCount

func (s *MemorySuperblockStore) GetSuperblockCount(context.Context) (uint64, error)

func (*MemorySuperblockStore) StoreSuperblock

func (s *MemorySuperblockStore) StoreSuperblock(_ context.Context, superblock *Superblock) error

type Superblock

type Superblock struct {
	Number            uint64           `json:"number"`
	Slot              uint64           `json:"slot"`
	ParentHash        common.Hash      `json:"parent_hash"`
	Hash              common.Hash      `json:"hash"`
	MerkleRoot        common.Hash      `json:"merkle_root"`
	Timestamp         time.Time        `json:"timestamp"`
	L2Blocks          []*pb.L2Block    `json:"l2_blocks"`
	IncludedXTs       []common.Hash    `json:"included_xts"`
	Proof             []byte           `json:"proof,omitempty"`
	L1TransactionHash common.Hash      `json:"l1_transaction_hash,omitempty"`
	Status            SuperblockStatus `json:"status"`
}

type SuperblockStatus

type SuperblockStatus string
const (
	SuperblockStatusPending    SuperblockStatus = "pending"
	SuperblockStatusSubmitted  SuperblockStatus = "submitted"
	SuperblockStatusConfirmed  SuperblockStatus = "confirmed"
	SuperblockStatusFinalized  SuperblockStatus = "finalized"
	SuperblockStatusRolledBack SuperblockStatus = "rolled_back"
)

type SuperblockStore

type SuperblockStore interface {
	StoreSuperblock(ctx context.Context, superblock *Superblock) error
	GetSuperblock(ctx context.Context, number uint64) (*Superblock, error)
	GetSuperblockByHash(ctx context.Context, hash []byte) (*Superblock, error)
	GetLatestSuperblock(ctx context.Context) (*Superblock, error)
	GetSuperblockCount(ctx context.Context) (uint64, error)
	DeleteSuperblock(ctx context.Context, number uint64) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL