server

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequestError  = errors.New("request error")
	ErrInternalError = errors.New("internal error")
)

Functions

func NewJobsQueue added in v0.1.4

func NewJobsQueue(scanner Scanner, db DbWorker, workerBlocks int, resultBlocks int, jobLifetime time.Duration) *jobsQueue

func WrapHandler

func WrapHandler(handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

Types

type BlockEntry

type BlockEntry struct {
	Height uint64
	Hash   moneroutil.Hash
	Header []byte
}

type BlocksBulkList added in v0.1.4

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

func NewBlocksBulkList added in v0.1.4

func NewBlocksBulkList() *BlocksBulkList

func (*BlocksBulkList) AddBlocks added in v0.1.4

func (l *BlocksBulkList) AddBlocks(start uint64, insertBlocks []*WalletBlock)

func (*BlocksBulkList) BlocksAvailable added in v0.1.4

func (l *BlocksBulkList) BlocksAvailable(start uint64) int

func (*BlocksBulkList) FindMissingBlocks added in v0.1.4

func (l *BlocksBulkList) FindMissingBlocks() (uint64, int)

Returns the first place (`start height`, `blocks count`) where to fetch blocks from If list is empty returns 0, 0 If there's no missing blocks returns `next height`, 0

func (*BlocksBulkList) GetBlocks added in v0.1.4

func (l *BlocksBulkList) GetBlocks(start uint64, maxCount int) []*WalletBlock

func (*BlocksBulkList) RemoveBlocks added in v0.1.4

func (l *BlocksBulkList) RemoveBlocks(start uint64, count int)

func (*BlocksBulkList) TrimBlocks added in v0.1.4

func (l *BlocksBulkList) TrimBlocks(topHeight uint64)

type BlocksHandler

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

func NewBlocksHandler

func NewBlocksHandler(db DbWorker, queue *jobsQueue) *BlocksHandler

func (*BlocksHandler) HandleGetBlocks

func (b *BlocksHandler) HandleGetBlocks(req *rpc.WalletChainInfoV1) (*rpc.WalletBlocksResult, error)

type BlocksScanner

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

func NewScanner

func NewScanner(db DbWorker) *BlocksScanner

func (*BlocksScanner) GetBlocks

func (b *BlocksScanner) GetBlocks(startHeight uint64, wallet utils.WalletEntry, maxBlocks int) ([]*WalletBlock, error)

type DbWorker

type DbWorker interface {
	GetBlocksAbove(startHeight uint64, maxCount int) ([]PreparsedBlock, error)
	GetBlockEntry(height uint64) (BlockEntry, error)
	GetChainIntersection(chain []moneroutil.Hash) (utils.HeightInfo, error)
	GetWalletBlocks(walletId uint32, startHeight uint64, maxBlocks int) ([]PreSerializedBlock, error)
	GetWalletOutputs(walletId uint32) ([]OutputHeight, error)
	SaveWalletBlocks(walletId uint32, blocks []moneroutil.Hash, outputs []OutputHeight) error
	SaveWalletProgress(walletId uint32, hash moneroutil.Hash) error
	GetTopScannedHeightInfo(walletId uint32) (utils.HeightInfo, error)
	GetOrCreateKeyProgress(account utils.AccountInfo) (utils.WalletEntry, error)
	GetTopBlockHeight() (uint64, error)
}

func NewDbWorker

func NewDbWorker(settings utils.DbSettings) (DbWorker, error)

type ExtSerializedTx

type ExtSerializedTx struct {
	Hash          moneroutil.Hash
	Blob          []byte
	OutputIndices []uint64
}

type OutputHeight

type OutputHeight struct {
	OutputIndex uint64
	Height      uint64
}

type PreSerializedBlock

type PreSerializedBlock struct {
	Height uint64
	Hash   moneroutil.Hash
	Header []byte
	Txs    []ExtSerializedTx
}

type PreparsedBlock

type PreparsedBlock struct {
	BlockEntry
	Txs []PreparsedTx
}

type PreparsedTx

type PreparsedTx struct {
	Hash          moneroutil.Hash
	Blob          []byte
	OutputKeys    []moneroutil.Key
	OutputIndices []uint64
	UsedInputs    []uint64
}

type Scanner

type Scanner interface {
	GetBlocks(startHeight uint64, wallet utils.WalletEntry, maxBlocks int) ([]*WalletBlock, error)
}

type Server

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

func NewServer

func NewServer(handler *BlocksHandler) *Server

func (*Server) HandleGetBlocks

func (s *Server) HandleGetBlocks(resp http.ResponseWriter, req *http.Request)

func (*Server) HandleVersions

func (s *Server) HandleVersions(resp http.ResponseWriter, req *http.Request)

func (*Server) StartAsync

func (s *Server) StartAsync(address string)

type WalletBlock

type WalletBlock struct {
	Hash          moneroutil.Hash
	Timestamp     uint64
	Bce           *moneroproto.BlockCompleteEntry
	OutputIndices [][]uint64
}

type WalletsDb

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

func (*WalletsDb) GetBlockEntry

func (w *WalletsDb) GetBlockEntry(height uint64) (BlockEntry, error)

func (*WalletsDb) GetBlocksAbove

func (w *WalletsDb) GetBlocksAbove(startHeight uint64, maxCount int) ([]PreparsedBlock, error)

func (*WalletsDb) GetChainIntersection

func (w *WalletsDb) GetChainIntersection(chain []moneroutil.Hash) (utils.HeightInfo, error)

func (*WalletsDb) GetOrCreateKeyProgress

func (w *WalletsDb) GetOrCreateKeyProgress(account utils.AccountInfo) (utils.WalletEntry, error)

func (*WalletsDb) GetTopBlockHeight

func (w *WalletsDb) GetTopBlockHeight() (uint64, error)

func (*WalletsDb) GetTopScannedHeightInfo added in v0.1.4

func (w *WalletsDb) GetTopScannedHeightInfo(walletId uint32) (utils.HeightInfo, error)

func (*WalletsDb) GetWalletBlocks

func (w *WalletsDb) GetWalletBlocks(walletId uint32, startHeight uint64, maxBlocks int) ([]PreSerializedBlock, error)

func (*WalletsDb) GetWalletOutputs

func (w *WalletsDb) GetWalletOutputs(walletId uint32) ([]OutputHeight, error)

func (*WalletsDb) SaveWalletBlocks

func (w *WalletsDb) SaveWalletBlocks(walletId uint32, blocks []moneroutil.Hash, outputs []OutputHeight) error

func (*WalletsDb) SaveWalletProgress

func (w *WalletsDb) SaveWalletProgress(walletId uint32, hash moneroutil.Hash) error

Jump to

Keyboard shortcuts

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