tx

package
v0.0.0-...-ba30ba3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastTxIDPrefix                = byte(0x03)
	PendingTxPrefix               = byte(0x04)
	BroadcastedBlobTxPrefix       = byte(0x05)
	NoncePrefix                   = byte(0x06)
	ExpiredTxPrefix               = byte(0x07)
	CommittedTxPrefix             = byte(0x08)
	WithdrawalPrefix              = byte(0x09)
	BroadcastedWithdrawalTxPrefix = byte(0x0A)

	StartingTxNumber = 0
)

Variables

View Source
var ErrTxNotFound = errors.New("transaction not found")

Functions

func AddWithdrawal

func AddWithdrawal(txn *badger.Txn, address string, amount uint64, add bool) error

func BroadcastedBlobTxKey

func BroadcastedBlobTxKey(id TxID) []byte

func BroadcastedWithdrawalTxKey

func BroadcastedWithdrawalTxKey(id TxID) []byte

func CommittedBlobKey

func CommittedBlobKey(id BlobID) []byte

func ExpiredBlobKey

func ExpiredBlobKey(id BlobID) []byte

func Hash

func Hash(b []byte) []byte

func HeightFromBytes

func HeightFromBytes(heightBytes []byte) uint64

func HeightToBytes

func HeightToBytes(h uint64) []byte

func LastBlobIDKey

func LastBlobIDKey() []byte

func NewBlobMeta

func NewBlobMeta(signer string, fee uint64) *wire.BlobMeta

func NonceKey

func NonceKey(nonce uint64) []byte

func ParseAddressFromKey

func ParseAddressFromKey(withdrawalKey []byte) string

func PendingBlobKey

func PendingBlobKey(id BlobID) []byte

func ToUint64s

func ToUint64s(ids []BlobID) []uint64

func WithdrawalKey

func WithdrawalKey(address string) []byte

Types

type Blob

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

func (*Blob) BlobMeta

func (b *Blob) BlobMeta() *wire.BlobMeta

func (*Blob) Blobs

func (b *Blob) Blobs() [][]byte

func (*Blob) Compact

func (b *Blob) Compact() bool

func (*Blob) EstimatedGas

func (b *Blob) EstimatedGas() uint64

func (*Blob) ExpiryHeight

func (b *Blob) ExpiryHeight() uint64

func (*Blob) Fee

func (b *Blob) Fee() uint64

func (*Blob) Hash

func (b *Blob) Hash() []byte

Hash is the sha256 of the signer, namespace, blobs and fee It is used to represent uniqueness of a transaction

func (*Blob) ID

func (b *Blob) ID() BlobID

func (*Blob) InsertHeight

func (b *Blob) InsertHeight() uint64

func (*Blob) Namespace

func (b *Blob) Namespace() []byte

func (*Blob) NamespaceVersion

func (b *Blob) NamespaceVersion() uint32

func (*Blob) ShareVersion

func (b *Blob) ShareVersion() uint32

func (*Blob) Signer

func (b *Blob) Signer() string

func (*Blob) TimeoutBlocks

func (b *Blob) TimeoutBlocks() uint64

type BlobID

type BlobID uint64

func BlobIDFromKey

func BlobIDFromKey(key []byte) BlobID

func GetBlobIDs

func GetBlobIDs(blobs []*Blob) []BlobID

func ToBlobIDs

func ToBlobIDs(ids []uint64) []BlobID

func (BlobID) Bytes

func (id BlobID) Bytes() []byte

type Pool

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

func NewPool

func NewPool(db *badger.DB, latestHeight uint64) (*Pool, error)

func (*Pool) Add

func (p *Pool) Add(
	signer string,
	namespace []byte,
	blobs [][]byte,
	fee, estimatedGas uint64,
	options *wire.Options,
	hook func(*badger.Txn) error,
) (BlobID, error)

func (*Pool) Cancel

func (p *Pool) Cancel(id BlobID) error

func (*Pool) CommitTx

func (p *Pool) CommitTx(txn *badger.Txn, txID TxID, pfbHash []byte) error

func (*Pool) GetAllWithdrawals

func (p *Pool) GetAllWithdrawals() map[string]uint64

func (*Pool) GetPendingTx

func (p *Pool) GetPendingTx(id BlobID) *Blob

func (*Pool) GetPendingWithdrawalAmount

func (p *Pool) GetPendingWithdrawalAmount(address string) uint64

func (*Pool) MarkBroadcasted

func (p *Pool) MarkBroadcasted(txID TxID, blobIDs []BlobID, timeoutHeight uint64) error

func (*Pool) MarkFailed

func (p *Pool) MarkFailed(txID TxID, height uint64) error

func (*Pool) MarkWithdrawalTxBroadcasted

func (p *Pool) MarkWithdrawalTxBroadcasted(txID TxID, withdrawals map[string]uint64, timeoutHeight uint64) error

func (*Pool) MarkWithdrawalTxFailed

func (p *Pool) MarkWithdrawalTxFailed(txID TxID) error

func (*Pool) MarkWithdrawalsComplete

func (p *Pool) MarkWithdrawalsComplete(txID TxID) (int, error)

func (*Pool) ProcessWithdrawal

func (p *Pool) ProcessWithdrawal(address string, amount uint64) error

func (*Pool) Pull

func (p *Pool) Pull(gasPrice float64, fixedPFBGas uint64) []*Blob

func (*Pool) Status

func (p *Pool) Status(id BlobID) *wire.StatusResponse

func (*Pool) Update

func (p *Pool) Update(height uint64) (int, error)

func (*Pool) WasBroadcasted

func (p *Pool) WasBroadcasted(txID TxID) bool

func (*Pool) WasWithdrawalBroadcasted

func (p *Pool) WasWithdrawalBroadcasted(txID TxID) bool

type Store

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

func NewStore

func NewStore(db *badger.DB) (*Store, error)

func (*Store) DeleteCommittedTxs

func (s *Store) DeleteCommittedTxs(ids []BlobID) error

func (*Store) DeleteExpiredTxs

func (s *Store) DeleteExpiredTxs(ids []BlobID) error

func (*Store) DeletePendingBlob

func (s *Store) DeletePendingBlob(id BlobID, hook func(txn *badger.Txn) error) error

func (*Store) DeleteWithdrawalTx

func (s *Store) DeleteWithdrawalTx(txID TxID) error

func (*Store) GetBlobMeta

func (s *Store) GetBlobMeta(id BlobID) (*wire.BlobMeta, error)

func (*Store) GetCommittedBlob

func (s *Store) GetCommittedBlob(id BlobID) (*wire.BlobMeta, error)

func (*Store) GetExpired

func (s *Store) GetExpired(id BlobID) (uint64, error)

func (*Store) GetLastBlobKey

func (s *Store) GetLastBlobKey() (BlobID, error)

func (*Store) GetMostRecentCommittedTxs

func (s *Store) GetMostRecentCommittedTxs(limit BlobID) (map[BlobID]*wire.BlobMeta, error)

func (*Store) LoadAllBroadcastedBlobTxs

func (s *Store) LoadAllBroadcastedBlobTxs() (map[TxID]*wire.BlobTx, error)

func (*Store) LoadRecentlyExpiredTxs

func (s *Store) LoadRecentlyExpiredTxs(limit BlobID) (map[BlobID]uint64, error)

func (*Store) MarkAsTimedOut

func (s *Store) MarkAsTimedOut(txs []TxID, blobs []*Blob, height uint64) error

func (*Store) MarkBroadcasted

func (s *Store) MarkBroadcasted(txID TxID, ids []BlobID, height uint64) error

func (*Store) MarkCommitted

func (s *Store) MarkCommitted(txn *badger.Txn, blobIds []BlobID, txHash []byte) error

func (*Store) MarkExpired

func (s *Store) MarkExpired(blobs []*Blob, height uint64) error

func (*Store) MarkFailed

func (s *Store) MarkFailed(txID TxID, blobs []*Blob, height uint64) error

func (*Store) MoveWithdrawalToBroadcast

func (s *Store) MoveWithdrawalToBroadcast(txID TxID, withdrawalTx *wire.WithdrawalTx) error

func (*Store) MoveWithdrawalToPending

func (s *Store) MoveWithdrawalToPending(txID TxID) error

func (*Store) RefundLostPendingTxs

func (s *Store) RefundLostPendingTxs(height uint64) (map[BlobID]uint64, error)

func (*Store) SetPendingBlob

func (s *Store) SetPendingBlob(blobMeta *wire.BlobMeta, hook func(txn *badger.Txn) error) (BlobID, error)

func (*Store) SetWidthdrawal

func (s *Store) SetWidthdrawal(address string, amount uint64) error

type TxID

type TxID string

ID is the sha256 hash of the raw tx that is submitted and committed in a block. In the case of a blob tx, the pfb tx is used

func GetTxID

func GetTxID(tx []byte) TxID

func TxIDFromKey

func TxIDFromKey(key []byte) TxID

func (TxID) Bytes

func (id TxID) Bytes() []byte

func (TxID) HEX

func (id TxID) HEX() string

Jump to

Keyboard shortcuts

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