store

package
v0.0.0-...-aa76b34 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStorer

type BlockStorer interface {
	Put(ctx context.Context, block *proto.Block) error
	Get(ctx context.Context, blockHash string) (*proto.Block, error)
	List(ctx context.Context) []*proto.Block
}

type ChainMemoryStore

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

func (*ChainMemoryStore) BlockStore

func (c *ChainMemoryStore) BlockStore(ctx context.Context) BlockStorer

func (*ChainMemoryStore) TxStore

func (c *ChainMemoryStore) TxStore(ctx context.Context) TxStorer

func (*ChainMemoryStore) UTXOStore

func (c *ChainMemoryStore) UTXOStore(ctx context.Context) UTXOStorer

type ChainMongoStore

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

func (*ChainMongoStore) BlockStore

func (c *ChainMongoStore) BlockStore(ctx context.Context) BlockStorer

func (*ChainMongoStore) TxStore

func (c *ChainMongoStore) TxStore(ctx context.Context) TxStorer

func (*ChainMongoStore) UTXOStore

func (c *ChainMongoStore) UTXOStore(ctx context.Context) UTXOStorer

type MemoryBlockStore

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

func NewMemoryBlockStore

func NewMemoryBlockStore() *MemoryBlockStore

func (*MemoryBlockStore) Get

func (m *MemoryBlockStore) Get(ctx context.Context, blockHash string) (*proto.Block, error)

func (*MemoryBlockStore) List

func (m *MemoryBlockStore) List(ctx context.Context) []*proto.Block

func (*MemoryBlockStore) Put

func (m *MemoryBlockStore) Put(ctx context.Context, block *proto.Block) error

type MemoryTxStore

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

MemoryTxStore

func NewMemoryTxStore

func NewMemoryTxStore() *MemoryTxStore

func (*MemoryTxStore) Get

func (m *MemoryTxStore) Get(ctx context.Context, txHash string) (*proto.Transaction, error)

func (*MemoryTxStore) List

func (m *MemoryTxStore) List(ctx context.Context) []*proto.Transaction

func (*MemoryTxStore) Put

type MemoryUTXOStore

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

func NewMemoryUTXOStore

func NewMemoryUTXOStore() *MemoryUTXOStore

func (*MemoryUTXOStore) Get

func (m *MemoryUTXOStore) Get(ctx context.Context, key string) (*proto.UTXO, error)

func (*MemoryUTXOStore) GetByAddress

func (m *MemoryUTXOStore) GetByAddress(ctx context.Context, address []byte) ([]*proto.UTXO, error)

func (*MemoryUTXOStore) List

func (m *MemoryUTXOStore) List(ctx context.Context) []*proto.UTXO

func (*MemoryUTXOStore) Put

func (m *MemoryUTXOStore) Put(ctx context.Context, utxo *proto.UTXO) error

type MongoBlockStore

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

func NewMongoBlockStore

func NewMongoBlockStore(client *mongo.Client) *MongoBlockStore

func (*MongoBlockStore) Get

func (m *MongoBlockStore) Get(ctx context.Context, blockID string) (*proto.Block, error)

Get retrieves a block from the database, implementing the BlockStorer interface.

func (*MongoBlockStore) List

func (m *MongoBlockStore) List(ctx context.Context) []*proto.Block

List retrieves all blocks from the database, implementing the BlockStorer interface.

func (*MongoBlockStore) Put

func (m *MongoBlockStore) Put(ctx context.Context, block *proto.Block) error

Put inserts a block into the database, implementing the BlockStorer interface.

type MongoTxStore

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

MongoTxStore

func NewMongoTxStore

func NewMongoTxStore(client *mongo.Client) *MongoTxStore

func (*MongoTxStore) Get

func (m *MongoTxStore) Get(ctx context.Context, txHash string) (*proto.Transaction, error)

Get retrieves transaction from the store, implements TxStorer interface

func (*MongoTxStore) List

func (m *MongoTxStore) List(ctx context.Context) []*proto.Transaction

List retrieves all transactions from the store, implements TxStorer interface

func (*MongoTxStore) Put

Put inserts transaction into the store, implements TxStorer interface

type MongoUTXOStore

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

func NewMongoUTXOStore

func NewMongoUTXOStore(client *mongo.Client) *MongoUTXOStore

func (*MongoUTXOStore) Get

func (m *MongoUTXOStore) Get(ctx context.Context, key string) (*proto.UTXO, error)

Get retrieves a UTXO from the store, implements UTXOStorer interface

func (*MongoUTXOStore) GetByAddress

func (m *MongoUTXOStore) GetByAddress(ctx context.Context, address []byte) ([]*proto.UTXO, error)

GetByAddress retrieves all UTXOs for a given address from the store, implements UTXOStorer interface

func (*MongoUTXOStore) List

func (m *MongoUTXOStore) List(ctx context.Context) []*proto.UTXO

List retrieves all UTXOs from the store, implements UTXOStorer interface

func (*MongoUTXOStore) Put

func (m *MongoUTXOStore) Put(ctx context.Context, utxo *proto.UTXO) error

Put inserts a new UTXO into the store, implements UTXOStorer interface

type Storer

type Storer interface {
	UTXOStore(context.Context) UTXOStorer
	TxStore(context.Context) TxStorer
	BlockStore(context.Context) BlockStorer
}

func NewChainMemoryStore

func NewChainMemoryStore() Storer

func NewChainMongoStore

func NewChainMongoStore(client *mongo.Client) Storer

func NewChainStore

func NewChainStore(sType string) (Storer, error)

type TxStorer

type TxStorer interface {
	Put(ctx context.Context, tx *proto.Transaction) error
	Get(ctx context.Context, txHash string) (*proto.Transaction, error)
	List(ctx context.Context) []*proto.Transaction
}

type UTXOStorer

type UTXOStorer interface {
	Put(ctx context.Context, utxo *proto.UTXO) error
	Get(ctx context.Context, key string) (*proto.UTXO, error)
	List(ctx context.Context) []*proto.UTXO
	GetByAddress(ctx context.Context, address []byte) ([]*proto.UTXO, error)
}

Jump to

Keyboard shortcuts

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