meddb

package
v0.0.0-...-180b776 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2017 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 Bigtable

type Bigtable interface {
	Put(tableName []byte, op *PutOp) error
	Get(tableName []byte, op *GetOp) (map[string][]*Cell, error)
	CreateTable(tableName []byte) error
}

type Block

type Block struct {
	Hash         []byte
	Transactions []*Transaction
	CreatedAt    *big.Int
	Creator      []byte
	Sig          []byte
	Voters       [][]byte
	State        int
}

func (*Block) Clone

func (b *Block) Clone() *Block

type BlockChangefeed

type BlockChangefeed interface {
	Next(*BlockChangefeedRes) bool
}

type BlockChangefeedRes

type BlockChangefeedRes struct {
	OldVal *Block
	NewVal *Block
}

type BlockchainDB

type BlockchainDB interface {
	// First time setup to create required tables and indices
	SetupTables() error

	// Writes transaction to backlog table
	WriteTransaction(*Transaction) error
	// Returns transactions currently assigned to given node from backlog table
	GetAssignedTransactions([]byte) ([]*Transaction, error)
	// Returns transactions older than given time (no order) from backlog table
	GetStaleTransactions(int64) ([]*Transaction, error)
	// Deletes given transactions from backlog table
	DeleteTransactions([]*Transaction) error

	// Writes block to block table
	WriteBlock(*Block) error
	// Returns blocks from block table by block ids
	GetBlocks([][]byte) ([]*Block, error)
	// Returns k oldest blocks from block table starting at given timestamp sorted by increasing
	// CreatedAt timestamp.
	GetOldestBlocks(int64, int) ([]*Block, error)
	// Returns outputs for given output ids
	GetOutputs([][]byte) ([]*OutputRes, error)
	// Returns inputs for given output ids
	GetInputsByOutput([][]byte) ([]*InputRes, error)

	// Writes vote to vote table
	WriteVote(*Vote) error
	// Returns all votes for given public key from votes table with the given VotedAt
	GetVotes([]byte, int64) ([]*Vote, error)
	// Returns k most recent votes for given public key from votes table sorted by decreasing
	// VotedAt timestamp.
	GetRecentVotes([]byte, int) ([]*Vote, error)

	// Returns changefeed for all transactions assigned to the given public key
	GetAssignedTransactionChangefeed([]byte) (TransactionChangefeed, error)
	// Returns changefeed for all blocks
	GetBlockChangefeed() (BlockChangefeed, error)
	// Returns changefeed for all votes
	GetVoteChangefeed() (VoteChangefeed, error)
}

type Cell

type Cell struct {
	VerId *big.Int
	Data  []byte
}

func NewCell

func NewCell(data []byte) *Cell

func NewCellVer

func NewCellVer(verId int64, data []byte) *Cell

func (*Cell) Clone

func (c *Cell) Clone() *Cell

type ColIdAlreadyExists

type ColIdAlreadyExists struct {
	ColId []byte
}

func (*ColIdAlreadyExists) Error

func (e *ColIdAlreadyExists) Error() string

type Database

type Database interface {
	Get([]byte) ([]byte, error)
	Put([]byte, []byte) error
	Contains([]byte) (bool, error)
	Commit() error
	Delete([]byte) error
}

type GetOp

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

func NewGetOp

func NewGetOp(rowId []byte, colIds [][]byte) *GetOp

func NewGetOpLimit

func NewGetOpLimit(rowId []byte, colIds [][]byte, limit uint32) *GetOp

func NewGetOpRange

func NewGetOpRange(rowId []byte, colIds [][]byte, minVer, maxVer int64) *GetOp

func NewGetOpVer

func NewGetOpVer(rowId []byte, colIds [][]byte, verId int64) *GetOp

type Input

type Input struct {
	Type       int
	OutputHash []byte
	Data       []byte
}

func (*Input) Clone

func (in *Input) Clone() *Input

type InputRes

type InputRes struct {
	Block *Block
	Input *Input
}

Structure used to return the result of GetInputsByOutput endpoint.

type MemoryBigtable

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

In memory bigtable db mainly meant for testing

func NewMemoryBigtable

func NewMemoryBigtable() (*MemoryBigtable, error)

func (*MemoryBigtable) CreateTable

func (bt *MemoryBigtable) CreateTable(tableName []byte) error

func (*MemoryBigtable) Get

func (bt *MemoryBigtable) Get(tableName []byte, op *GetOp) (map[string][]*Cell, error)

func (*MemoryBigtable) Put

func (bt *MemoryBigtable) Put(tableName []byte, op *PutOp) error

type MemoryBlockchainDB

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

In-memory blockchain db mainly meant for testing

func NewMemoryBlockchainDB

func NewMemoryBlockchainDB() (*MemoryBlockchainDB, error)

func (*MemoryBlockchainDB) DeleteTransactions

func (db *MemoryBlockchainDB) DeleteTransactions(txs []*Transaction) error

func (*MemoryBlockchainDB) GetAssignedTransactionChangefeed

func (db *MemoryBlockchainDB) GetAssignedTransactionChangefeed(
	pubKey []byte) (TransactionChangefeed, error)

func (*MemoryBlockchainDB) GetAssignedTransactions

func (db *MemoryBlockchainDB) GetAssignedTransactions(pubKey []byte) ([]*Transaction, error)

Note: This is not performant, do not use in prod

func (*MemoryBlockchainDB) GetBlockChangefeed

func (db *MemoryBlockchainDB) GetBlockChangefeed() (BlockChangefeed, error)

func (*MemoryBlockchainDB) GetBlocks

func (db *MemoryBlockchainDB) GetBlocks(blockIds [][]byte) ([]*Block, error)

func (*MemoryBlockchainDB) GetInputsByOutput

func (db *MemoryBlockchainDB) GetInputsByOutput(outputIds [][]byte) ([]*InputRes, error)

func (*MemoryBlockchainDB) GetOldestBlocks

func (db *MemoryBlockchainDB) GetOldestBlocks(start int64, limit int) ([]*Block, error)

func (*MemoryBlockchainDB) GetOutputs

func (db *MemoryBlockchainDB) GetOutputs(outputIds [][]byte) ([]*OutputRes, error)

func (*MemoryBlockchainDB) GetRecentVotes

func (db *MemoryBlockchainDB) GetRecentVotes(pubKey []byte, limit int) ([]*Vote, error)

func (*MemoryBlockchainDB) GetStaleTransactions

func (db *MemoryBlockchainDB) GetStaleTransactions(before int64) ([]*Transaction, error)

Note: This is not performant, do not use in prod

func (*MemoryBlockchainDB) GetVoteChangefeed

func (db *MemoryBlockchainDB) GetVoteChangefeed() (VoteChangefeed, error)

func (*MemoryBlockchainDB) GetVotes

func (db *MemoryBlockchainDB) GetVotes(pubKey []byte, votedAt int64) ([]*Vote, error)

func (*MemoryBlockchainDB) SetupTables

func (db *MemoryBlockchainDB) SetupTables() error

func (*MemoryBlockchainDB) WriteBlock

func (db *MemoryBlockchainDB) WriteBlock(b *Block) error

func (*MemoryBlockchainDB) WriteTransaction

func (db *MemoryBlockchainDB) WriteTransaction(tx *Transaction) error

func (*MemoryBlockchainDB) WriteVote

func (db *MemoryBlockchainDB) WriteVote(v *Vote) error

type MemoryDatabase

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

func NewMemoryDatabase

func NewMemoryDatabase() (*MemoryDatabase, error)

func (*MemoryDatabase) Commit

func (db *MemoryDatabase) Commit() error

func (*MemoryDatabase) Contains

func (db *MemoryDatabase) Contains(key []byte) (bool, error)

Returns whether the database contains the key

func (*MemoryDatabase) Delete

func (db *MemoryDatabase) Delete(key []byte) error

Delete the key from the database. Returns NotFoundError if the key does not exist.

func (*MemoryDatabase) Get

func (db *MemoryDatabase) Get(key []byte) ([]byte, error)

Gets value from database with given key If value dues not exist, returns error and nil

func (*MemoryDatabase) Put

func (db *MemoryDatabase) Put(key []byte, value []byte) error

Puts value into database at given key

type NotFoundError

type NotFoundError struct {
	Key []byte
}

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Output

type Output struct {
	Hash []byte
	Type int
	Data []byte
}

func (*Output) Clone

func (o *Output) Clone() *Output

type OutputRes

type OutputRes struct {
	Block       *Block
	Transaction *Transaction
	Output      *Output
}

Structure used to return the result of the GetOutputs endpoint.

type PutOp

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

func NewPutOp

func NewPutOp(rowId []byte) *PutOp

func (*PutOp) AddCol

func (op *PutOp) AddCol(colId []byte, data []byte) error

func (*PutOp) AddColVer

func (op *PutOp) AddColVer(colId []byte, verId int64, data []byte) error

type RethinkBigtable

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

func NewRethinkBigtable

func NewRethinkBigtable(addresses []string, database string) (*RethinkBigtable, error)

func (*RethinkBigtable) CreateTable

func (bt *RethinkBigtable) CreateTable(tableName []byte) error

func (*RethinkBigtable) Get

func (bt *RethinkBigtable) Get(tableName []byte, op *GetOp) (map[string][]*Cell, error)

func (*RethinkBigtable) Put

func (bt *RethinkBigtable) Put(tableName []byte, op *PutOp) error

type RethinkBlockChangefeed

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

func (*RethinkBlockChangefeed) Next

type RethinkBlockchainDB

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

func NewRethinkBlockchainDB

func NewRethinkBlockchainDB(addresses []string, database string) (*RethinkBlockchainDB, error)

func (*RethinkBlockchainDB) DeleteTransactions

func (db *RethinkBlockchainDB) DeleteTransactions(txs []*Transaction) error

func (*RethinkBlockchainDB) GetAssignedTransactionChangefeed

func (db *RethinkBlockchainDB) GetAssignedTransactionChangefeed(
	pubKey []byte) (TransactionChangefeed, error)

func (*RethinkBlockchainDB) GetAssignedTransactions

func (db *RethinkBlockchainDB) GetAssignedTransactions(pubKey []byte) ([]*Transaction, error)

func (*RethinkBlockchainDB) GetBlockChangefeed

func (db *RethinkBlockchainDB) GetBlockChangefeed() (BlockChangefeed, error)

func (*RethinkBlockchainDB) GetBlocks

func (db *RethinkBlockchainDB) GetBlocks(blockIds [][]byte) ([]*Block, error)

func (*RethinkBlockchainDB) GetInputsByOutput

func (db *RethinkBlockchainDB) GetInputsByOutput(outputIds [][]byte) ([]*InputRes, error)

func (*RethinkBlockchainDB) GetOldestBlocks

func (db *RethinkBlockchainDB) GetOldestBlocks(start int64, limit int) ([]*Block, error)

func (*RethinkBlockchainDB) GetOutputs

func (db *RethinkBlockchainDB) GetOutputs(outputIds [][]byte) ([]*OutputRes, error)

func (*RethinkBlockchainDB) GetRecentVotes

func (db *RethinkBlockchainDB) GetRecentVotes(pubKey []byte, limit int) ([]*Vote, error)

func (*RethinkBlockchainDB) GetStaleTransactions

func (db *RethinkBlockchainDB) GetStaleTransactions(before int64) ([]*Transaction, error)

func (*RethinkBlockchainDB) GetVoteChangefeed

func (db *RethinkBlockchainDB) GetVoteChangefeed() (VoteChangefeed, error)

func (*RethinkBlockchainDB) GetVotes

func (db *RethinkBlockchainDB) GetVotes(pubKey []byte, votedAt int64) ([]*Vote, error)

func (*RethinkBlockchainDB) SetupTables

func (db *RethinkBlockchainDB) SetupTables() error

func (*RethinkBlockchainDB) WriteBlock

func (db *RethinkBlockchainDB) WriteBlock(b *Block) error

func (*RethinkBlockchainDB) WriteTransaction

func (db *RethinkBlockchainDB) WriteTransaction(tx *Transaction) error

func (*RethinkBlockchainDB) WriteVote

func (db *RethinkBlockchainDB) WriteVote(v *Vote) error

type RethinkTransactionChangefeed

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

func (*RethinkTransactionChangefeed) Next

type RethinkVoteChangefeed

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

func (*RethinkVoteChangefeed) Next

type RowNotFoundError

type RowNotFoundError struct {
	RowId []byte
}

func (*RowNotFoundError) Error

func (e *RowNotFoundError) Error() string

type TableAlreadyExists

type TableAlreadyExists struct {
	TableName []byte
}

func (*TableAlreadyExists) Error

func (e *TableAlreadyExists) Error() string

type TableNotFoundError

type TableNotFoundError struct {
	TableName []byte
}

func (*TableNotFoundError) Error

func (e *TableNotFoundError) Error() string

type Transaction

type Transaction struct {
	Hash       []byte
	AssignedTo []byte // Public key of node this transaction is assigned to
	AssignedAt *big.Int
	Type       int
	TableName  []byte
	RowId      []byte
	Cols       map[string]*Cell
	Outputs    []*Output
	Inputs     []*Input
}

func (*Transaction) Clone

func (tx *Transaction) Clone() *Transaction

type TransactionChangefeed

type TransactionChangefeed interface {
	Next(*TransactionChangefeedRes) bool
}

type TransactionChangefeedRes

type TransactionChangefeedRes struct {
	OldVal *Transaction
	NewVal *Transaction
}

type VerIdAlreadyExists

type VerIdAlreadyExists struct {
	VerId *big.Int
}

func (*VerIdAlreadyExists) Error

func (e *VerIdAlreadyExists) Error() string

type Vote

type Vote struct {
	Hash      []byte
	Voter     []byte
	Sig       []byte
	VotedAt   *big.Int
	PrevBlock []byte
	NextBlock []byte // Block we are voting on
	Value     bool
}

func (*Vote) Clone

func (v *Vote) Clone() *Vote

type VoteChangefeed

type VoteChangefeed interface {
	Next(*VoteChangefeedRes) bool
}

type VoteChangefeedRes

type VoteChangefeedRes struct {
	OldVal *Vote
	NewVal *Vote
}

Jump to

Keyboard shortcuts

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