mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 18:27:43 +02:00
channeldb: FetchPermAndTempPeers to load access perms on startup
We introduce a new func FetchPermAndTempPeers that returns two maps. The first map indicates the nodes that will have "protected" access to the server. The second map indicates the nodes that have "temporary" access to the server. This will be used in a future commit in the server.go code.
This commit is contained in:
@@ -107,6 +107,10 @@ type testChannelParams struct {
|
||||
// openChannel is set to true if the channel should be fully marked as
|
||||
// open if this is false, the channel will be left in pending state.
|
||||
openChannel bool
|
||||
|
||||
// closedChannel is set to true if the channel should be marked as
|
||||
// closed after opening it.
|
||||
closedChannel bool
|
||||
}
|
||||
|
||||
// testChannelOption is a functional option which can be used to alter the
|
||||
@@ -129,6 +133,21 @@ func openChannelOption() testChannelOption {
|
||||
}
|
||||
}
|
||||
|
||||
// closedChannelOption is an option which can be used to create a test channel
|
||||
// that is closed.
|
||||
func closedChannelOption() testChannelOption {
|
||||
return func(params *testChannelParams) {
|
||||
params.closedChannel = true
|
||||
}
|
||||
}
|
||||
|
||||
// pubKeyOption is an option which can be used to set the remote's pubkey.
|
||||
func pubKeyOption(pubKey *btcec.PublicKey) testChannelOption {
|
||||
return func(params *testChannelParams) {
|
||||
params.channel.IdentityPub = pubKey
|
||||
}
|
||||
}
|
||||
|
||||
// localHtlcsOption is an option which allows setting of htlcs on the local
|
||||
// commitment.
|
||||
func localHtlcsOption(htlcs []HTLC) testChannelOption {
|
||||
@@ -231,6 +250,17 @@ func createTestChannel(t *testing.T, cdb *ChannelStateDB,
|
||||
err = params.channel.MarkAsOpen(params.channel.ShortChannelID)
|
||||
require.NoError(t, err, "unable to mark channel open")
|
||||
|
||||
if params.closedChannel {
|
||||
// Set the other public keys so that serialization doesn't
|
||||
// panic.
|
||||
err = params.channel.CloseChannel(&ChannelCloseSummary{
|
||||
RemotePub: params.channel.IdentityPub,
|
||||
RemoteCurrentRevocation: params.channel.IdentityPub,
|
||||
RemoteNextRevocation: params.channel.IdentityPub,
|
||||
})
|
||||
require.NoError(t, err, "unable to close channel")
|
||||
}
|
||||
|
||||
return params.channel
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user