indexservice

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExist indicates certain item does not exist in Blockchain database
	ErrNotExist = errors.New("not exist in DB")
	// ErrAlreadyExist indicates certain item already exists in Blockchain database
	ErrAlreadyExist = errors.New("already exist in DB")
)

Functions

This section is empty.

Types

type ActionHistory

type ActionHistory struct {
	NodeAddress string
	UserAddress string
	ActionHash  string
}

ActionHistory defines the schema of "action history" table

type ActionToBlock

type ActionToBlock struct {
	NodeAddress string
	ActionHash  string
	BlockHash   string
}

ActionToBlock defines the schema of "action hash to block hash" table

type ExecutionHistory

type ExecutionHistory struct {
	NodeAddress   string
	UserAddress   string
	ExecutionHash string
}

ExecutionHistory defines the schema of "execution history" table

type ExecutionToBlock

type ExecutionToBlock struct {
	NodeAddress   string
	ExecutionHash string
	BlockHash     string
}

ExecutionToBlock defines the schema of "execution hash to block hash" table

type Indexer

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

Indexer handles the index build for blocks

func (*Indexer) BuildIndex

func (idx *Indexer) BuildIndex(blk *block.Block) error

BuildIndex builds the index for a block

func (*Indexer) CreateTablesIfNotExist

func (idx *Indexer) CreateTablesIfNotExist() error

CreateTablesIfNotExist creates tables in local database

func (*Indexer) GetActionHistory

func (idx *Indexer) GetActionHistory(userAddr string) ([]hash.Hash32B, error)

GetActionHistory gets action history

func (*Indexer) GetBlockByAction

func (idx *Indexer) GetBlockByAction(actionHash hash.Hash32B) (hash.Hash32B, error)

GetBlockByAction returns block hash by action hash

func (*Indexer) GetBlockByExecution

func (idx *Indexer) GetBlockByExecution(executionHash hash.Hash32B) (hash.Hash32B, error)

GetBlockByExecution returns block hash by execution hash

func (*Indexer) GetBlockByTransfer

func (idx *Indexer) GetBlockByTransfer(transferHash hash.Hash32B) (hash.Hash32B, error)

GetBlockByTransfer returns block hash by transfer hash

func (*Indexer) GetBlockByVote

func (idx *Indexer) GetBlockByVote(voteHash hash.Hash32B) (hash.Hash32B, error)

GetBlockByVote returns block hash by vote hash

func (*Indexer) GetExecutionHistory

func (idx *Indexer) GetExecutionHistory(userAddr string) ([]hash.Hash32B, error)

GetExecutionHistory gets execution history

func (*Indexer) GetTransferHistory

func (idx *Indexer) GetTransferHistory(userAddr string) ([]hash.Hash32B, error)

GetTransferHistory gets transfer history

func (*Indexer) GetVoteHistory

func (idx *Indexer) GetVoteHistory(userAddr string) ([]hash.Hash32B, error)

GetVoteHistory gets vote history

func (*Indexer) HandleBlock

func (idx *Indexer) HandleBlock(blk *block.Block) error

HandleBlock is an implementation of interface BlockCreationSubscriber

func (*Indexer) UpdateActionHistory

func (idx *Indexer) UpdateActionHistory(blk *block.Block, tx *sql.Tx) error

UpdateActionHistory stores action information into action history table

func (*Indexer) UpdateActionToBlock

func (idx *Indexer) UpdateActionToBlock(blk *block.Block, tx *sql.Tx) error

UpdateActionToBlock maps action hash to block hash

func (*Indexer) UpdateExecutionHistory

func (idx *Indexer) UpdateExecutionHistory(blk *block.Block, tx *sql.Tx) error

UpdateExecutionHistory stores execution information into execution history table

func (*Indexer) UpdateExecutionToBlock

func (idx *Indexer) UpdateExecutionToBlock(blk *block.Block, tx *sql.Tx) error

UpdateExecutionToBlock maps execution hash to block hash

func (*Indexer) UpdateTransferHistory

func (idx *Indexer) UpdateTransferHistory(blk *block.Block, tx *sql.Tx) error

UpdateTransferHistory stores transfer information into transfer history table

func (*Indexer) UpdateTransferToBlock

func (idx *Indexer) UpdateTransferToBlock(blk *block.Block, tx *sql.Tx) error

UpdateTransferToBlock maps transfer hash to block hash

func (*Indexer) UpdateVoteHistory

func (idx *Indexer) UpdateVoteHistory(blk *block.Block, tx *sql.Tx) error

UpdateVoteHistory stores vote information into vote history table

func (*Indexer) UpdateVoteToBlock

func (idx *Indexer) UpdateVoteToBlock(blk *block.Block, tx *sql.Tx) error

UpdateVoteToBlock maps vote hash to block hash

type Server

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

Server is the container of the index service

func NewServer

func NewServer(
	cfg config.Config,
	bc blockchain.Blockchain,
) *Server

NewServer instantiates an index service

func (*Server) Indexer

func (s *Server) Indexer() *Indexer

Indexer return indexer interface

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the explorer server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stops the explorer server

type TransferHistory

type TransferHistory struct {
	NodeAddress string
	UserAddress string
	TrasferHash string
}

TransferHistory defines the schema of "transfer history" table

type TransferToBlock

type TransferToBlock struct {
	NodeAddress string
	TrasferHash string
	BlockHash   string
}

TransferToBlock defines the schema of "transfer hash to block hash" table

type VoteHistory

type VoteHistory struct {
	NodeAddress string
	UserAddress string
	VoteHash    string
}

VoteHistory defines the schema of "vote history" table

type VoteToBlock

type VoteToBlock struct {
	NodeAddress string
	VoteHash    string
	BlockHash   string
}

VoteToBlock defines the schema of "vote hash to block hash" table

Jump to

Keyboard shortcuts

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