mirror of
https://github.com/muun/recovery.git
synced 2025-11-11 14:30:19 -05:00
36 lines
872 B
Go
36 lines
872 B
Go
package newop
|
|
|
|
import "github.com/muun/libwallet/operation"
|
|
|
|
// FeeWindow holds a map of target block to fee rate for a given time
|
|
type FeeWindow struct {
|
|
FastConfTarget int64
|
|
MediumConfTarget int64
|
|
SlowConfTarget int64
|
|
TargetedFees map[uint]float64
|
|
}
|
|
|
|
func (w *FeeWindow) PutTargetedFees(target int64, feeRateInSatsPerVByte float64) {
|
|
if w.TargetedFees == nil {
|
|
w.TargetedFees = make(map[uint]float64)
|
|
}
|
|
w.TargetedFees[uint(target)] = feeRateInSatsPerVByte
|
|
}
|
|
|
|
func (w *FeeWindow) GetTargetedFees(target int64) float64 {
|
|
if w.TargetedFees == nil {
|
|
return 0
|
|
}
|
|
return w.TargetedFees[uint(target)]
|
|
}
|
|
|
|
func (w *FeeWindow) nextHighestBlock(feeRate float64) int64 {
|
|
return int64(w.toInternalType().NextHighestBlock(feeRate))
|
|
}
|
|
|
|
func (w *FeeWindow) toInternalType() *operation.FeeWindow {
|
|
return &operation.FeeWindow{
|
|
TargetedFees: w.TargetedFees,
|
|
}
|
|
}
|