xenomint

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package xenomint provides an eventual consistency implementation of the blockchain database.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingParent indicates the parent of the current query attempt is missing.
	ErrMissingParent = errors.New("query missing parent")
	// ErrInvalidRequest indicates the query is invalid.
	ErrInvalidRequest = errors.New("invalid request")
	// ErrQueryConflict indicates the there is a conflict on query replay.
	ErrQueryConflict = errors.New("query conflict")
	// ErrMuxServiceNotFound indicates that the multiplexing service endpoint is not found.
	ErrMuxServiceNotFound = errors.New("mux service not found")
	// ErrStatefulQueryParts indicates query contains stateful query parts.
	ErrStatefulQueryParts = errors.New("query contains stateful query parts")
	// ErrInvalidTableName indicates query contains invalid table name in ddl statement.
	ErrInvalidTableName = errors.New("invalid table name in ddl")
)

Functions

This section is empty.

Types

type Chain

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

Chain defines the xenomint chain structure.

func NewChain

func NewChain(filename string) (c *Chain, err error)

NewChain returns new chain instance.

func (*Chain) Query

func (c *Chain) Query(req *types.Request) (resp *types.Response, err error)

Query queries req from local chain state and returns the query results in resp.

func (*Chain) Stop

func (c *Chain) Stop() (err error)

Stop stops chain workers and RPC service.

type MuxLeaderCommitRequest

type MuxLeaderCommitRequest struct {
	proto.DatabaseID
	proto.Envelope
	// Height is the expected block height of this commit.
	Height int32
}

MuxLeaderCommitRequest a request of the MuxLeaderCommitResponse RPC method.

type MuxLeaderCommitResponse

type MuxLeaderCommitResponse struct {
	proto.DatabaseID
	proto.Envelope
	// Height is the expected block height of this commit.
	Height int32
	Offset uint64
}

MuxLeaderCommitResponse a response of the MuxLeaderCommitResponse RPC method.

type MuxQueryRequest

type MuxQueryRequest struct {
	proto.DatabaseID
	proto.Envelope
	Request *types.Request
}

MuxQueryRequest defines a request of the Query RPC method.

type MuxQueryResponse

type MuxQueryResponse struct {
	proto.DatabaseID
	proto.Envelope
	Response *types.Response
}

MuxQueryResponse defines a response of the Query RPC method.

type MuxService

type MuxService struct {
	ServiceName string
	// contains filtered or unexported fields
}

MuxService defines multiplexing service of xenomint chain.

func NewMuxService

func NewMuxService(name string, server *rpc.Server) (service *MuxService, err error)

NewMuxService returns a new MuxService instance and registers it to server.

func (*MuxService) Query

func (s *MuxService) Query(req *MuxQueryRequest, resp *MuxQueryResponse) (err error)

Query is the RPC method to process database query on mux service.

type QueryTracker

type QueryTracker struct {
	sync.RWMutex
	Req  *types.Request
	Resp *types.Response
}

QueryTracker defines an object to track query as a request - response pair.

func (*QueryTracker) Ready

func (q *QueryTracker) Ready() bool

Ready reports whether the query is ready for block producing. It is assumed that all objects should be ready shortly.

func (*QueryTracker) UpdateResp

func (q *QueryTracker) UpdateResp(resp *types.Response)

UpdateResp updates response of the QueryTracker within locking scope.

type State

type State struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

State defines a xenomint state which is bound to a underlying storage.

func NewState

func NewState(level sql.IsolationLevel, nodeID proto.NodeID, strg xi.Storage) (s *State)

NewState returns a new State bound to strg.

func (*State) Close

func (s *State) Close(commit bool) (err error)

Close commits any ongoing transaction if needed and closes the underlying storage.

func (*State) CommitEx

func (s *State) CommitEx() (failed []*types.Request, queries []*QueryTracker, err error)

CommitEx commits the current transaction and returns all the pooled queries.

func (*State) CommitExWithContext

func (s *State) CommitExWithContext(
	ctx context.Context) (failed []*types.Request, queries []*QueryTracker, err error,
)

CommitExWithContext commits the current transaction and returns all the pooled queries with context.

func (*State) Query

func (s *State) Query(req *types.Request, isLeader bool) (ref *QueryTracker, resp *types.Response, err error)

Query does the query(ies) in req, pools the request and persists any change to the underlying storage.

func (*State) QueryWithContext

func (s *State) QueryWithContext(
	ctx context.Context, req *types.Request, isLeader bool) (ref *QueryTracker, resp *types.Response, err error,
)

QueryWithContext does the query(ies) in req, pools the request and persists any change to the underlying storage.

func (*State) Replay

func (s *State) Replay(req *types.Request, resp *types.Response) (err error)

Replay replays a write log from other peer to replicate storage state.

func (*State) ReplayBlock

func (s *State) ReplayBlock(block *types.Block) (err error)

ReplayBlock replays the queries from block. It also checks and skips some preceding pooled queries.

func (*State) ReplayBlockWithContext

func (s *State) ReplayBlockWithContext(ctx context.Context, block *types.Block) (err error)

ReplayBlockWithContext replays the queries from block with context. It also checks and skips some preceding pooled queries.

func (*State) ReplayWithContext

func (s *State) ReplayWithContext(
	ctx context.Context, req *types.Request, resp *types.Response) (err error,
)

ReplayWithContext replays a write log from other peer to replicate storage state with context.

func (*State) SetSeq

func (s *State) SetSeq(id uint64)

SetSeq sets the initial id of the current transaction.

func (*State) Stat

func (s *State) Stat(id proto.DatabaseID)

Stat prints the statistic message of the State object.

Directories

Path Synopsis
Package interfaces defines common used interfaces of the xenomint package.
Package interfaces defines common used interfaces of the xenomint package.
Package sqlite introduces a sqlite3 implementation of the xenomint/interfaces.Storage interface.
Package sqlite introduces a sqlite3 implementation of the xenomint/interfaces.Storage interface.

Jump to

Keyboard shortcuts

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