Documentation ¶
Index ¶
- func ComputeBlockID(block *protocol.Block) []byte
- func GetEmptyBlockID() []byte
- type BadgerBackend
- type BlockHeightMismatch
- type BlockNotPresent
- type BlockStoreBackend
- type BlockTree
- type DeserializeError
- type InternalError
- type KoinosBadgerLogger
- type MapBackend
- type MockBlock
- type MockBlockTree
- type NotImplemented
- type RequestHandler
- func (handler *RequestHandler) AddBlock(req *block_store.AddBlockRequest) (*block_store.AddBlockResponse, error)
- func (handler *RequestHandler) GetBlocksByHeight(req *block_store.GetBlocksByHeightRequest) (*block_store.GetBlocksByHeightResponse, error)
- func (handler *RequestHandler) GetBlocksByID(req *block_store.GetBlocksByIdRequest) (*block_store.GetBlocksByIdResponse, error)
- func (handler *RequestHandler) GetHighestBlock(req *block_store.GetHighestBlockRequest) (*block_store.GetHighestBlockResponse, error)
- func (handler *RequestHandler) HandleRequest(req *block_store.BlockStoreRequest) *block_store.BlockStoreResponse
- func (handler *RequestHandler) UpdateHighestBlock(topology *koinos.BlockTopology) error
- type ReservedReqError
- type TraverseBeforeGenesisError
- type UnexpectedHeightError
- type UnknownReqError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeBlockID ¶
ComputeBlockID computes the block ID according to cryptographic constraints
func GetEmptyBlockID ¶
func GetEmptyBlockID() []byte
GetEmptyBlockID computes the zero block ID (i.e. Previous of first block applied to genesis state)
Types ¶
type BadgerBackend ¶
type BadgerBackend struct {
DB *badger.DB
}
BadgerBackend Badger backend implementation
func NewBadgerBackend ¶
func NewBadgerBackend(opts badger.Options) (*BadgerBackend, error)
NewBadgerBackend BadgerBackend constructor
func (*BadgerBackend) Delete ¶ added in v1.0.0
func (backend *BadgerBackend) Delete(key []byte) error
Delete an item from the database
func (*BadgerBackend) Get ¶
func (backend *BadgerBackend) Get(key []byte) ([]byte, error)
Get backend getter
func (*BadgerBackend) Put ¶
func (backend *BadgerBackend) Put(key, value []byte) error
Put backend setter
type BlockHeightMismatch ¶
type BlockHeightMismatch struct { }
BlockHeightMismatch is an error type thrown when querying ancestor of block B at height H where H >= B.height.
func (*BlockHeightMismatch) Error ¶
func (e *BlockHeightMismatch) Error() string
type BlockNotPresent ¶
type BlockNotPresent struct {
// contains filtered or unexported fields
}
BlockNotPresent is an error type thrown when asking for a block that is not contained in the blockstore
func (*BlockNotPresent) Error ¶
func (e *BlockNotPresent) Error() string
type BlockStoreBackend ¶
type BlockStoreBackend interface { /** * Store the given value in the given key. */ Put(key []byte, value []byte) error /** * Deletes the value at the given key. */ Delete(key []byte) error /** * Get a previously stored value. * * If the key is not found, returns (nil, nil). */ Get(key []byte) ([]byte, error) // Resets the entire database Reset() error }
BlockStoreBackend interface defines an abstract key-value store
type BlockTree ¶
type BlockTree struct { // Block indexed by number ByNum map[uint64]*protocol.Block // Receipt indexed by number ReceiptByNum map[uint64][]byte // MockBlock by number Numbers []uint64 }
BlockTree tracks blocks by number.
func ToBlockTree ¶
func ToBlockTree(mbt *MockBlockTree) *BlockTree
ToBlockTree converts a MockBlockTree to a BlockTree
type DeserializeError ¶
type DeserializeError struct { }
DeserializeError is an error type for errors during deserialization
func (*DeserializeError) Error ¶
func (e *DeserializeError) Error() string
type InternalError ¶
type InternalError struct { }
InternalError is an error type that is thrown when an internal constraint is violated
func (*InternalError) Error ¶
func (e *InternalError) Error() string
type KoinosBadgerLogger ¶
type KoinosBadgerLogger struct { }
KoinosBadgerLogger implements the badger.Logger interface in roder to pass badger logs the the koinos logger
func (KoinosBadgerLogger) Debugf ¶
func (kbl KoinosBadgerLogger) Debugf(msg string, args ...interface{})
Debugf implements formatted debug message handling for badger
func (KoinosBadgerLogger) Errorf ¶
func (kbl KoinosBadgerLogger) Errorf(msg string, args ...interface{})
Errorf implements formatted error message handling for badger
func (KoinosBadgerLogger) Infof ¶
func (kbl KoinosBadgerLogger) Infof(msg string, args ...interface{})
Infof implements formatted info message handling for badger
func (KoinosBadgerLogger) Warningf ¶
func (kbl KoinosBadgerLogger) Warningf(msg string, args ...interface{})
Warningf implements formatted warning message handling for badger
type MapBackend ¶
type MapBackend struct {
// contains filtered or unexported fields
}
MapBackend implements a key-value store backed by a simple map
func NewMapBackend ¶
func NewMapBackend() *MapBackend
NewMapBackend creates and returns a reference to a map backend instance
func (*MapBackend) Delete ¶ added in v1.0.0
func (backend *MapBackend) Delete(key []byte) error
Delete an item from the database
func (*MapBackend) Get ¶
func (backend *MapBackend) Get(key []byte) ([]byte, error)
Get fetches the requested value from the database
type MockBlock ¶
type MockBlock struct { Num uint64 Previous uint64 ActiveData []byte PassiveData []byte SignatureData []byte Transactions []*protocol.Transaction Receipt []byte }
MockBlock is similar to a Block.
MockBlock is referred to by a number. For example, we might represent a forked blockchain like this:
101 -> 102 -> 103 -> 104
\ ---> 203 -> 204
The numbers 101, 102, 103, 104, 203, 204, etc. are used to explain how the blocks relate to each other topologically.
For example, if we're constructing block 203 in some variable mb, we would say mb.Previous = 102. These MockBlocks would be contained in a MockBlockTree, and the number-based Previous is translated to an actual block ID that obeys proper cryptographic constraints by ToBlockTree().
type MockBlockTree ¶
MockBlockTree tracks mock blocks by number.
func NewMockBlockTree ¶
func NewMockBlockTree(tree [][]uint64) *MockBlockTree
NewMockBlockTree creates a MockBlockTree from a tree specification
type NotImplemented ¶
type NotImplemented struct { }
NotImplemented is an error type for unimplemented types
func (*NotImplemented) Error ¶
func (e *NotImplemented) Error() string
type RequestHandler ¶
type RequestHandler struct { Backend BlockStoreBackend // contains filtered or unexported fields }
RequestHandler contains a backend object and handles requests
func (*RequestHandler) AddBlock ¶
func (handler *RequestHandler) AddBlock(req *block_store.AddBlockRequest) (*block_store.AddBlockResponse, error)
AddBlock adds a block to the block store
func (*RequestHandler) GetBlocksByHeight ¶
func (handler *RequestHandler) GetBlocksByHeight(req *block_store.GetBlocksByHeightRequest) (*block_store.GetBlocksByHeightResponse, error)
GetBlocksByHeight retuns blocks by block height
func (*RequestHandler) GetBlocksByID ¶
func (handler *RequestHandler) GetBlocksByID(req *block_store.GetBlocksByIdRequest) (*block_store.GetBlocksByIdResponse, error)
GetBlocksByID returns blocks by block ID
func (*RequestHandler) GetHighestBlock ¶
func (handler *RequestHandler) GetHighestBlock(req *block_store.GetHighestBlockRequest) (*block_store.GetHighestBlockResponse, error)
GetHighestBlock returns the highest block seen by the block store
func (*RequestHandler) HandleRequest ¶
func (handler *RequestHandler) HandleRequest(req *block_store.BlockStoreRequest) *block_store.BlockStoreResponse
HandleRequest handles and routes blockstore requests
func (*RequestHandler) UpdateHighestBlock ¶
func (handler *RequestHandler) UpdateHighestBlock(topology *koinos.BlockTopology) error
UpdateHighestBlock Updates the database metadata with the highest blocks ID
type ReservedReqError ¶
type ReservedReqError struct { }
ReservedReqError is an error type that is thrown when a reserved request is passed to the request handler
func (*ReservedReqError) Error ¶
func (e *ReservedReqError) Error() string
type TraverseBeforeGenesisError ¶
type TraverseBeforeGenesisError struct { }
TraverseBeforeGenesisError is an error type when the blockchain attempts to traverse before genesis
func (*TraverseBeforeGenesisError) Error ¶
func (e *TraverseBeforeGenesisError) Error() string
type UnexpectedHeightError ¶
type UnexpectedHeightError struct { }
UnexpectedHeightError is an error type for bad block heights
func (*UnexpectedHeightError) Error ¶
func (e *UnexpectedHeightError) Error() string
type UnknownReqError ¶
type UnknownReqError struct { }
UnknownReqError is an error that is thrown when an unknown request is given to the request handler
func (*UnknownReqError) Error ¶
func (e *UnknownReqError) Error() string