Documentation
¶
Index ¶
- func GetTransactionCoinType(tx *dcrutil.Tx) cointype.CoinType
- func UseLogger(logger slog.Logger)
- type AllocationResult
- type BlockSpaceAllocator
- type CoinTypeAllocation
- type TransactionSizeTracker
- func (tst *TransactionSizeTracker) AddTransaction(tx *dcrutil.Tx)
- func (tst *TransactionSizeTracker) CanAddTransaction(tx *dcrutil.Tx) bool
- func (tst *TransactionSizeTracker) GetAllocation() *AllocationResult
- func (tst *TransactionSizeTracker) GetSizeForCoinType(coinType cointype.CoinType) uint32
- func (tst *TransactionSizeTracker) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTransactionCoinType ¶
GetTransactionCoinType determines the primary coin type of a transaction based on the total value of outputs for each coin type.
Types ¶
type AllocationResult ¶
type AllocationResult struct {
Allocations map[cointype.CoinType]*CoinTypeAllocation
TotalAllocated uint32
TotalUsed uint32
OverflowHandled uint32
}
AllocationResult contains the complete block space allocation for all coin types.
func (*AllocationResult) GetAllocationForCoinType ¶
func (result *AllocationResult) GetAllocationForCoinType(coinType cointype.CoinType) *CoinTypeAllocation
GetAllocationForCoinType returns the space allocation for a specific coin type.
func (*AllocationResult) GetUtilizationPercentage ¶
func (result *AllocationResult) GetUtilizationPercentage() float64
GetUtilizationPercentage returns the overall block space utilization as a percentage.
type BlockSpaceAllocator ¶
type BlockSpaceAllocator struct {
// contains filtered or unexported fields
}
BlockSpaceAllocator manages the allocation of block space among different coin types following the 10% VAR / 90% SKA proportional distribution strategy.
func NewBlockSpaceAllocator ¶
func NewBlockSpaceAllocator(maxBlockSize uint32, chainParams *chaincfg.Params) *BlockSpaceAllocator
NewBlockSpaceAllocator creates a new block space allocator with the standard 10% VAR / 90% SKA allocation strategy.
func (*BlockSpaceAllocator) AllocateBlockSpace ¶
func (bsa *BlockSpaceAllocator) AllocateBlockSpace(pendingTxBytes map[cointype.CoinType]uint32) *AllocationResult
AllocateBlockSpace calculates the optimal block space allocation given pending transaction sizes for each coin type. Returns allocation details for all coin types.
Algorithm: 1. If no SKA has pending transactions, VAR gets 100% of block space (early exit) 2. Otherwise, initial 10% VAR / 90% SKA split among active SKA types 3. Redistribute unused space ONCE with 10%/90% proportional allocation 4. Any remaining unused space goes to VAR
type CoinTypeAllocation ¶
type CoinTypeAllocation struct {
CoinType cointype.CoinType
BaseAllocation uint32 // Guaranteed space allocation
FinalAllocation uint32 // Final space after overflow distribution
PendingBytes uint32 // Bytes of transactions pending for this coin type
UsedBytes uint32 // Bytes actually used by this coin type
}
CoinTypeAllocation represents the space allocation for a specific coin type.
type TransactionSizeTracker ¶
type TransactionSizeTracker struct {
// contains filtered or unexported fields
}
TransactionSizeTracker tracks transaction sizes by coin type for block space allocation.
func NewTransactionSizeTracker ¶
func NewTransactionSizeTracker(allocator *BlockSpaceAllocator) *TransactionSizeTracker
NewTransactionSizeTracker creates a new transaction size tracker.
func (*TransactionSizeTracker) AddTransaction ¶
func (tst *TransactionSizeTracker) AddTransaction(tx *dcrutil.Tx)
AddTransaction adds a transaction to the size tracking.
func (*TransactionSizeTracker) CanAddTransaction ¶
func (tst *TransactionSizeTracker) CanAddTransaction(tx *dcrutil.Tx) bool
CanAddTransaction checks if a transaction can be added without exceeding coin type allocation.
func (*TransactionSizeTracker) GetAllocation ¶
func (tst *TransactionSizeTracker) GetAllocation() *AllocationResult
GetAllocation returns the current block space allocation based on tracked transaction sizes.
func (*TransactionSizeTracker) GetSizeForCoinType ¶
func (tst *TransactionSizeTracker) GetSizeForCoinType(coinType cointype.CoinType) uint32
GetSizeForCoinType returns the current size tracked for a specific coin type.
func (*TransactionSizeTracker) Reset ¶
func (tst *TransactionSizeTracker) Reset()
Reset clears all tracked transaction sizes.