54c3e98b40
This commit moves and partially refactors the channel acceptor logic added in c2a6c86e into the channel acceptor package. This allows us to use the same logic in our unit tests as the rpcserver, rather than needing to replicate it in unit tests. Two changes are made to the existing implementation: - Rather than having the Accept function run a closure, the closure originally used in the rpcserver is moved directly into Accept - The done channel used to signal client exit is moved into the acceptor because the rpc server does not need knowledge of this detail (in addition to other fields required for mocking the actual rpc). Crediting orginal committer as co-author: Co-authored-by: Crypt-iQ
33 lines
864 B
Go
33 lines
864 B
Go
package chanacceptor
|
|
|
|
import (
|
|
"github.com/btcsuite/btclog"
|
|
"github.com/lightningnetwork/lnd/build"
|
|
)
|
|
|
|
// Subsystem defines the logging code for this subsystem.
|
|
const Subsystem = "CHAC"
|
|
|
|
// log is a logger that is initialized with no output filters. This
|
|
// means the package will not perform any logging by default until the caller
|
|
// requests it.
|
|
var log btclog.Logger
|
|
|
|
// The default amount of logging is none.
|
|
func init() {
|
|
UseLogger(build.NewSubLogger(Subsystem, nil))
|
|
}
|
|
|
|
// DisableLog disables all library log output. Logging output is disabled
|
|
// by default until UseLogger is called.
|
|
func DisableLog() {
|
|
UseLogger(btclog.Disabled)
|
|
}
|
|
|
|
// UseLogger uses a specified Logger to output package logging info.
|
|
// This should be used in preference to SetLogWriter if the caller is also
|
|
// using btclog.
|
|
func UseLogger(logger btclog.Logger) {
|
|
log = logger
|
|
}
|