bftdb

package
v0.0.0-...-6096f8e Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATE_URL = "http://localhost:3000"
	QUERY_URL = "http://localhost:3000/query"
	OTHER_URL = "http://localhost:3000/stmt"
)
View Source
const (
	SELECT = 0
	DROP   = 1
	OTHER  = 2
	BAD    = 3
)
View Source
const PORT = ":3000"

Routes /query -> takes a query and returns result /stmt -> does the same / -> returns the lastes state PORT http addr

Variables

This section is empty.

Functions

func HandleSQL

func HandleSQL(stmt string)

func HandleStatus

func HandleStatus()

func ValidateSql

func ValidateSql(val string) (int, error)

ValidateSql checks the incoming statements for correctness. 'drop' statements are not allowed

Types

type App

type App struct {
	abci.BaseApplication
	// contains filtered or unexported fields
}

func NewApp

func NewApp(dbo *DbWrapper) (*App, error)

func (*App) BeginBlock

func (app *App) BeginBlock(req abci.RequestBeginBlock) abci.ResponseBeginBlock

BeginBlock called on new block

func (*App) CheckTx

func (app *App) CheckTx(tx []byte) abci.ResponseCheckTx

CheckTx validate incoming txs

func (*App) Commit

func (app *App) Commit() abci.ResponseCommit

Commit create hash of all txs

func (*App) DeliverTx

func (app *App) DeliverTx(tx []byte) abci.ResponseDeliverTx

DeliverTx process txs

func (*App) EndBlock

func (app *App) EndBlock(req abci.RequestEndBlock) abci.ResponseEndBlock

EndBlock called at end...

func (*App) Info

func (app *App) Info(req abci.RequestInfo) abci.ResponseInfo

Info something

func (*App) InitChain

func (app *App) InitChain(req abci.RequestInitChain) abci.ResponseInitChain

InitChain called on startup

func (*App) Query

func (app *App) Query(reqQuery abci.RequestQuery) abci.ResponseQuery

Query temp

type DbWrapper

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

func NewDb

func NewDb() (*DbWrapper, error)

NewDb create new inmemory DB

func (*DbWrapper) Close

func (self *DbWrapper) Close()

func (*DbWrapper) Read

func (self *DbWrapper) Read(query string) (*QueryResult, error)

func (*DbWrapper) Write

func (self *DbWrapper) Write(stmt Statement) error

type QueryResult

type QueryResult struct {
	Columns []string        `json:"columns,omitempty"`
	Values  [][]interface{} `json:"values,omitempty"`
}

type QueryService

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

QueryService base struct for QueryServer

func NewQueryServer

func NewQueryServer(db *DbWrapper) *QueryService

NewQueryServer create an http server that responds to SELECT statements

func (*QueryService) LatestState

func (service *QueryService) LatestState(w http.ResponseWriter, r *http.Request)

func (*QueryService) QueryHandler

func (service *QueryService) QueryHandler(w http.ResponseWriter, r *http.Request)

func (*QueryService) Run

func (service *QueryService) Run() *http.Server

func (*QueryService) StatementHandler

func (service *QueryService) StatementHandler(w http.ResponseWriter, r *http.Request)

type Statement

type Statement []byte

func (Statement) Hash

func (st Statement) Hash() []byte

func (Statement) String

func (st Statement) String() string

type StatementRequest

type StatementRequest []string

Jump to

Keyboard shortcuts

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