mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 14:17:56 +01:00
chanacceptor: Adding Chained and RPC acceptors
This commit introduces the chanacceptor package which is used to determine, by a set of heuristics, which open channel messages to accept and reject. Currently, two acceptors are implemented via the ChannelAcceptor interface: ChainedAcceptor and RPCAcceptor. The RPCAcceptor allows the RPC client to respond to the open channel request, and the ChainedAcceptor allows a conjunction of acceptors to be used.
This commit is contained in:
27
chanacceptor/rpcacceptor.go
Normal file
27
chanacceptor/rpcacceptor.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package chanacceptor
|
||||
|
||||
// RPCAcceptor represents the RPC-controlled variant of the ChannelAcceptor.
|
||||
// One RPCAcceptor allows one RPC client.
|
||||
type RPCAcceptor struct {
|
||||
acceptClosure func(req *ChannelAcceptRequest) bool
|
||||
}
|
||||
|
||||
// Accept is a predicate on the ChannelAcceptRequest which is sent to the RPC
|
||||
// client who will respond with the ultimate decision. This assumes an accept
|
||||
// closure has been specified during creation.
|
||||
//
|
||||
// NOTE: Part of the ChannelAcceptor interface.
|
||||
func (r *RPCAcceptor) Accept(req *ChannelAcceptRequest) bool {
|
||||
return r.acceptClosure(req)
|
||||
}
|
||||
|
||||
// NewRPCAcceptor creates and returns an instance of the RPCAcceptor.
|
||||
func NewRPCAcceptor(closure func(*ChannelAcceptRequest) bool) *RPCAcceptor {
|
||||
return &RPCAcceptor{
|
||||
acceptClosure: closure,
|
||||
}
|
||||
}
|
||||
|
||||
// A compile-time constraint to ensure RPCAcceptor implements the ChannelAcceptor
|
||||
// interface.
|
||||
var _ ChannelAcceptor = (*RPCAcceptor)(nil)
|
||||
Reference in New Issue
Block a user