transaction

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Overview

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicatedTx = errors.New("Duplicated transaction")
	ErrNotComeTime  = errors.New("Transaction processing time has not come")
	ErrExpiredTime  = errors.New("Transaction processing time is expired")
	ErrEarlyTime    = utils.WithBan(errors.New("Early transaction time"))
	ErrEmptyKey     = utils.WithBan(errors.New("KeyID is empty"))
)
View Source
var (
	// ErrLimitSkip returns when tx should be skipped during generating block
	ErrLimitSkip = errors.New(`skip tx`)
	// ErrLimitStop returns when the generation of the block should be stopped
	ErrLimitStop = errors.New(`stop generating block`)
)
View Source
var (
	ErrNetworkStopping = errors.New("network is stopping")
)

Functions

func BadTxForBan

func BadTxForBan(keyID int64)

BadTxForBan adds info about bad tx of the key

func BannedTill

func BannedTill(keyID int64) string

BannedTill returns the time that the user has been banned till

func CheckLogTx

func CheckLogTx(txHash []byte, logger *log.Entry) error

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

func CleanCache

func CleanCache()

CleanCache cleans cache of transaction parsers

func CreateContract

func CreateContract(contractName string, keyID int64, params map[string]any,
	privateKey []byte) error

func CreateDelayTransactionHighRate

func CreateDelayTransactionHighRate(data, hash []byte, keyID, highRate int64) *sqldb.Transaction

CreateDelayTransactionHighRate creates transaction

func CreateTransaction

func CreateTransaction(data, hash []byte, keyID, tnow int64) error

CreateTransaction creates transaction

func DeleteQueueTx

func DeleteQueueTx(dbTx *sqldb.DbTransaction, hash []byte) error

DeleteQueueTx deletes a transaction from the queue

func IsKeyBanned

func IsKeyBanned(keyID int64) bool

IsKeyBanned returns true if the key has been banned

func MarkTransactionBad

func MarkTransactionBad(hash []byte, errText string) error

func NewInternalTransaction

func NewInternalTransaction(smartTx types.SmartTransaction, privateKey []byte) (data, hash []byte, err error)

func NewTransactionInProc

func NewTransactionInProc(smartTx types.SmartTransaction, privateKey []byte) (data, hash []byte, err error)

func ProcessQueueTransactionBatches

func ProcessQueueTransactionBatches(dbTx *sqldb.DbTransaction, qs []*sqldb.QueueTx) error

func ProcessTransactionsAttempt

func ProcessTransactionsAttempt(dbTx *sqldb.DbTransaction) error

AllTxParser parses new transactions

func ProcessTransactionsQueue

func ProcessTransactionsQueue(dbTx *sqldb.DbTransaction) error

ProcessTransactionsQueue parses new transactions

Types

type DeliverProvider

type DeliverProvider interface {
	SysUpdateWorker(*sqldb.DbTransaction) error
	SysTableColByteaWorker(*sqldb.DbTransaction) error
	FlushVM()
}

type FirstBlockParser

type FirstBlockParser struct {
	Logger        *log.Entry
	DbTransaction *sqldb.DbTransaction
	Data          *types.FirstBlock
	Timestamp     int64
	TxHash        []byte
	Payload       []byte // transaction binary data
}

FirstBlockParser is parser wrapper

func (*FirstBlockParser) Action

func (f *FirstBlockParser) Action(in *InToCxt, out *OutCtx) (err error)

func (*FirstBlockParser) BinMarshal

func (s *FirstBlockParser) BinMarshal(data *types.FirstBlock) ([]byte, error)

func (*FirstBlockParser) FlushVM

func (f *FirstBlockParser) FlushVM()

func (*FirstBlockParser) Init

func (f *FirstBlockParser) Init(in *InToCxt) error

func (*FirstBlockParser) SysTableColByteaWorker

func (f *FirstBlockParser) SysTableColByteaWorker(dbTx *sqldb.DbTransaction) error

func (*FirstBlockParser) SysUpdateWorker

func (f *FirstBlockParser) SysUpdateWorker(dbTx *sqldb.DbTransaction) error

func (*FirstBlockParser) TxRollback

func (f *FirstBlockParser) TxRollback() error

func (*FirstBlockParser) Unmarshal

func (f *FirstBlockParser) Unmarshal(buffer *bytes.Buffer) error

func (*FirstBlockParser) Validate

func (f *FirstBlockParser) Validate() error

type InToCxt

type InToCxt struct {
	SqlDbSavePoint string
	GenBlock       bool
	DbTransaction  *sqldb.DbTransaction
	BlockHeader    *types.BlockHeader
	PreBlockHeader *types.BlockHeader
	Notifications  types.Notifications
	Rand           *rand.Rand
	TxCheckLimits  *Limits
	OutputsMap     map[sqldb.KeyUTXO][]sqldb.SpentInfo
	PrevSysPar     map[string]string
	EcoParams      []sqldb.EcoParam
}

type LimitMode

type LimitMode int

func GetLetGenBlock

func GetLetGenBlock() LimitMode

func GetLetParsing

func GetLetParsing() LimitMode

func GetLetPreprocess

func GetLetPreprocess() LimitMode

type Limiter

type Limiter interface {
	// contains filtered or unexported methods
}

Limiter describes interface functions for limits

type Limits

type Limits struct {
	Mode     LimitMode
	Limiters []Limiter // the list of limiters
}

Limits is used for saving current limit information

func NewLimits

func NewLimits(b LimitMode) (limits *Limits)

NewLimits initializes Limits structure.

func (*Limits) CheckLimit

func (limits *Limits) CheckLimit(t TransactionCaller) error

CheckLimit calls each limiter

type OutCtx

type OutCtx struct {
	SysUpdate    bool
	RollBackTx   []*types.RollbackTx
	TxResult     *pbgo.TxResult
	TxOutputsMap map[sqldb.KeyUTXO][]sqldb.SpentInfo
	TxInputsMap  map[sqldb.KeyUTXO][]sqldb.SpentInfo
}

func (*OutCtx) Apply

func (tr *OutCtx) Apply(opts ...OutCtxOption)

type OutCtxOption

type OutCtxOption func(b *OutCtx)

func WithOutCtxRollBackTx

func WithOutCtxRollBackTx(ret []*types.RollbackTx) OutCtxOption

func WithOutCtxSysUpdate

func WithOutCtxSysUpdate(ret bool) OutCtxOption

func WithOutCtxTxInputs

func WithOutCtxTxInputs(txInputsMap map[sqldb.KeyUTXO][]sqldb.SpentInfo) OutCtxOption

func WithOutCtxTxOutputs

func WithOutCtxTxOutputs(txOutputsMap map[sqldb.KeyUTXO][]sqldb.SpentInfo) OutCtxOption

func WithOutCtxTxResult

func WithOutCtxTxResult(ret *pbgo.TxResult) OutCtxOption

type SmartTransactionParser

type SmartTransactionParser struct {
	*smart.SmartContract
}

func (*SmartTransactionParser) Action

func (s *SmartTransactionParser) Action(in *InToCxt, out *OutCtx) (err error)

func (*SmartTransactionParser) BinMarshalWithPrivate

func (s *SmartTransactionParser) BinMarshalWithPrivate(smartTx *types.SmartTransaction, privateKey []byte, internal bool) ([]byte, error)

func (*SmartTransactionParser) FlushVM

func (s *SmartTransactionParser) FlushVM()

func (*SmartTransactionParser) Init

func (s *SmartTransactionParser) Init(t *InToCxt) error

func (*SmartTransactionParser) Marshal

func (s *SmartTransactionParser) Marshal() ([]byte, error)

func (*SmartTransactionParser) SysTableColByteaWorker

func (s *SmartTransactionParser) SysTableColByteaWorker(dbTx *sqldb.DbTransaction) error

func (*SmartTransactionParser) SysUpdateWorker

func (s *SmartTransactionParser) SysUpdateWorker(dbTx *sqldb.DbTransaction) error

func (*SmartTransactionParser) TxRollback

func (s *SmartTransactionParser) TxRollback() error

func (*SmartTransactionParser) Unmarshal

func (s *SmartTransactionParser) Unmarshal(buffer *bytes.Buffer, fill bool) error

func (*SmartTransactionParser) Validate

func (s *SmartTransactionParser) Validate() error

type StopNetworkParser

type StopNetworkParser struct {
	Logger    *log.Entry
	Data      *types.StopNetwork
	Cert      *x509.Cert
	Timestamp int64
	TxHash    []byte
	Payload   []byte // transaction binary data
}

func (*StopNetworkParser) Action

func (s *StopNetworkParser) Action(in *InToCxt, out *OutCtx) (err error)

func (*StopNetworkParser) BinMarshal

func (s *StopNetworkParser) BinMarshal(data *types.StopNetwork) ([]byte, error)

func (*StopNetworkParser) FlushVM

func (s *StopNetworkParser) FlushVM()

func (*StopNetworkParser) Init

func (s *StopNetworkParser) Init(in *InToCxt) error

func (*StopNetworkParser) SysTableColByteaWorker

func (s *StopNetworkParser) SysTableColByteaWorker(dbTx *sqldb.DbTransaction) error

func (*StopNetworkParser) SysUpdateWorker

func (s *StopNetworkParser) SysUpdateWorker(dbTx *sqldb.DbTransaction) error

func (*StopNetworkParser) TxRollback

func (s *StopNetworkParser) TxRollback() error

func (*StopNetworkParser) Unmarshal

func (s *StopNetworkParser) Unmarshal(buffer *bytes.Buffer) error

func (*StopNetworkParser) Validate

func (s *StopNetworkParser) Validate() error

type Transaction

type Transaction struct {
	FullData []byte // full transaction, with type and data
	*InToCxt
	*OutCtx
	Inner TransactionCaller
}

Transaction is a structure for parsing transactions

func UnmarshallTransaction

func UnmarshallTransaction(buffer *bytes.Buffer, fill bool) (*Transaction, error)

UnmarshallTransaction is unmarshalling transaction

func (*Transaction) Apply

func (tr *Transaction) Apply(opts ...TransactionOption) error

func (*Transaction) Check

func (t *Transaction) Check(checkTime int64) error

func (*Transaction) Expedite

func (t *Transaction) Expedite() decimal.Decimal

func (*Transaction) GetLogger

func (t *Transaction) GetLogger() *log.Entry

GetLogger returns logger

func (*Transaction) Hash

func (t *Transaction) Hash() []byte

func (*Transaction) IsSmartContract

func (t *Transaction) IsSmartContract() bool

func (*Transaction) KeyID

func (t *Transaction) KeyID() int64

func (*Transaction) Payload

func (t *Transaction) Payload() []byte

func (*Transaction) Play

func (t *Transaction) Play() error

func (*Transaction) SetRawTx

func (rtx *Transaction) SetRawTx() *sqldb.RawTx

func (*Transaction) SmartContract

func (t *Transaction) SmartContract() *SmartTransactionParser

func (*Transaction) Timestamp

func (t *Transaction) Timestamp() int64

func (*Transaction) Type

func (t *Transaction) Type() byte

func (*Transaction) Unmarshall

func (rtx *Transaction) Unmarshall(buffer *bytes.Buffer, fill bool) error

func (*Transaction) WithOption

func (tr *Transaction) WithOption(
	notifications types.Notifications,
	genBlock bool,
	blockHeader, preBlockHeader *types.BlockHeader,
	dbTransaction *sqldb.DbTransaction,
	rand *rand.Rand,
	txCheckLimits *Limits,
	sqlDbSavePoint string,
	outputsMap map[sqldb.KeyUTXO][]sqldb.SpentInfo,
	prevSysPar map[string]string,
	ecoParams []sqldb.EcoParam,
	opts ...TransactionOption) error

type TransactionCaller

type TransactionCaller interface {
	Init(*InToCxt) error
	Validate() error
	Action(*InToCxt, *OutCtx) error
	TxRollback() error
	// contains filtered or unexported methods
}

TransactionCaller is parsing transactions

type TransactionOption

type TransactionOption func(b *Transaction) error

type TxOutCtx

type TxOutCtx struct {
	SysUpdate        bool
	SysTableColBytea bool
	Flush            bool
	FlushRollback    []*smart.FlushInfo
	VM               *script.VM
	VM2              *script.VM
}

Jump to

Keyboard shortcuts

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