lnd/lncfg/dev.go
ziggie 66f64c2b63
routerrpc: implement DeleteForwardingHistory RPC handler
In this commit, we implement the server-side handler for the
DeleteForwardingHistory RPC, connecting the proto definition to the
database layer through the ForwardingLogDB interface on RouterBackend.

The handler resolves the time specification from the request oneof: an
absolute Unix timestamp is used directly, while a relative duration
string is parsed via parseDuration and resolved against the current
clock time. We use the injected clock (RouterBackend.Clock) rather than
time.Now to keep the handler testable.

A configurable minimum age guard (MinFwdHistoryAge, defaulting to 1h)
prevents accidental deletion of recent events. The minimum age can be
overridden via --routerrpc.min-fwd-history-age for environments such as
integration tests that need a shorter threshold.

The context is threaded through to DeleteForwardingEvents so that client
cancellation or deadline expiry aborts the deletion between batches.
Batches already committed at cancellation time are permanent, but the
operation is safe to re-run since deletion is idempotent.
2026-03-27 20:53:00 +01:00

73 lines
2.2 KiB
Go

//go:build !integration
package lncfg
import (
"time"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
)
// IsDevBuild returns a bool to indicate whether we are in a development
// environment.
//
// NOTE: always return false here.
func IsDevBuild() bool {
return false
}
// DevConfig specifies development configs used for production. This struct
// should always remain empty.
type DevConfig struct{}
// ChannelReadyWait returns the config value, which is always 0 for production
// build.
func (d *DevConfig) ChannelReadyWait() time.Duration {
return 0
}
// GetUnsafeDisconnect returns the config value, which is always true for
// production build.
//
// TODO(yy): this is a temporary solution to allow users to reconnect peers to
// trigger a reestablishiment for the active channels. Once a new dedicated RPC
// is added to realize that functionality, this function should return false to
// forbidden disconnecting peers while there are active channels.
func (d *DevConfig) GetUnsafeDisconnect() bool {
return true
}
// GetReservationTimeout returns the config value for `ReservationTimeout`.
func (d *DevConfig) GetReservationTimeout() time.Duration {
return chanfunding.DefaultReservationTimeout
}
// GetZombieSweeperInterval returns the config value for`ZombieSweeperInterval`.
func (d *DevConfig) GetZombieSweeperInterval() time.Duration {
return DefaultZombieSweeperInterval
}
// GetMaxWaitNumBlocksFundingConf returns the config value for
// `MaxWaitNumBlocksFundingConf`.
func (d *DevConfig) GetMaxWaitNumBlocksFundingConf() uint32 {
return DefaultMaxWaitNumBlocksFundingConf
}
// GetUnsafeConnect returns the config value `UnsafeConnect`, which is always
// false for production build.
func (d *DevConfig) GetUnsafeConnect() bool {
return false
}
// GetMinFwdHistoryAge returns 0 for production builds, causing the caller to
// use the hardcoded default of 1h.
func (d *DevConfig) GetMinFwdHistoryAge() time.Duration {
return 0
}
// ChannelCloseConfs returns the config value for channel close confirmations
// override, which is always None for production build.
func (d *DevConfig) ChannelCloseConfs() fn.Option[uint32] {
return fn.None[uint32]()
}