txcounter

package
v0.0.0-...-e16fa07 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TxCounter

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

A struct counting the average TX size (in BCH) over a specified time period (such as 24h). This gives a dynamic threshold to identify whales.

func NewTxCounter

func NewTxCounter(config *TxCounterConfig, ctx context.Context, logger log.Logger, monitor *monitoring.HttpMonitoring) (*TxCounter, error)

func (*TxCounter) AddTransaction

func (counter *TxCounter) AddTransaction(sizeBch float32)

func (*TxCounter) GetAverageTransactionSize

func (counter *TxCounter) GetAverageTransactionSize() float32

func (*TxCounter) GetTransactionCount

func (counter *TxCounter) GetTransactionCount() int

func (*TxCounter) GetUpperTransactionSizePercent

func (counter *TxCounter) GetUpperTransactionSizePercent(percent float32) float32

func (*TxCounter) ScheduleCleanupTransactions

func (counter *TxCounter) ScheduleCleanupTransactions() error

func (*TxCounter) WriteTransactionsFile

func (counter *TxCounter) WriteTransactionsFile() error

type TxCounterConfig

type TxCounterConfig struct {
	AverageTime time.Duration // the time to go back and include TX for average size calculation
}

type TxCounterTransaction

type TxCounterTransaction struct {
	SizeBch float32
	When    time.Time
}

type TxHeap

type TxHeap []*TxCounterTransaction

An TxHeap is a min-heap of float32 TX size values.

func (TxHeap) Len

func (h TxHeap) Len() int

func (TxHeap) Less

func (h TxHeap) Less(i, j int) bool

func (h TxHeap) Less(i, j int) bool { return h[i].SizeBch < h[j].SizeBch }

func (*TxHeap) Pop

func (h *TxHeap) Pop() interface{}

func (*TxHeap) Push

func (h *TxHeap) Push(x interface{})

func (TxHeap) Swap

func (h TxHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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