Documentation
¶
Index ¶
- Variables
- type BlockManager
- type BlockStorer
- type Blocks
- func (b *Blocks) Close() error
- func (b *Blocks) Configure(ctx context.Context, coins []string) (err error)
- func (b *Blocks) Create(ctx context.Context, coin string, newEntity *capi.Block) (block *capi.Block, err error)
- func (b *Blocks) CreateBulk(ctx context.Context, coin string, newEntities []*capi.Block) (blocks []*capi.Block, err error)
- func (b *Blocks) CreateSchema(ctx context.Context, coins []string) (err error)
- func (b *Blocks) Delete(ctx context.Context, coin string, id string) (err error)
- func (b *Blocks) Get(ctx context.Context, coin string, id string) (block *capi.Block, err error)
- func (b *Blocks) GetByHash(ctx context.Context, coin string, hash string) (block *capi.Block, err error)
- func (b *Blocks) IsCreated(ctx context.Context, coins []string) bool
- func (b *Blocks) Last(ctx context.Context, coin string) (block *capi.Block, err error)
- func (b *Blocks) List(ctx context.Context, coin string, query ListBlocksRequest) (blocks []*capi.Block, err error)
- func (b *Blocks) Update(ctx context.Context, coin string, id string, updatedEntity *capi.Block) (block *capi.Block, err error)
- type Configurer
- type CreateTransactionRequest
- type Creater
- type Datastore
- type DeleteTransactionRequest
- type ListBlocksRequest
- type ListTransactionsRequest
- type Manager
- type Stater
- type TransactionManager
- type TransactionStorer
- type Transactions
- func (t *Transactions) Close() error
- func (b *Transactions) Configure(ctx context.Context, coins []string) (err error)
- func (b *Transactions) Create(ctx context.Context, coin string, query CreateTransactionRequest) (transaction *capi.Transaction, err error)
- func (b *Transactions) CreateBulk(ctx context.Context, coin string, query []CreateTransactionRequest) (transactions []*capi.Transaction, err error)
- func (b *Transactions) CreateSchema(ctx context.Context, coins []string) (err error)
- func (b *Transactions) Delete(ctx context.Context, coin string, query DeleteTransactionRequest) (err error)
- func (b *Transactions) IsCreated(ctx context.Context, coins []string) bool
- func (b *Transactions) List(ctx context.Context, coin string, query ListTransactionsRequest) (transactions []*capi.Transaction, err error)
- func (b *Transactions) Update(ctx context.Context, coin string, query UpdateTransactionRequest) (transaction *capi.Transaction, err error)
- type UpdateTransactionRequest
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is the error returned for when a resource could not be // found in the datastore. ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type BlockManager ¶
type BlockManager interface {
Creater
Configurer
Stater
BlockStorer
}
BlockManager pulls together all interfaces required to implement a database storage driver for storing coin blocks.
type BlockStorer ¶
type BlockStorer interface {
// Last returns the last known block stored of the provided coin.
Last(ctx context.Context, coin string) (*capi.Block, error)
// List enables filtering for blocks in the datastore.
List(ctx context.Context, coin string, query ListBlocksRequest) ([]*capi.Block, error)
// Create creating a block in the datastore.
Create(ctx context.Context, coin string, newEntity *capi.Block) (*capi.Block, error)
// CreateBulk enables bulk creation of blocks in the datastore.
CreateBulk(ctx context.Context, coin string, query []*capi.Block) ([]*capi.Block, error)
// Get enables retrieving a block given an ID.
Get(ctx context.Context, coin string, id string) (block *capi.Block, err error)
// GetByHash enables retrieving a block given a block Hash.
GetByHash(ctx context.Context, coin string, hash string) (block *capi.Block, err error)
// Update enables updating a block resource in the datastore.
Update(ctx context.Context, coin string, id string, updatedEntity *capi.Block) (*capi.Block, error)
// Delete removes a block from the datastore.
Delete(ctx context.Context, coin string, id string) (err error)
}
BlockManager enables datastore implementers to filter for, create, update and delete blockchain block resources for multiple coins.
type Blocks ¶
type Blocks struct {
// dbpath is the path to where the boltdb datafiles are stored.
DBPath string
// DB contains the boltdb handler to access the underlying buckets.
DB *bolt.DB
// Coins contains the list of coins supported by the underlying DB.
Coins []string
// Options are specific boltdb configurations.
Options *bolt.Options
// contains filtered or unexported fields
}
Blocks provides a boltdb backed datastore implementation for storing blocks.
func (*Blocks) Create ¶
func (b *Blocks) Create(ctx context.Context, coin string, newEntity *capi.Block) (block *capi.Block, err error)
Create creating a block in the datastore.
func (*Blocks) CreateBulk ¶
func (b *Blocks) CreateBulk(ctx context.Context, coin string, newEntities []*capi.Block) (blocks []*capi.Block, err error)
CreateBulk enables bulk creation of blocks in the datastore.
func (*Blocks) CreateSchema ¶
CreateSchema implements datastore.Creater
func (*Blocks) GetByHash ¶
func (b *Blocks) GetByHash(ctx context.Context, coin string, hash string) (block *capi.Block, err error)
GetByHash enables retrieving a block given a block hash.
type Configurer ¶
type Configurer interface {
// Configure provides a hook to configure the database.
// coins is provided as a parameter in case individual tables require being
// configured per coin.
Configure(ctx context.Context, coins []string) error
}
Configurer provides an interface for required configuration that may be required on startup. For example, ensuring indices are configured e.t.c.
type CreateTransactionRequest ¶
type CreateTransactionRequest struct {
Transaction *capi.Transaction
}
CreateTransactionRequest creates a Transaction.
type Creater ¶
type Creater interface {
// CreateSchema provides a hook for the underlying storage to perform
// operations in order to create the required store for a given resource.
// coins is provided as a parameter in case individual tables are required
// to be created per coin.
CreateSchema(ctx context.Context, coins []string) error
}
Creater provides an interface for any required setup that may be needed on first initialization for a given datastore.
type Datastore ¶
type Datastore struct {
Blocks BlockManager
Transactions TransactionManager
// contains filtered or unexported fields
}
Datastore provides the concrete implementation of a datastore.
func NewDatastore ¶
NewDatastore returns a configured datastore.
func (*Datastore) ConfigureSchemas ¶
ConfigureSchemas ensures that on start up, each resource is configured.
type DeleteTransactionRequest ¶
type DeleteTransactionRequest struct {
ID string
}
DeleteTransactionRequest deletes the specified transaction.
type ListBlocksRequest ¶
type ListBlocksRequest struct {
// WalletID enables filtering blocks based on the a Wallet.
WalletID string `json:"walletId"`
// TransactionID enables filtering blocks based on a Transaction.
TransactionID string `json:"TransactionId"`
}
ListBlocksRequest enables filtering blocks based on the following parameters.
type ListTransactionsRequest ¶
type ListTransactionsRequest struct {
// WalletID enables filtering transactions based on a Wallet.
WalletID string `json:"walletId"`
}
ListTransactionsRequest enables filtering transactions based on the following parameters.
type Manager ¶
type Manager interface {
Creater
Configurer
Stater
}
Manager brings together the interfaces required to manage a datastore.
type Stater ¶
type Stater interface {
// IsCreated returns a bool to trigger crea
IsCreated(ctx context.Context, coins []string) bool
// Close enables datastore connections to be closed.
Close() error
}
Stater provides simple state management for the datastore in order to provide state information based on coin.
type TransactionManager ¶
type TransactionManager interface {
Creater
Configurer
Stater
TransactionStorer
}
TransactionManager pulls together all interfaces required to implement a database storage driver for storing coin transactions.
type TransactionStorer ¶
type TransactionStorer interface {
// List enables filtering for transactions in the datastore.
List(ctx context.Context, coin string, query ListTransactionsRequest) (transactions []*capi.Transaction, err error)
// Create creating a transaction in the datastore.
Create(ctx context.Context, coin string, query CreateTransactionRequest) (transaction *capi.Transaction, err error)
// CreateBulk enables bulk creation of transactions in the datastore.
CreateBulk(ctx context.Context, coin string, query []CreateTransactionRequest) (transactions []*capi.Transaction, err error)
// Update enables updating a transaction resource in the datastore.
Update(ctx context.Context, coin string, query UpdateTransactionRequest) (transaction *capi.Transaction, err error)
// Delete removes a transaction from the datastore.
Delete(ctx context.Context, coin string, query DeleteTransactionRequest) (err error)
}
TransactionManager enables datastore implementers to filter for, create, update and delete blockchain transaction resources for multiple coins.
type Transactions ¶
type Transactions struct {
// dbpath is the path to where the boltdb datafiles are stored.
DBPath string
// DB contains the boltdb handler to access the underlying buckets.
DB *bolt.DB
// Coins contains the list of coins supported by the underlying DB.
Coins []string
// Options are specific boltdb configurations.
Options *bolt.Options
// contains filtered or unexported fields
}
Transactions provides a boltdb backed datastore implementation for storing blockchain transactions.
func (*Transactions) Configure ¶
func (b *Transactions) Configure(ctx context.Context, coins []string) (err error)
Configure implements Configurer.Configure
func (*Transactions) Create ¶
func (b *Transactions) Create(ctx context.Context, coin string, query CreateTransactionRequest) (transaction *capi.Transaction, err error)
Create creates a transaction in the datastore.
func (*Transactions) CreateBulk ¶
func (b *Transactions) CreateBulk(ctx context.Context, coin string, query []CreateTransactionRequest) (transactions []*capi.Transaction, err error)
CreateBulk enables bulk creation of transactions in the datastore.
func (*Transactions) CreateSchema ¶
func (b *Transactions) CreateSchema(ctx context.Context, coins []string) (err error)
CreateSchema implements datastore.Creater
func (*Transactions) Delete ¶
func (b *Transactions) Delete(ctx context.Context, coin string, query DeleteTransactionRequest) (err error)
Delete removes a transaction from the datastore.
func (*Transactions) IsCreated ¶
func (b *Transactions) IsCreated(ctx context.Context, coins []string) bool
IsCreated returns a bool to trigger crea
func (*Transactions) List ¶
func (b *Transactions) List(ctx context.Context, coin string, query ListTransactionsRequest) (transactions []*capi.Transaction, err error)
List enables filtering for transactions in the datastore.
func (*Transactions) Update ¶
func (b *Transactions) Update(ctx context.Context, coin string, query UpdateTransactionRequest) (transaction *capi.Transaction, err error)
Update enables updating a transaction resource in the datastore.
type UpdateTransactionRequest ¶
type UpdateTransactionRequest struct {
ID string
Transaction *capi.Transaction
}
UpdateTransactionRequest updates the transaction, with the newly provided resource.