txpool

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TxsBucket   = "txs"
	BatchBucket = "txs:batch"
)
View Source
const AcquireRemainingLife = int64(time.Minute * 10)
View Source
const MaxObjectSize = 1 << 20 // 1MB

Variables

This section is empty.

Functions

func FindCOSEVerifier

func FindCOSEVerifier(ks signer.Keys, kid []byte) key.Verifier

func TxFrom

func TxFrom(obj *Object, verify bool) (*ld.Transaction, error)

func TxsFrom

func TxsFrom(os Objects, verify bool) (ld.Txs, error)

Types

type Chain

type Chain interface {
	GetGenesisTxs(context.Context) (ld.Txs, error)
	GetAccount(context.Context, ids.Address) (*ld.Account, error)
	PreVerifyTxs(context.Context, ld.Txs) error
}

Chain is Chain's tx interface.

func NewChainAPI

func NewChainAPI(endpoint string, opts *httprpc.CBORClientOptions) Chain

type MemStorage

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

MemStorage is in-memory POS for testing.

func (*MemStorage) BatchAccept

func (m *MemStorage) BatchAccept(ctx context.Context, bucket string, height uint64, hashList ids.IDList[ids.ID32]) error

func (*MemStorage) BatchAcquire

func (m *MemStorage) BatchAcquire(ctx context.Context, bucket string, hashList ids.IDList[ids.ID32]) error

func (*MemStorage) GetObject

func (m *MemStorage) GetObject(ctx context.Context, bucket string, hash ids.ID32) (*Object, error)

func (*MemStorage) ListUnaccept

func (m *MemStorage) ListUnaccept(ctx context.Context, bucket, token string) (
	hashList ids.IDList[ids.ID32], nextToken string, err error)

func (*MemStorage) PutObject

func (m *MemStorage) PutObject(ctx context.Context, bucket string, objectRaw []byte) error

func (*MemStorage) RemoveObject

func (m *MemStorage) RemoveObject(ctx context.Context, bucket string, hash ids.ID32) error

type Object

type Object struct {
	Raw []byte
	// -2: rejected, will be remove at expiration time
	// -1: wait for build, will be remove if not accepted before expiration time
	// 0: processing, will be remove if not accepted before expiration time, except genesis tx objects;
	// > 0: accepted, the height of block, the object is permanently stored.
	Height int64
}

Object represents a data with LDC's block height in the POS.

func (*Object) Hash

func (obj *Object) Hash() ids.ID32

Hash returns the SHA3-256 digest of the object's data. It is the key of the object.

type Objects

type Objects []*Object

func (Objects) ToRawList

func (os Objects) ToRawList() []cbor.RawMessage

type POS

type POS interface {
	GetObject(ctx context.Context, bucket string, hash ids.ID32) (*Object, error)
	PutObject(ctx context.Context, bucket string, objectRaw []byte) error
	RemoveObject(ctx context.Context, bucket string, hash ids.ID32) error
	BatchAcquire(ctx context.Context, bucket string, hashList ids.IDList[ids.ID32]) error
	BatchAccept(ctx context.Context, bucket string, height uint64, hashList ids.IDList[ids.ID32]) error
	ListUnaccept(ctx context.Context, bucket, token string) (hashList ids.IDList[ids.ID32], nextToken string, err error)
}

POS is permanent object storage interface.

func NewMemStorage

func NewMemStorage(expiration time.Duration) POS

type RequestParams

type RequestParams struct {
	Payload cbor.RawMessage                `cbor:"p,omitempty"`
	CWT     *cose.Sign1Message[cwt.Claims] `cbor:"t,omitempty"`
}

type TxOrBatch

type TxOrBatch struct {
	Tx           *ld.TxData  `cbor:"tx,omitempty"`
	Signatures   signer.Sigs `cbor:"ss,omitempty"`
	ExSignatures signer.Sigs `cbor:"es,omitempty"`
	Batch        ld.Txs      `cbor:"ba,omitempty"`
}

func (*TxOrBatch) ToTransaction

func (t *TxOrBatch) ToTransaction() (*ld.Transaction, error)

type TxPool

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

TxPool contains all currently known transactions.

func NewTxPool

func NewTxPool(pos POS, chain Chain, opts TxPoolOptions) *TxPool

NewTxPool creates a new transaction pool.

func (*TxPool) Bootstrap

func (p *TxPool) Bootstrap(ctx context.Context) error

func (*TxPool) ServeRPC

func (p *TxPool) ServeRPC(ctx context.Context, req *cborrpc.Request) *cborrpc.Response

func (*TxPool) SetChain

func (p *TxPool) SetChain(chain Chain)

type TxPoolOptions

type TxPoolOptions struct {
	Builder     ids.Address
	CWTAudience string
	CWTExData   []byte
}

type TxsBuildStatus

type TxsBuildStatus struct {
	Unknown  ids.IDList[ids.ID32] `cbor:"u,omitempty"`
	Rejected ids.IDList[ids.ID32] `cbor:"r,omitempty"`
}

Jump to

Keyboard shortcuts

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