transactionpool

package
v0.0.0-...-3442dc8 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: GPL-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaData_TxPool_Tx     = "MD_TP_Tx"
	MetaData_TxPool_Config = "MD_TP_Config"
)
View Source
const (
	ChanAddTxsSize        = 1024 * 1024
	ChanBlockAddedSize    = 64
	ChanDelTxsStorage     = 20 * 1024
	ChanSaveTxsStorage    = 20 * 1024
	TxCacheSize           = 1024 * 1024
	AccountNonceCacheSize = 40 * 1024
	MaxUint64             = 1<<64 - 1
)

Variables

View Source
var (
	ErrInvalidLengthMessageTxpool        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowMessageTxpool          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupMessageTxpool = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ExpiredTxsInterval  = 2000 * time.Millisecond
	RepublishTxInterval = 1000 * time.Millisecond
	RepublishTxLimit    = 50

	ObsID string

	ErrAlreadyKnown  = errors.New("transaction is already know")
	ErrTxNotExist    = errors.New("transaction not found")
	ErrAddrNotExist  = errors.New("address not found")
	ErrNoTxAdded     = errors.New("no transactions add to txPool")
	ErrNonceNotMin   = errors.New("nonce is not min when remove tx")
	ErrTxIDDiff      = errors.New("TxID is different for the same nonce ")
	ErrTxIsPackaged  = errors.New("transaction is packaged can't be replaced")
	ErrTxIsNil       = errors.New("transaction is nil")
	ErrUnRooted      = errors.New("UnRooted new chain")
	ErrTxStoragePath = errors.New("error tx storage path")
	ErrTxPoolFull    = errors.New("tx pool is full")
)
View Source
var TxPoolMessage_TxPoolMessageType_name = map[int32]string{
	0: "Unknown",
	1: "Tx",
}
View Source
var TxPoolMessage_TxPoolMessageType_value = map[string]int32{
	"Unknown": 0,
	"Tx":      1,
}

Functions

func CreateTransactionPoolActor

func CreateTransactionPoolActor(level tplogcmm.LogLevel, log tplog.Logger, sysActor *actor.ActorSystem, txPool *transactionPool) (*actor.PID, error)

func NewTransactionPool

func NewTransactionPool(exeDomainID string,
	nodeID string,
	ctx context.Context,
	conf *tpconfig.TransactionPoolConfig,
	level tplogcmm.LogLevel,
	log tplog.Logger,
	codecType codec.CodecType,
	stateQueryService service.StateQueryService,
	blockService service.BlockService,
	network tpnet.Network,
	ledger ledger.Ledger) txpooli.TransactionPool

func NewTransactionPoolHandler

func NewTransactionPoolHandler(log tplog.Logger, txPool *transactionPool, txMsgSub TxMsgSubProcessor) *transactionPoolHandler

Types

type BlockAddedEvent

type BlockAddedEvent struct{ Block *tpchaintypes.Block }

type BlocksRevertEvent

type BlocksRevertEvent struct {
	Blocks []*tpchaintypes.Block
}

type PickTxType

type PickTxType uint32
const (
	PickTxPending PickTxType = iota
	PickTxPriceAndNonce
	PickTxPriceAndTime
)

type TransactionPoolHandler

type TransactionPoolHandler interface {
	ProcessTx(ctx context.Context, msg *TxMessage) error
	// contains filtered or unexported methods
}

type TransactionPoolServant

type TransactionPoolServant interface {
	CurrentHeight() (uint64, error)

	GetNonce(tpcrtypes.Address) (uint64, error)

	GetLatestBlock() (*tpchaintypes.Block, error)

	GetBlockByHash(hash tpchaintypes.BlockHash) (*tpchaintypes.Block, error)

	GetBlockByNumber(blockNum tpchaintypes.BlockNum) (*tpchaintypes.Block, error)

	GetLedger() ledger.Ledger

	PublishTx(ctx context.Context, marshaler codec.Marshaler, topic string, domainID string, nodeID string, tx *txbasic.Transaction) error

	Subscribe(ctx context.Context, topic string, localIgnore bool, validators ...message.PubSubMessageValidator) error

	UnSubscribe(topic string) error

	CreateTopic(topic string)
	// contains filtered or unexported methods
}

type TxExpiredPolicy

type TxExpiredPolicy byte
const (
	TxExpiredTime TxExpiredPolicy = iota
	TxExpiredHeight
	TxExpiredTimeAndHeight
	TxExpiredTimeOrHeight
)

type TxMessage

type TxMessage struct {
	Data                 []byte   `protobuf:"bytes,1,opt,name=Data,proto3" json:"data"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*TxMessage) Descriptor

func (*TxMessage) Descriptor() ([]byte, []int)

func (*TxMessage) GetData

func (m *TxMessage) GetData() []byte

func (*TxMessage) Marshal

func (m *TxMessage) Marshal() (dAtA []byte, err error)

func (*TxMessage) MarshalTo

func (m *TxMessage) MarshalTo(dAtA []byte) (int, error)

func (*TxMessage) MarshalToSizedBuffer

func (m *TxMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TxMessage) ProtoMessage

func (*TxMessage) ProtoMessage()

func (*TxMessage) Reset

func (m *TxMessage) Reset()

func (*TxMessage) Size

func (m *TxMessage) Size() (n int)

func (*TxMessage) String

func (m *TxMessage) String() string

func (*TxMessage) Unmarshal

func (m *TxMessage) Unmarshal(dAtA []byte) error

func (*TxMessage) XXX_DiscardUnknown

func (m *TxMessage) XXX_DiscardUnknown()

func (*TxMessage) XXX_Marshal

func (m *TxMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TxMessage) XXX_Merge

func (m *TxMessage) XXX_Merge(src proto.Message)

func (*TxMessage) XXX_Size

func (m *TxMessage) XXX_Size() int

func (*TxMessage) XXX_Unmarshal

func (m *TxMessage) XXX_Unmarshal(b []byte) error

type TxMsgSubProcessor

type TxMsgSubProcessor interface {
	Validate(ctx context.Context, isLocal bool, data []byte) message.ValidationResult
	Process(ctx context.Context, subMsgTxMessage *TxMessage) error
}

func NewTxMsgSubProcessor

func NewTxMsgSubProcessor(exeDomainID string, nodeID string, log tplog.Logger, txPool *transactionPool) TxMsgSubProcessor

type TxPoolActor

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

func (*TxPoolActor) Receive

func (ta *TxPoolActor) Receive(context actor.Context)

type TxPoolMessage

type TxPoolMessage struct {
	MsgType              TxPoolMessage_TxPoolMessageType `protobuf:"varint,1,opt,name=MsgType,proto3,enum=proto.TxPoolMessage_TxPoolMessageType" json:"msgType"`
	FromDomain           []byte                          `protobuf:"bytes,2,opt,name=FromDomain,proto3" json:"fromDomain"`
	FromNode             []byte                          `protobuf:"bytes,3,opt,name=FromNode,proto3" json:"fromNode"`
	Data                 []byte                          `protobuf:"bytes,4,opt,name=Data,proto3" json:"data"`
	XXX_NoUnkeyedLiteral struct{}                        `json:"-"`
	XXX_unrecognized     []byte                          `json:"-"`
	XXX_sizecache        int32                           `json:"-"`
}

func (*TxPoolMessage) Descriptor

func (*TxPoolMessage) Descriptor() ([]byte, []int)

func (*TxPoolMessage) GetData

func (m *TxPoolMessage) GetData() []byte

func (*TxPoolMessage) GetFromDomain

func (m *TxPoolMessage) GetFromDomain() []byte

func (*TxPoolMessage) GetFromNode

func (m *TxPoolMessage) GetFromNode() []byte

func (*TxPoolMessage) GetMsgType

func (*TxPoolMessage) Marshal

func (m *TxPoolMessage) Marshal() (dAtA []byte, err error)

func (*TxPoolMessage) MarshalTo

func (m *TxPoolMessage) MarshalTo(dAtA []byte) (int, error)

func (*TxPoolMessage) MarshalToSizedBuffer

func (m *TxPoolMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TxPoolMessage) ProtoMessage

func (*TxPoolMessage) ProtoMessage()

func (*TxPoolMessage) Reset

func (m *TxPoolMessage) Reset()

func (*TxPoolMessage) Size

func (m *TxPoolMessage) Size() (n int)

func (*TxPoolMessage) String

func (m *TxPoolMessage) String() string

func (*TxPoolMessage) Unmarshal

func (m *TxPoolMessage) Unmarshal(dAtA []byte) error

func (*TxPoolMessage) XXX_DiscardUnknown

func (m *TxPoolMessage) XXX_DiscardUnknown()

func (*TxPoolMessage) XXX_Marshal

func (m *TxPoolMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TxPoolMessage) XXX_Merge

func (m *TxPoolMessage) XXX_Merge(src proto.Message)

func (*TxPoolMessage) XXX_Size

func (m *TxPoolMessage) XXX_Size() int

func (*TxPoolMessage) XXX_Unmarshal

func (m *TxPoolMessage) XXX_Unmarshal(b []byte) error

type TxPoolMessage_TxPoolMessageType

type TxPoolMessage_TxPoolMessageType int32
const (
	TxPoolMessage_Unknown TxPoolMessage_TxPoolMessageType = 0
	TxPoolMessage_Tx      TxPoolMessage_TxPoolMessageType = 1
)

func (TxPoolMessage_TxPoolMessageType) EnumDescriptor

func (TxPoolMessage_TxPoolMessageType) EnumDescriptor() ([]byte, []int)

func (TxPoolMessage_TxPoolMessageType) String

type TxRepublishPolicy

type TxRepublishPolicy byte
const (
	TxRepublishTime TxRepublishPolicy = iota
	TxRepublishHeight
	TxRepublishTimeAndHeight
	TxRepublishTimeOrHeight
)

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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