github.com/decred/politeia@v1.4.0/politeiawww/cmd/politeiavoter/params.go (about)

     1  // Copyright (c) 2013-2014 The btcsuite developers
     2  // Copyright (c) 2015-2019 The Decred developers
     3  // Use of this source code is governed by an ISC
     4  // license that can be found in the LICENSE file.
     5  
     6  package main
     7  
     8  import (
     9  	"github.com/decred/dcrd/chaincfg/v3"
    10  	"github.com/decred/dcrd/wire"
    11  )
    12  
    13  // activeNetParams is a pointer to the parameters specific to the
    14  // currently active decred network.
    15  var activeNetParams = &mainNetParams
    16  
    17  // params is used to group parameters for various networks such as the main
    18  // network and test networks.
    19  type params struct {
    20  	*chaincfg.Params
    21  	WalletRPCServerPort string
    22  }
    23  
    24  // mainNetParams contains parameters specific to the main network
    25  // (wire.MainNet).  NOTE: The RPC port is intentionally different than the
    26  // reference implementation because dcrd does not handle wallet requests.  The
    27  // separate wallet process listens on the well-known port and forwards requests
    28  // it does not handle on to dcrd.  This approach allows the wallet process
    29  // to emulate the full reference implementation RPC API.
    30  var mainNetParams = params{
    31  	Params:              chaincfg.MainNetParams(),
    32  	WalletRPCServerPort: "9111",
    33  }
    34  
    35  // testNet3Params contains parameters specific to the test network (version 0)
    36  // (wire.TestNet).  NOTE: The RPC port is intentionally different than the
    37  // reference implementation - see the mainNetParams comment for details.
    38  
    39  var testNet3Params = params{
    40  	Params:              chaincfg.TestNet3Params(),
    41  	WalletRPCServerPort: "19111",
    42  }
    43  
    44  // netName returns the name used when referring to a decred network.  At the
    45  // time of writing, dcrd currently places blocks for testnet version 0 in the
    46  // data and log directory "testnet", which does not match the Name field of the
    47  // chaincfg parameters.  This function can be used to override this directory name
    48  // as "testnet" when the passed active network matches wire.TestNet.
    49  //
    50  // A proper upgrade to move the data and log directories for this network to
    51  // "testnet" is planned for the future, at which point this function can be
    52  // removed and the network parameter's name used instead.
    53  func netName(chainParams *params) string {
    54  	switch chainParams.Net {
    55  	case wire.TestNet3:
    56  		return "testnet3"
    57  	default:
    58  		return chainParams.Name
    59  	}
    60  }