From e245576d70b1f720a9bc60c879ec9afb98fc22d3 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 27 Jan 2021 14:40:56 +0100 Subject: [PATCH] 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. --- auctioneer/client.go | 9 ++++++++- server.go | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/auctioneer/client.go b/auctioneer/client.go index e072c84..6232df5 100644 --- a/auctioneer/client.go +++ b/auctioneer/client.go @@ -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{ diff --git a/server.go b/server.go index ae6b200..c514c9c 100644 --- a/server.go +++ b/server.go @@ -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 {