bigt

package
v0.1.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EOSNameColumnItem

func EOSNameColumnItem(row bigtable.Row, familyColumn string) (eos.Name, error)

func New

func New(dsnString string, opts ...eosdb.Option) (eosdb.Driver, error)

Types

type AccountCreator

type AccountCreator struct {
	Created   string    `json:"created"`
	Creator   string    `json:"creator"`
	BlockID   string    `json:"block_id"`
	BlockNum  uint32    `json:"block_num"`
	BlockTime time.Time `json:"block_time"`
	TrxID     string    `json:"trx_id"`
}

type AccountResponse

type AccountResponse struct {
	Name        eos.Name
	CreatorName eos.Name
	Creator     *AccountCreator
}

type AccountsTable

type AccountsTable struct {
	*basebigt.BaseTable

	ColMetaExists      string
	ColCreatorName     string
	ColCreatorJSON     string
	ColPermissionLinks string
	FamilyVerification string
}

func NewAccountsTable

func NewAccountsTable(name string, client *bigtable.Client) *AccountsTable

func (*AccountsTable) ParallelStreamRows

func (tbl *AccountsTable) ParallelStreamRows(
	ctx context.Context,
	rowRanges []bigtable.RowSet,
	concurrentReadCount uint32,
	processor func(row *AccountResponse) bool,
	opts ...bigtable.ReadOption,
) error

func (*AccountsTable) PutCreator

func (tbl *AccountsTable) PutCreator(key string, name string, data json.RawMessage)

func (*AccountsTable) PutMetaExists

func (tbl *AccountsTable) PutMetaExists(key string)
func (tbl *AccountsTable) PutPermissionLinks(key string, data json.RawMessage)

func (*AccountsTable) PutVerification

func (tbl *AccountsTable) PutVerification(key string, property string, data json.RawMessage)

func (*AccountsTable) StreamRows

func (tbl *AccountsTable) StreamRows(
	ctx context.Context,
	rowRange bigtable.RowSet,
	processor func(row *AccountResponse) bool,
	opts ...bigtable.ReadOption,
) error

type BlocksTable

type BlocksTable struct {
	*basebigt.BaseTable

	ColBlock                string
	ColMetaWritten          string
	ColMetaIrreversible     string
	ColTransactionRefs      string
	ColTransactionTraceRefs string
}

func NewBlocksTable

func NewBlocksTable(name string, client *bigtable.Client) *BlocksTable

func (*BlocksTable) ParseRowAs

func (tbl *BlocksTable) ParseRowAs(row bigtable.Row) (*pbcodec.BlockWithRefs, error)

func (*BlocksTable) PutBlock

func (tbl *BlocksTable) PutBlock(key string, block *pbcodec.Block)

PutBlock will strip the Header, Transactions and TransactionTraces from the block so you should put them separately.

**Warning** This method is not concurrent safe! While in the method, we assume full

control of the passed `block` instance. You are responsible for ensuring
this preconditions holds.

func (*BlocksTable) PutMetaIrreversible

func (tbl *BlocksTable) PutMetaIrreversible(key string, irreversible bool)

func (*BlocksTable) PutMetaWritten

func (tbl *BlocksTable) PutMetaWritten(key string)

func (*BlocksTable) PutTransactionRefs

func (tbl *BlocksTable) PutTransactionRefs(key string, refs *pbcodec.TransactionRefs)

func (*BlocksTable) PutTransactionTraceRefs

func (tbl *BlocksTable) PutTransactionTraceRefs(key string, refs *pbcodec.TransactionRefs)

func (*BlocksTable) ReadIrrCell

func (tbl *BlocksTable) ReadIrrCell(ctx context.Context, rowRange bigtable.RowSet, opts ...bigtable.ReadOption) (out []*pbcodec.BlockWithRefs, err error)

func (*BlocksTable) ReadRows

func (tbl *BlocksTable) ReadRows(ctx context.Context, rowRange bigtable.RowSet, opts ...bigtable.ReadOption) (out []*pbcodec.BlockWithRefs, err error)

type EOSDatabase

type EOSDatabase struct {
	*basebigt.Bigtable

	Accounts     *AccountsTable
	Transactions *TransactionsTable
	Blocks       *BlocksTable
	BlocksLast   *BlocksTable // Flushed last, w/ "written" marker for write completion.
	Timeline     *TimelineTable
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(tablePrefix, project, instance string, createTables bool, maxDurationBeforeFlush time.Duration, maxBlocksBeforeFlush uint64, opts ...option.ClientOption) (*EOSDatabase, error)

func NewWithClient

func NewWithClient(tablePrefix string, client *bigtable.Client) *EOSDatabase

func (*EOSDatabase) BlockIDAfter

func (b *EOSDatabase) BlockIDAfter(ctx context.Context, blockTime time.Time, inclusive bool) (id string, foundTime time.Time, err error)

func (*EOSDatabase) BlockIDAt

func (b *EOSDatabase) BlockIDAt(ctx context.Context, blockTime time.Time) (id string, err error)

func (*EOSDatabase) BlockIDBefore

func (b *EOSDatabase) BlockIDBefore(ctx context.Context, blockTime time.Time, inclusive bool) (id string, foundTime time.Time, err error)

func (*EOSDatabase) GetAccount

func (b *EOSDatabase) GetAccount(ctx context.Context, accountName string) (*pbcodec.AccountCreationRef, error)

func (*EOSDatabase) GetBlock

func (b *EOSDatabase) GetBlock(ctx context.Context, blockID string) (*pbcodec.BlockWithRefs, error)

func (*EOSDatabase) GetBlockByNum

func (b *EOSDatabase) GetBlockByNum(ctx context.Context, blockNum uint32) ([]*pbcodec.BlockWithRefs, error)

func (*EOSDatabase) GetClosestIrreversibleIDAtBlockNum

func (b *EOSDatabase) GetClosestIrreversibleIDAtBlockNum(ctx context.Context, blockNum uint32) (bstream.BlockRef, error)

GetClosestIrreversibleIDAtBlockNum retrieves the CLOSEST irreversible block from that block num, INCLUSIVELY.

WARN: a previous version of this function was EXCLUSIVE (GetIrreversibleIDAtBlockNum), make sure the caller does `blockNum-1` if it wants to keep that behavior.

func (*EOSDatabase) GetIrreversibleIDAtBlockID

func (b *EOSDatabase) GetIrreversibleIDAtBlockID(ctx context.Context, ID string) (bstream.BlockRef, error)

FIXME: Put that in CONSUMING code. It uses only public APIs from this. Belongs elsewhere.

func (*EOSDatabase) GetLastWrittenBlockID

func (b *EOSDatabase) GetLastWrittenBlockID(ctx context.Context) (out string, err error)

func (*EOSDatabase) GetLastWrittenIrreversibleBlockRef

func (db *EOSDatabase) GetLastWrittenIrreversibleBlockRef(ctx context.Context) (ref bstream.BlockRef, err error)

func (*EOSDatabase) GetTransactionEvents

func (b *EOSDatabase) GetTransactionEvents(ctx context.Context, idPrefix string) ([]*pbcodec.TransactionEvent, error)

func (*EOSDatabase) GetTransactionEventsBatch

func (b *EOSDatabase) GetTransactionEventsBatch(ctx context.Context, idPrefixes []string) ([][]*pbcodec.TransactionEvent, error)

GetTransactionEventsBatch retrieves all events for each transaction listed in `idPrefixes`. It is the caller's responsibility to decide whether it wants Irreversible only, by using `pbcodec.MergeTransactionEvents()` for example.

func (*EOSDatabase) GetTransactionRow

func (b *EOSDatabase) GetTransactionRow(ctx context.Context, idPrefix string) (*TransactionRow, error)

FIXME: delete this, no one calls it anymore. The TransactionEvent took prcedence over that.

func (*EOSDatabase) GetTransactionTraces

func (b *EOSDatabase) GetTransactionTraces(ctx context.Context, idPrefix string) (out []*pbcodec.TransactionEvent, err error)

func (*EOSDatabase) GetTransactionTracesBatch

func (b *EOSDatabase) GetTransactionTracesBatch(ctx context.Context, idPrefixes []string) (out [][]*pbcodec.TransactionEvent, err error)

func (*EOSDatabase) GetTransactions

func (b *EOSDatabase) GetTransactions(ctx context.Context, ids []string, chainDiscriminator eosdb.ChainDiscriminator) (out []*pbcodec.TransactionLifecycle, err error)

FIXME: delete this, it's used by `eosws`, but see how it can NOT use it anymore. This should be replaced by `GetTransactionEventsBatch` and Merged like the other ones. Hopefully there's no difference (check in `eosws`).

func (*EOSDatabase) ListAccountNames

func (b *EOSDatabase) ListAccountNames(ctx context.Context, concurrentReadCount uint32) ([]string, error)

func (*EOSDatabase) ListBlocks

func (b *EOSDatabase) ListBlocks(ctx context.Context, startBlockNum uint32, limit int) ([]*pbcodec.BlockWithRefs, error)

func (*EOSDatabase) ListBlocksRange

func (b *EOSDatabase) ListBlocksRange(ctx context.Context, blockNumStart uint32, blockNumEnd uint32) ([]*pbcodec.BlockWithRefs, error)

func (*EOSDatabase) ListSiblingBlocks

func (b *EOSDatabase) ListSiblingBlocks(ctx context.Context, blockNum uint32, spread uint32) ([]*pbcodec.BlockWithRefs, error)

func (*EOSDatabase) ListTransactionsForBlockID

func (b *EOSDatabase) ListTransactionsForBlockID(
	ctx context.Context,
	blockID string,
	startKey string,
	limit int,
) (out *mdl.TransactionList, err error)

FIXME: this belongs to the caller, not to the KVDB interface. This is client code, using `GetBlock` and `GetTransactionTraces`, outside the app context. The `mdl.TransactionList` belongs to `eosws` and not here.

func (*EOSDatabase) PutBlock

func (db *EOSDatabase) PutBlock(ctx context.Context, blk *pbcodec.Block) error

TODO we should lowercase all methods under db.Blocks or itself to prevent people from not getting the autoflush TODO get context right here

func (*EOSDatabase) SetWriterChainID

func (b *EOSDatabase) SetWriterChainID(chainID []byte)

func (*EOSDatabase) StartSpan

func (b *EOSDatabase) StartSpan(ctx context.Context, name string, attributes ...trace.Attribute) (context.Context, *trace.Span)

func (*EOSDatabase) UpdateNowIrreversibleBlock

func (db *EOSDatabase) UpdateNowIrreversibleBlock(ctx context.Context, blk *pbcodec.Block) error

type Keyer

type Keyer struct{}
var Keys Keyer

func (Keyer) Account

func (Keyer) Account(account uint64) string
func (Keyer) AccountLink(creator, created uint64) string

func (Keyer) Block

func (Keyer) Block(blockID string) string

func (Keyer) ReadAccount

func (Keyer) ReadAccount(key string) (account uint64, err error)
func (Keyer) ReadAccountLink(key string) (creator, created uint64, err error)

func (Keyer) ReadBlock

func (Keyer) ReadBlock(key string) (blockID string)

func (Keyer) ReadTimelineBlock

func (Keyer) ReadTimelineBlock(key string, reversed bool) (blockTime time.Time, blockID string, err error)

func (Keyer) ReadTimelineBlockForward

func (Keyer) ReadTimelineBlockForward(key string) (blockTime time.Time, blockID string, err error)

func (Keyer) ReadTimelineBlockReverse

func (Keyer) ReadTimelineBlockReverse(key string) (blockTime time.Time, blockID string, err error)

func (Keyer) ReadTransaction

func (Keyer) ReadTransaction(key string) (transactionID, blockID string, err error)

func (Keyer) TimelineBlockForward

func (Keyer) TimelineBlockForward(blockTime time.Time, blockID string) string

timeline

func (Keyer) TimelineBlockReverse

func (Keyer) TimelineBlockReverse(blockTime time.Time, blockID string) string

func (Keyer) Transaction

func (Keyer) Transaction(transactionID, blockID string) string

func (Keyer) TransactionPrefix

func (Keyer) TransactionPrefix(transactionID string) string

type TimelineTable

type TimelineTable struct {
	*basebigt.BaseTable

	ColMetaExists string
}

func NewTimelineTable

func NewTimelineTable(name string, client *bigtable.Client) *TimelineTable

func (*TimelineTable) PutMetaExists

func (tbl *TimelineTable) PutMetaExists(key string)

func (*TimelineTable) ReadRows

func (tbl *TimelineTable) ReadRows(ctx context.Context, rowRange bigtable.RowSet, opts ...bigtable.ReadOption) (out []string, err error)

type TransactionRow

type TransactionRow struct {
	// TODO: Replace Key usage by `ID` and `BlockID`.. Key is an intricacy
	// of Bigtables, shouldn't bubble outside this model.
	// It contains: `trx_id:block_id` as per `Keyer.ReadTransaction`
	Key string

	Transaction      *pbcodec.SignedTransaction
	TransactionTrace *pbcodec.TransactionTrace // really: ExecutionTrace
	BlockHeader      *pbcodec.BlockHeader
	PublicKeys       []string
	CreatedBy        *pbcodec.ExtDTrxOp
	CanceledBy       *pbcodec.ExtDTrxOp
	Irreversible     bool

	// TODO: phase this out, who relies on this anyway?
	Written bool
}

type TransactionsTable

type TransactionsTable struct {
	*basebigt.BaseTable

	ColTrx              string
	ColTrace            string
	ColDTrxCreatedBy    string
	ColDTrxCanceledBy   string
	ColMetaBlockHeader  string
	ColMetaIrreversible string
	ColMetaPubkeys      string
	ColMetaWritten      string
}

func NewTransactionsTable

func NewTransactionsTable(name string, client *bigtable.Client) *TransactionsTable

func (*TransactionsTable) ParseRowAs

func (tbl *TransactionsTable) ParseRowAs(row bigtable.Row) (*TransactionRow, error)

func (*TransactionsTable) PutBlockHeader

func (tbl *TransactionsTable) PutBlockHeader(key string, header *pbcodec.BlockHeader)

func (*TransactionsTable) PutDTrxCanceledBy

func (tbl *TransactionsTable) PutDTrxCanceledBy(key string, extDTrxOp *pbcodec.ExtDTrxOp)

func (*TransactionsTable) PutDTrxCreatedBy

func (tbl *TransactionsTable) PutDTrxCreatedBy(key string, extDTrxOp *pbcodec.ExtDTrxOp)

func (*TransactionsTable) PutMetaIrreversible

func (tbl *TransactionsTable) PutMetaIrreversible(key string, irreversible bool)

func (*TransactionsTable) PutMetaWritten

func (tbl *TransactionsTable) PutMetaWritten(key string, written bool)

func (*TransactionsTable) PutPublicKeys

func (tbl *TransactionsTable) PutPublicKeys(key string, publicKeys []string)

func (*TransactionsTable) PutTrace

func (tbl *TransactionsTable) PutTrace(key string, trace *pbcodec.TransactionTrace)

func (*TransactionsTable) PutTrx

func (tbl *TransactionsTable) PutTrx(key string, trx *pbcodec.SignedTransaction)

func (*TransactionsTable) ReadEvents

func (tbl *TransactionsTable) ReadEvents(ctx context.Context, rowRange bigtable.RowSet, opts ...bigtable.ReadOption) (out []*pbcodec.TransactionEvent, err error)

func (*TransactionsTable) ReadRows

func (tbl *TransactionsTable) ReadRows(ctx context.Context, rowRange bigtable.RowSet, opts ...bigtable.ReadOption) (out []*TransactionRow, err error)

Jump to

Keyboard shortcuts

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