mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
server+auctioneer: make batch version configurable
This commit is contained in:
parent
65045066af
commit
1f50c7839a
4 changed files with 45 additions and 31 deletions
|
|
@ -16,13 +16,14 @@ import (
|
|||
// auction. It can also perform the 3-way authentication handshake that is
|
||||
// needed to authenticate a trader for a subscription.
|
||||
type acctSubscription struct {
|
||||
acctKey *keychain.KeyDescriptor
|
||||
commitHash [32]byte
|
||||
sendMsg func(*auctioneerrpc.ClientAuctionMessage) error
|
||||
signer lndclient.SignerClient
|
||||
msgChan chan *auctioneerrpc.ServerAuctionMessage
|
||||
errChan chan error
|
||||
quit chan struct{}
|
||||
acctKey *keychain.KeyDescriptor
|
||||
commitHash [32]byte
|
||||
sendMsg func(*auctioneerrpc.ClientAuctionMessage) error
|
||||
signer lndclient.SignerClient
|
||||
msgChan chan *auctioneerrpc.ServerAuctionMessage
|
||||
batchVersion order.BatchVersion
|
||||
errChan chan error
|
||||
quit chan struct{}
|
||||
}
|
||||
|
||||
// authenticate performs the 3-way authentication handshake between the trader
|
||||
|
|
@ -50,7 +51,7 @@ func (s *acctSubscription) authenticate(ctx context.Context) error {
|
|||
Msg: &auctioneerrpc.ClientAuctionMessage_Commit{
|
||||
Commit: &auctioneerrpc.AccountCommitment{
|
||||
CommitHash: s.commitHash[:],
|
||||
BatchVersion: uint32(order.CurrentBatchVersion),
|
||||
BatchVersion: uint32(s.batchVersion),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/lightninglabs/pool/auctioneerrpc"
|
||||
"github.com/lightninglabs/pool/internal/test"
|
||||
"github.com/lightninglabs/pool/order"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
|
||||
|
|
@ -40,10 +41,11 @@ func TestAccountSubscriptionAuthenticate(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
sub = &acctSubscription{
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
batchVersion: order.CurrentBatchVersion,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -102,10 +104,11 @@ func TestAccountSubscriptionAuthenticateAbort(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
sub = &acctSubscription{
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
batchVersion: order.CurrentBatchVersion,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -154,10 +157,11 @@ func TestAccountSubscriptionAuthenticateContextClose(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
sub = &acctSubscription{
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
batchVersion: order.CurrentBatchVersion,
|
||||
}
|
||||
ctxc, cancel = context.WithCancel(context.Background())
|
||||
)
|
||||
|
|
@ -208,11 +212,12 @@ func TestAccountSubscriptionAuthenticateError(t *testing.T) {
|
|||
return nil
|
||||
}
|
||||
sub = &acctSubscription{
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
errChan: make(chan error),
|
||||
acctKey: testAccountDesc,
|
||||
sendMsg: sendMsg,
|
||||
signer: testSigner,
|
||||
msgChan: srvMsgChan,
|
||||
batchVersion: order.CurrentBatchVersion,
|
||||
errChan: make(chan error),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ type Config struct {
|
|||
// trader's pending batch.
|
||||
BatchCleaner BatchCleaner
|
||||
|
||||
// BatchVersion is the batch version that we should use when
|
||||
// authenticating with the auction server.
|
||||
BatchVersion order.BatchVersion
|
||||
|
||||
// GenUserAgent is a function that generates a complete user agent
|
||||
// string given the incoming request context.
|
||||
GenUserAgent func(context.Context) string
|
||||
|
|
@ -581,12 +585,13 @@ func (c *Client) connectAndAuthenticate(ctx context.Context,
|
|||
// Before we can expect to receive any updates, we need to perform the
|
||||
// 3-way authentication handshake.
|
||||
sub = &acctSubscription{
|
||||
acctKey: acctKey,
|
||||
sendMsg: c.SendAuctionMessage,
|
||||
signer: c.cfg.Signer,
|
||||
msgChan: make(chan *auctioneerrpc.ServerAuctionMessage),
|
||||
errChan: tempErrChan,
|
||||
quit: make(chan struct{}),
|
||||
acctKey: acctKey,
|
||||
sendMsg: c.SendAuctionMessage,
|
||||
signer: c.cfg.Signer,
|
||||
msgChan: make(chan *auctioneerrpc.ServerAuctionMessage),
|
||||
batchVersion: c.cfg.BatchVersion,
|
||||
errChan: tempErrChan,
|
||||
quit: make(chan struct{}),
|
||||
}
|
||||
c.subscribedAcctsMtx.Lock()
|
||||
c.subscribedAccts[acctPubKey] = sub
|
||||
|
|
|
|||
|
|
@ -505,6 +505,9 @@ func (s *Server) setupClient() error {
|
|||
MaxBackoff: s.cfg.MaxBackoff,
|
||||
BatchSource: s.db,
|
||||
BatchCleaner: s.fundingManager,
|
||||
BatchVersion: order.BatchVersion(
|
||||
s.cfg.DebugConfig.BatchVersion,
|
||||
),
|
||||
GenUserAgent: func(ctx context.Context) string {
|
||||
return UserAgent(InitiatorFromContext(ctx))
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue