impl

package
v0.0.0-...-7b2e207 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const LedgerTableName = "ledgers"

LedgerTableName represents the name of the table where all known ledger info are stored.

View Source
const TransactionTableName = "transactions"

TransactionTableName represents the name of the table where all transactions are stored.

Variables

View Source
var ErrChainExist = errors.New("chain already exists")

ErrChainExist represents an error about an existing chain

Functions

func Clear

func Clear(dbAddr string) error

Clear the database tables. Will only work in a test environment (Test Only!!!)

func Destroy

func Destroy(dbAddr string) error

Destroy removes the database tables. Will only work in a test environment (Test Only!!!)

Types

type PostgresStore

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

PostgresStore defines a store implementation on the postgres database. It implements the Store interface

func (*PostgresStore) Close

func (s *PostgresStore) Close() error

Close releases any resource held

func (*PostgresStore) Connect

func (s *PostgresStore) Connect(dbAddr string) (interface{}, error)

Connect connects to a postgres server and returns a client or error if connection failed.

func (*PostgresStore) CreateLedger

func (s *PostgresStore) CreateLedger(cocoonID, name string, chained, public bool) (*types.Ledger, error)

CreateLedger creates a new ledger.

func (*PostgresStore) CreateLedgerThen

func (s *PostgresStore) CreateLedgerThen(cocoonID, name string, chained, public bool, thenFunc func() error) (*types.Ledger, error)

CreateLedgerThen creates a new ledger and accepts an additional operation (via the thenFunc) to be executed before the ledger creation transaction is committed. If the thenFunc returns an error, the transaction is rolled back and error returned

func (*PostgresStore) Get

func (s *PostgresStore) Get(ledger, key string) (*types.Transaction, error)

Get fetches a transaction by its ledger and key

func (*PostgresStore) GetImplementationName

func (s *PostgresStore) GetImplementationName() string

GetImplementationName returns the name of this store implementation

func (*PostgresStore) GetLedger

func (s *PostgresStore) GetLedger(name string) (*types.Ledger, error)

GetLedger fetches a ledger meta information

func (*PostgresStore) GetRange

func (s *PostgresStore) GetRange(ledger, startKey, endKey string, inclusive bool, limit, offset int) ([]*types.Transaction, error)

GetRange fetches transactions with keys included in a specified range. No lock is acquired in this operation.

func (*PostgresStore) Init

func (s *PostgresStore) Init(systemPublicLedgerName, systemPrivateLedgerName string) error

Init initializes the types. Creates the necessary tables such as the the tables and public and private system ledgers

func (*PostgresStore) Put

func (s *PostgresStore) Put(ledgerName string, txs []*types.Transaction) ([]*types.TxReceipt, error)

Put creates one or more transactions associated to a ledger. Returns a list of transaction receipts and a general error.

func (*PostgresStore) PutThen

func (s *PostgresStore) PutThen(ledgerName string, txs []*types.Transaction, thenFunc func(validTxss []*types.Transaction) error) ([]*types.TxReceipt, error)

PutThen adds transactions to the store and returns a list of transaction receipts. Any transaction that failed to be created will result in an error receipt being created and returned along with success receipts of they successfully added transactions. However, all transactions will be rolled back if the `thenFunc` returns error. Only the transaction that are successfully added will be passed to the thenFunc. Future work may allow the caller to determine the behaviour via an additional parameter.

func (*PostgresStore) SetBlockchainImplementation

func (s *PostgresStore) SetBlockchainImplementation(b types.Blockchain)

SetBlockchainImplementation sets sets a reference of the blockchain implementation

Jump to

Keyboard shortcuts

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