parser

package
v0.0.0-...-b8f9f05 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFirstBlockHostIsEmpty = errors.New("FirstBlockHost is empty")

ErrFirstBlockHostIsEmpty host for first block is not specified

Functions

func BlockRollback

func BlockRollback(data []byte) error

BlockRollback is blocking rollback

func CheckLogTx

func CheckLogTx(txBinary []byte, transactions, txQueue bool) error

CheckLogTx checks if this transaction exists And it would have successfully passed a frontal test

func CheckTransaction

func CheckTransaction(data []byte) (*tx.Header, error)

CheckTransaction is checking transaction

func ClearTmp

func ClearTmp(blocks map[int64]string)

ClearTmp deletes temporary files

func GetBlockDataFromBlockChain

func GetBlockDataFromBlockChain(blockID int64) (*utils.BlockData, error)

GetBlockDataFromBlockChain is retrieving block data from blockchain

func GetBlocks

func GetBlocks(blockID int64, host string) error

GetBlocks is returning blocks

func GetKeyIDFromPrivateKey

func GetKeyIDFromPrivateKey() (int64, error)

GetKeyIDFromPrivateKey load KeyID fron PrivateKey file

func GetTablePrefix

func GetTablePrefix(global string, stateId int64) (string, error)

GetTablePrefix returns table prefix

func GetTxTypeAndUserID

func GetTxTypeAndUserID(binaryBlock []byte) (txType int64, keyID int64)

GetTxTypeAndUserID returns tx type, wallet and citizen id from the block data

func InsertBlockWOForks

func InsertBlockWOForks(data []byte) error

InsertBlockWOForks is inserting blocks

func InsertInLogTx

func InsertInLogTx(transaction *model.DbTransaction, binaryTx []byte, time int64) error

InsertInLogTx is inserting tx in log

func InsertIntoBlockchain

func InsertIntoBlockchain(transaction *model.DbTransaction, block *Block) error

InsertIntoBlockchain inserts a block into the blockchain

func IsContractTransaction

func IsContractTransaction(txType int) bool

IsContractTransaction checks txType

func IsState

func IsState(transaction *model.DbTransaction, country string) (int64, error)

IsState returns if country is state

func MarshallBlock

func MarshallBlock(header *utils.BlockData, trData [][]byte, prevHash []byte, key string) ([]byte, error)

MarshallBlock is marshalling block

func ParseBlockHeader

func ParseBlockHeader(binaryBlock *bytes.Buffer) (utils.BlockData, error)

ParseBlockHeader is parses block header

func RollbackTxFromBlock

func RollbackTxFromBlock(data []byte) error

RollbackTxFromBlock is rollback tx from block

func UpdBlockInfo

func UpdBlockInfo(dbTransaction *model.DbTransaction, block *Block) error

UpdBlockInfo updates info_block table

Types

type Block

type Block struct {
	Header     utils.BlockData
	PrevHeader *utils.BlockData
	MrklRoot   []byte
	BinData    []byte
	Parsers    []*Parser
	SysUpdate  bool
}

Block is storing block data

func ProcessBlockWherePrevFromBlockchainTable

func ProcessBlockWherePrevFromBlockchainTable(data []byte) (*Block, error)

ProcessBlockWherePrevFromBlockchainTable is processing block with in table previous block

func ProcessBlockWherePrevFromMemory

func ProcessBlockWherePrevFromMemory(data []byte) (*Block, error)

ProcessBlockWherePrevFromMemory is processing block with in memory previous block

func (*Block) CheckBlock

func (b *Block) CheckBlock() error

CheckBlock is checking block

func (*Block) CheckHash

func (b *Block) CheckHash() (bool, error)

CheckHash is checking hash

func (Block) GetLogger

func (b Block) GetLogger() *log.Entry

GetLogger is returns logger

func (*Block) PlayBlockSafe

func (b *Block) PlayBlockSafe() error

PlayBlockSafe is inserting block safely

type FirstBlockParser

type FirstBlockParser struct {
	*Parser
}

FirstBlockParser is parser wrapper

func (*FirstBlockParser) Action

func (p *FirstBlockParser) Action() error

Action is fires first block

func (FirstBlockParser) Header

func (p FirstBlockParser) Header() *tx.Header

Header is returns first block header

func (*FirstBlockParser) Init

func (p *FirstBlockParser) Init() error

Init first block

func (*FirstBlockParser) Rollback

func (p *FirstBlockParser) Rollback() error

Rollback first block

func (*FirstBlockParser) Validate

func (p *FirstBlockParser) Validate() error

Validate first block

type Parser

type Parser struct {
	BlockData *utils.BlockData
	PrevBlock *utils.BlockData

	CurrentVersion string
	MrklRoot       []byte
	PublicKeys     [][]byte

	TxBinaryData     []byte // transaction binary data
	TxFullData       []byte // full transaction, with type and data
	TxHash           []byte
	TxSlice          [][]byte
	TxMap            map[string][]byte
	TxIds            int // count of transactions
	TxKeyID          int64
	TxEcosystemIDStr string
	TxEcosystemID    int64
	TxNodePosition   uint32
	TxTime           int64
	TxType           int64
	TxCost           int64           // Maximum cost of executing contract
	TxUsedCost       decimal.Decimal // Used cost of CPU resources
	TxPtr            interface{}     // Pointer to the corresponding struct in consts/struct.go
	TxData           map[string]interface{}
	TxSmart          *tx.SmartContract
	TxContract       *smart.Contract
	TxHeader         *tx.Header

	DbTransaction *model.DbTransaction
	SysUpdate     bool

	SmartContract smart.SmartContract
	// contains filtered or unexported fields
}

Parser is a structure for parsing transactions

func ParseTransaction

func ParseTransaction(buffer *bytes.Buffer) (*Parser, error)

ParseTransaction is parsing transaction

func (*Parser) AccessChange

func (p *Parser) AccessChange(table, name, global string, stateId int64) error

AccessChange is changing access

func (*Parser) AccessRights

func (p *Parser) AccessRights(condition string, iscondition bool) error

AccessRights checks the access right by executing the condition value

func (*Parser) AllTxParser

func (p *Parser) AllTxParser() error

AllTxParser parses new transactions

func (*Parser) BlockError

func (p *Parser) BlockError(err error)

BlockError writes the error of the transaction in the transactions_status table

func (*Parser) CallContract

func (p *Parser) CallContract(flags int) (resultContract string, err error)

CallContract calls the contract functions according to the specified flags

func (*Parser) DeleteQueueTx

func (p *Parser) DeleteQueueTx(hash []byte) error

DeleteQueueTx deletes a transaction from the queue

func (*Parser) ErrInfo

func (p *Parser) ErrInfo(verr interface{}) error

ErrInfo returns the more detailed error

func (*Parser) FormatBlockData

func (p *Parser) FormatBlockData() string

FormatBlockData returns formated block data

func (*Parser) FormatTxMap

func (p *Parser) FormatTxMap() string

FormatTxMap returns the formated TxMap

func (Parser) GetLogger

func (p Parser) GetLogger() *log.Entry

GetLogger returns logger

func (*Parser) RollbackToBlockID

func (p *Parser) RollbackToBlockID(blockID int64) error

RollbackToBlockID rollbacks blocks till blockID

func (*Parser) TxParser

func (p *Parser) TxParser(hash, binaryTx []byte, myTx bool) error

TxParser writes transactions into the queue

type ParserInterface

type ParserInterface interface {
	Init() error
	Validate() error
	Action() error
	Rollback() error
	Header() *tx.Header
}

ParserInterface is parsing transactions

func GetParser

func GetParser(p *Parser, txType string) (ParserInterface, error)

GetParser returns ParserInterface

Jump to

Keyboard shortcuts

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