auctioneer+server: send user agent to auctioneer

Send the static user agent plus the dynamic initiator string (if
provided) to the auctioneer in the InitAccount and SubmitOrder RPCs.
This commit is contained in:
Oliver Gugger 2021-01-27 14:40:56 +01:00
parent 76838927c8
commit e245576d70
No known key found for this signature in database
GPG key ID: 8E4256593F177720
2 changed files with 11 additions and 1 deletions

View file

@ -93,6 +93,10 @@ type Config struct {
// BatchCleaner provides functionality to clean up the state of a
// trader's pending batch.
BatchCleaner BatchCleaner
// GenUserAgent is a function that generates a complete user agent
// string given the incoming request context.
GenUserAgent func(context.Context) string
}
// Client performs the client side part of auctions. This interface exists to be
@ -287,6 +291,7 @@ func (c *Client) InitAccount(ctx context.Context, account *account.Account) erro
AccountValue: uint64(account.Value),
AccountExpiry: account.Expiry,
TraderKey: account.TraderKey.PubKey.SerializeCompressed(),
UserAgent: c.cfg.GenUserAgent(ctx),
},
)
return err
@ -355,7 +360,9 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
// Prepare everything that is common to both ask and bid orders.
nonce := o.Nonce()
rpcRequest := &auctioneerrpc.ServerSubmitOrderRequest{}
rpcRequest := &auctioneerrpc.ServerSubmitOrderRequest{
UserAgent: c.cfg.GenUserAgent(ctx),
}
nodeAddrs := make([]*auctioneerrpc.NodeAddress, 0, len(serverParams.Addrs))
for _, addr := range serverParams.Addrs {
nodeAddrs = append(nodeAddrs, &auctioneerrpc.NodeAddress{

View file

@ -466,6 +466,9 @@ func (s *Server) setupClient() error {
MaxBackoff: s.cfg.MaxBackoff,
BatchSource: s.db,
BatchCleaner: s.fundingManager,
GenUserAgent: func(ctx context.Context) string {
return UserAgent(InitiatorFromContext(ctx))
},
}
s.AuctioneerClient, err = auctioneer.NewClient(clientCfg)
if err != nil {