indexservice

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 BlockByIndex added in v0.5.0

type BlockByIndex struct {
	NodeAddress string
	IndexHash   []byte
	BlockHash   []byte
}

BlockByIndex defines the base schema of "index to block" table

type IndexHistory added in v0.5.0

type IndexHistory struct {
	NodeAddress string
	UserAddress string
	IndexHash   string
}

IndexHistory defines the schema of "index history" 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 added in v0.4.4

func (idx *Indexer) CreateTablesIfNotExist() error

CreateTablesIfNotExist creates tables in local database

func (*Indexer) GetBlockByIndex added in v0.5.0

func (idx *Indexer) GetBlockByIndex(indexIdentifier string, indexHash hash.Hash256) (hash.Hash256, error)

GetBlockByIndex returns block hash by index hash

func (*Indexer) GetIndexHistory added in v0.5.0

func (idx *Indexer) GetIndexHistory(indexIdentifier string, userAddr string) ([]hash.Hash256, error)

GetIndexHistory gets index history

func (*Indexer) HandleBlock added in v0.4.4

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

HandleBlock is an implementation of interface BlockCreationSubscriber

func (*Indexer) UpdateBlockByIndex added in v0.5.0

func (idx *Indexer) UpdateBlockByIndex(blk *block.Block, tx *sql.Tx, indexIdentifier string, indexHash hash.Hash256,
	blockHash hash.Hash256) error

UpdateBlockByIndex maps index hash to block hash

func (*Indexer) UpdateIndexHistory added in v0.5.0

func (idx *Indexer) UpdateIndexHistory(blk *block.Block, tx *sql.Tx, indexIdentifier string, userAddr string,
	indexHash hash.Hash256) error

UpdateIndexHistory stores index information into index history table

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

Jump to

Keyboard shortcuts

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