Skip to content

Commit

Permalink
multi: Remove references to v2 ticket buyer.
Browse files Browse the repository at this point in the history
There is currently only a single implementation of ticket buyer, and all
references to old implementations have been removed. There is therefore
no longer any need to reference v2 (or even v3) ticket buyers.
  • Loading branch information
jholdstock committed Sep 9, 2024
1 parent b1879df commit adf2fa8
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 146 deletions.
36 changes: 18 additions & 18 deletions internal/rpc/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ type accountMixerServer struct {

// ticketbuyerServer provides RPC clients with the ability to start/stop the
// automatic ticket buyer service.
type ticketbuyerV2Server struct {
type ticketbuyerServer struct {
ready atomic.Uint32
loader *loader.Loader
pb.UnimplementedTicketBuyerV2ServiceServer
pb.UnimplementedTicketBuyerServiceServer
}

type agendaServer struct {
Expand Down Expand Up @@ -255,7 +255,7 @@ var (
loaderService loaderServer
seedService seedServer
accountMixerService accountMixerServer
ticketBuyerV2Service ticketbuyerV2Server
ticketBuyerService ticketbuyerServer
agendaService agendaServer
votingService votingServer
messageVerificationService messageVerificationServer
Expand All @@ -271,7 +271,7 @@ func RegisterServices(server *grpc.Server) {
pb.RegisterWalletLoaderServiceServer(server, &loaderService)
pb.RegisterSeedServiceServer(server, &seedService)
pb.RegisterAccountMixerServiceServer(server, &accountMixerService)
pb.RegisterTicketBuyerV2ServiceServer(server, &ticketBuyerV2Service)
pb.RegisterTicketBuyerServiceServer(server, &ticketBuyerService)
pb.RegisterAgendaServiceServer(server, &agendaService)
pb.RegisterVotingServiceServer(server, &votingService)
pb.RegisterMessageVerificationServiceServer(server, &messageVerificationService)
Expand All @@ -285,7 +285,7 @@ var serviceMap = map[string]any{
"walletrpc.WalletLoaderService": &loaderService,
"walletrpc.SeedService": &seedService,
"walletrpc.AccountMixerService": &accountMixerService,
"walletrpc.TicketBuyerV2Service": &ticketBuyerV2Service,
"walletrpc.TicketBuyerService": &ticketBuyerService,
"walletrpc.AgendaService": &agendaService,
"walletrpc.VotingService": &votingService,
"walletrpc.MessageVerificationService": &messageVerificationService,
Expand Down Expand Up @@ -2605,7 +2605,7 @@ func (t *accountMixerServer) RunAccountMixer(req *pb.RunAccountMixerRequest, svr

tb := ticketbuyer.New(wallet)

// Set ticketbuyerV2 config
// Set ticketbuyer config
tb.AccessConfig(func(c *ticketbuyer.Config) {
c.Mixing = req.CsppServer != ""
c.MixedAccountBranch = req.MixedAccountBranch
Expand Down Expand Up @@ -2645,16 +2645,16 @@ func (t *accountMixerServer) checkReady() bool {
return t.ready.Load() != 0
}

// StartTicketBuyerV2Service starts the TicketBuyerV2Service.
func StartTicketBuyerV2Service(server *grpc.Server, loader *loader.Loader) {
ticketBuyerV2Service.loader = loader
if ticketBuyerV2Service.ready.Swap(1) != 0 {
// StartTicketBuyerService starts the TicketBuyerService.
func StartTicketBuyerService(server *grpc.Server, loader *loader.Loader) {
ticketBuyerService.loader = loader
if ticketBuyerService.ready.Swap(1) != 0 {
panic("service already started")
}
}

// StartTicketBuyer starts the automatic ticket buyer for the v2 service.
func (t *ticketbuyerV2Server) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr pb.TicketBuyerV2Service_RunTicketBuyerServer) error {
// RunTicketBuyer starts the automatic ticket buyer.
func (t *ticketbuyerServer) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr pb.TicketBuyerService_RunTicketBuyerServer) error {
wallet, ok := t.loader.LoadedWallet()
if !ok {
return status.Errorf(codes.FailedPrecondition, "Wallet has not been loaded")
Expand Down Expand Up @@ -2712,7 +2712,7 @@ func (t *ticketbuyerV2Server) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr
}
vspClient, err = loader.VSP(cfg)
if err != nil {
return status.Errorf(codes.Unknown, "TicketBuyerV3 instance failed to start. Error: %v", err)
return status.Errorf(codes.Unknown, "TicketBuyer instance failed to start. Error: %v", err)
}
}
if req.BalanceToMaintain < 0 {
Expand Down Expand Up @@ -2758,7 +2758,7 @@ func (t *ticketbuyerV2Server) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr
limit := int(req.Limit)

tb := ticketbuyer.New(wallet)
// Set ticketbuyerV2 config
// Set ticketbuyer config
tb.AccessConfig(func(c *ticketbuyer.Config) {
c.BuyTickets = true
c.Account = req.Account
Expand Down Expand Up @@ -2795,15 +2795,15 @@ func (t *ticketbuyerV2Server) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr
err = tb.Run(svr.Context(), req.Passphrase)
if err != nil {
if svr.Context().Err() != nil {
return status.Errorf(codes.Canceled, "TicketBuyerV2 instance canceled, account number: %v", req.Account)
return status.Errorf(codes.Canceled, "TicketBuyer instance canceled, account number: %v", req.Account)
}
return status.Errorf(codes.Unknown, "TicketBuyerV2 instance errored: %v", err)
return status.Errorf(codes.Unknown, "TicketBuyer instance errored: %v", err)
}

return nil
}

func (t *ticketbuyerV2Server) checkReady() bool {
func (t *ticketbuyerServer) checkReady() bool {
return t.ready.Load() != 0
}

Expand Down Expand Up @@ -4203,7 +4203,7 @@ func (s *walletServer) SyncVSPFailedTickets(ctx context.Context, req *pb.SyncVSP
}
vspClient, err := loader.VSP(cfg)
if err != nil {
return nil, status.Errorf(codes.Unknown, "TicketBuyerV3 instance failed to start. Error: %v", err)
return nil, status.Errorf(codes.Unknown, "TicketBuyer instance failed to start. Error: %v", err)
}

// Process tickets fee if needed.
Expand Down
2 changes: 1 addition & 1 deletion rpc/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ service WalletLoaderService {
service AccountMixerService {
rpc RunAccountMixer (RunAccountMixerRequest) returns (stream RunAccountMixerResponse);
}
service TicketBuyerV2Service {
service TicketBuyerService {
rpc RunTicketBuyer (RunTicketBuyerRequest) returns (stream RunTicketBuyerResponse);
}

Expand Down
12 changes: 6 additions & 6 deletions rpc/documentation/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ existing wallet.
- [`WalletLoaderService`](#walletloaderservice)
- [`WalletService`](#walletservice)
- [`SeedService`](#seedservice)
- [`TicketBuyerV2Service`](#ticketbuyerv2service)
- [`TicketBuyerService`](#ticketbuyerservice)
- [`AgendaService`](#agendaservice)
- [`VotingService`](#votingservice)
- [`MessageVerificationService`](#messageverificationservice)
Expand Down Expand Up @@ -2788,10 +2788,10 @@ The user input can be either a hexadecimal string or a mnemonic word list.

- `InvalidArgument`: The input is invalid.

## `TicketBuyerV2Service`
## `TicketBuyerService`

The `TicketBuyerV2Service` service provides RPC clients with the ability to
launch the V2 ticket buyer.
The `TicketBuyerService` service provides RPC clients with the ability to
launch the ticket buyer.

**Methods:**

Expand All @@ -2801,7 +2801,7 @@ launch the V2 ticket buyer.

#### `RunTicketBuyer`

The `RunTicketBuyer` starts a new V2 ticket buyer for the specified account.
The `RunTicketBuyer` starts a new ticket buyer for the specified account.
The users may specify a balance to maintain as well as various settings for purchasing tickets for stakepools.

**Request:** `RunTicketBuyerRequest`
Expand Down Expand Up @@ -2835,7 +2835,7 @@ The users may specify a balance to maintain as well as various settings for purc
## `AccountMixerService`

The `AccountMixerService` service provides RPC clients with the ability to
launch the V2 ticket buyer.
launch the ticket buyer.

**Methods:**

Expand Down
Loading

0 comments on commit adf2fa8

Please sign in to comment.