github.com/decred/politeia@v1.4.0/politeiawww/cmd/pictl/cmdvotetimestamps.go (about)

     1  // Copyright (c) 2020-2021 The Decred developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	tkv1 "github.com/decred/politeia/politeiawww/api/ticketvote/v1"
     9  	pclient "github.com/decred/politeia/politeiawww/client"
    10  )
    11  
    12  // cmdVoteTimestamps retrieves the timestamps for a politeiawww ticket vote.
    13  type cmdVoteTimestamps struct {
    14  	Args struct {
    15  		Token     string `positional-arg-name:"token" required:"true"`
    16  		VotesPage uint32 `positional-arg-name:"votespage" optional:"true"`
    17  	} `positional-args:"true"`
    18  }
    19  
    20  // Execute executes the cmdVoteTimestamps command.
    21  //
    22  // This function satisfies the go-flags Commander interface.
    23  func (c *cmdVoteTimestamps) Execute(args []string) error {
    24  	// Setup client
    25  	opts := pclient.Opts{
    26  		HTTPSCert:  cfg.HTTPSCert,
    27  		Cookies:    cfg.Cookies,
    28  		HeaderCSRF: cfg.CSRF,
    29  		Verbose:    cfg.Verbose,
    30  		RawJSON:    cfg.RawJSON,
    31  	}
    32  	pc, err := pclient.New(cfg.Host, opts)
    33  	if err != nil {
    34  		return err
    35  	}
    36  
    37  	// Get timestamps
    38  	t := tkv1.Timestamps{
    39  		Token:     c.Args.Token,
    40  		VotesPage: c.Args.VotesPage,
    41  	}
    42  	tr, err := pc.TicketVoteTimestamps(t)
    43  	if err != nil {
    44  		return err
    45  	}
    46  
    47  	// Verify timestamps
    48  	return pclient.TicketVoteTimestampsVerify(*tr)
    49  }
    50  
    51  // voteTimestampsHelpMsg is printed to stdout by the help command.
    52  const voteTimestampsHelpMsg = `votetimestamps "token" votepage
    53  
    54  Request the timestamps for ticket vote data.
    55  
    56  If no votes page number is provided then the vote authorization and vote
    57  details timestamps will be returned. If a votes page number is provided then
    58  the specified page of votes will be returned.
    59  
    60  Arguments:
    61  1. token     (string, required) Record token.
    62  2. votepage  (uint32, optional) Page number for cast vote timestamps. 
    63  `