sql

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

type KV

type KV struct {
	MTId uint64
	K    []byte
	V    merkletree.Node
}

KV contains a key (K) and a value (V)

type NodeItem

type NodeItem struct {
	MTId uint64 `db:"mt_id"`
	Key  []byte `db:"key"`
	// Type is the type of node in the tree.
	Type byte `db:"type"`
	// ChildL is the left child of a middle node.
	ChildL []byte `db:"child_l"`
	// ChildR is the right child of a middle node.
	ChildR []byte `db:"child_r"`
	// Entry is the data stored in a leaf node.
	Entry     []byte  `db:"entry"`
	CreatedAt *uint64 `db:"created_at"`
	DeletedAt *uint64 `db:"deleted_at"`
}

func (*NodeItem) Node

func (item *NodeItem) Node() (*merkletree.Node, error)

type RootItem

type RootItem struct {
	MTId      uint64  `db:"mt_id"`
	Key       []byte  `db:"key"`
	CreatedAt *uint64 `db:"created_at"`
	DeletedAt *uint64 `db:"deleted_at"`
}

type Storage

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

Storage implements the db.Storage interface

func NewSqlStorage

func NewSqlStorage(db DB, mtId uint64) *Storage

NewSqlStorage returns a new Storage

func (*Storage) Get

func (s *Storage) Get(ctx context.Context,
	key []byte) (*merkletree.Node, error)

Get retrieves a value from a key in the db.Storage

func (*Storage) GetRoot

func (s *Storage) GetRoot(ctx context.Context) (*merkletree.Hash, error)

GetRoot retrieves a merkle tree root hash in the interface db.Tx

func (*Storage) Put

func (s *Storage) Put(ctx context.Context, key []byte,
	node *merkletree.Node) error

func (*Storage) SetRoot

func (s *Storage) SetRoot(ctx context.Context, hash *merkletree.Hash) error

Jump to

Keyboard shortcuts

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