mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-05 21:56:50 +00:00
[NOD-360] Renamed TestNet3 to TestNet. (#426)
This commit is contained in:
parent
d99af7424c
commit
13cf1f7715
4
CHANGES
4
CHANGES
@ -513,7 +513,7 @@ Changes in 0.8.0-beta (Sun May 25 2014)
|
||||
- Reduce max bytes allowed for a standard nulldata transaction to 40 for
|
||||
compatibility with the reference client
|
||||
- Introduce a new btcnet package which houses all of the network params
|
||||
for each network (mainnet, testnet3, regtest) to ultimately enable
|
||||
for each network (mainnet, testnet, regtest) to ultimately enable
|
||||
easier addition and tweaking of networks without needing to change
|
||||
several packages
|
||||
- Fix several script discrepancies found by reference client test data
|
||||
@ -530,7 +530,7 @@ Changes in 0.8.0-beta (Sun May 25 2014)
|
||||
- Provide options to control block template creation settings
|
||||
- Support the getwork RPC
|
||||
- Allow address identifiers to apply to more than one network since both
|
||||
testnet3 and the regression test network unfortunately use the same
|
||||
testnet and the regression test network unfortunately use the same
|
||||
identifier
|
||||
- RPC changes:
|
||||
- Set the content type for HTTP POST RPC connections to application/json
|
||||
|
@ -110,7 +110,7 @@ func resolveNetwork(cfg *Config) error {
|
||||
activeNetParams = dagconfig.MainNetParams
|
||||
switch {
|
||||
case cfg.TestNet:
|
||||
activeNetParams = dagconfig.TestNet3Params
|
||||
activeNetParams = dagconfig.TestNetParams
|
||||
case cfg.SimNet:
|
||||
activeNetParams = dagconfig.SimNetParams
|
||||
case cfg.DevNet:
|
||||
|
@ -111,7 +111,7 @@ var (
|
||||
// allow them to change out from under the tests potentially invalidating them.
|
||||
var regressionNetParams = &dagconfig.Params{
|
||||
Name: "regtest",
|
||||
Net: wire.TestNet,
|
||||
Net: wire.RegTest,
|
||||
DefaultPort: "18444",
|
||||
|
||||
// DAG parameters
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
"github.com/daglabs/btcd/database"
|
||||
_ "github.com/daglabs/btcd/database/ffldb"
|
||||
"github.com/daglabs/btcd/util"
|
||||
"github.com/daglabs/btcd/wire"
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
)
|
||||
|
||||
@ -37,7 +36,7 @@ var (
|
||||
type config struct {
|
||||
DataDir string `short:"b" long:"datadir" description:"Location of the btcd data directory"`
|
||||
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
|
||||
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
||||
TestNet bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
DevNet bool `long:"devnet" description:"Use the development test network"`
|
||||
@ -68,24 +67,6 @@ func validDbType(dbType string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// netName returns the name used when referring to a bitcoin network. At the
|
||||
// time of writing, btcd currently places blocks for testnet version 3 in the
|
||||
// data and log directory "testnet", which does not match the Name field of the
|
||||
// dagconfig parameters. This function can be used to override this directory name
|
||||
// as "testnet" when the passed active network matches wire.TestNet3.
|
||||
//
|
||||
// A proper upgrade to move the data and log directories for this network to
|
||||
// "testnet3" is planned for the future, at which point this function can be
|
||||
// removed and the network parameter's name used instead.
|
||||
func netName(chainParams *dagconfig.Params) string {
|
||||
switch chainParams.Net {
|
||||
case wire.TestNet3:
|
||||
return "testnet"
|
||||
default:
|
||||
return chainParams.Name
|
||||
}
|
||||
}
|
||||
|
||||
// loadConfig initializes and parses the config using command line options.
|
||||
func loadConfig() (*config, []string, error) {
|
||||
// Default config.
|
||||
@ -111,9 +92,9 @@ func loadConfig() (*config, []string, error) {
|
||||
numNets := 0
|
||||
// Count number of network flags passed; assign active network params
|
||||
// while we're at it
|
||||
if cfg.TestNet3 {
|
||||
if cfg.TestNet {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.TestNet3Params
|
||||
activeNetParams = &dagconfig.TestNetParams
|
||||
}
|
||||
if cfg.RegressionTest {
|
||||
numNets++
|
||||
@ -152,7 +133,7 @@ func loadConfig() (*config, []string, error) {
|
||||
// All data is specific to a network, so namespacing the data directory
|
||||
// means each individual piece of serialized data does not have to
|
||||
// worry about changing names per network and such.
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, activeNetParams.Name)
|
||||
|
||||
// Ensure the specified block file exists.
|
||||
if !fileExists(cfg.InFile) {
|
||||
|
@ -66,7 +66,7 @@ func parseConfig() (*config, error) {
|
||||
activeNetParams = dagconfig.MainNetParams
|
||||
switch {
|
||||
case cfg.TestNet:
|
||||
activeNetParams = dagconfig.TestNet3Params
|
||||
activeNetParams = dagconfig.TestNetParams
|
||||
case cfg.SimNet:
|
||||
activeNetParams = dagconfig.SimNetParams
|
||||
case cfg.DevNet:
|
||||
|
@ -96,7 +96,7 @@ type config struct {
|
||||
Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"`
|
||||
ProxyUser string `long:"proxyuser" description:"Username for proxy server"`
|
||||
ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
|
||||
TestNet3 bool `long:"testnet" description:"Connect to testnet"`
|
||||
TestNet bool `long:"testnet" description:"Connect to testnet"`
|
||||
SimNet bool `long:"simnet" description:"Connect to the simulation test network"`
|
||||
DevNet bool `long:"devnet" description:"Connect to the development test network"`
|
||||
TLSSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"`
|
||||
@ -104,14 +104,14 @@ type config struct {
|
||||
|
||||
// normalizeAddress returns addr with the passed default port appended if
|
||||
// there is not already a port specified.
|
||||
func normalizeAddress(addr string, useTestNet3, useSimNet, useDevNet bool) string {
|
||||
func normalizeAddress(addr string, useTestNet, useSimNet, useDevNet bool) string {
|
||||
_, _, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
var defaultPort string
|
||||
switch {
|
||||
case useDevNet:
|
||||
fallthrough
|
||||
case useTestNet3:
|
||||
case useTestNet:
|
||||
defaultPort = "18334"
|
||||
case useSimNet:
|
||||
defaultPort = "18556"
|
||||
@ -226,7 +226,7 @@ func loadConfig() (*config, []string, error) {
|
||||
|
||||
// Multiple networks can't be selected simultaneously.
|
||||
numNets := 0
|
||||
if cfg.TestNet3 {
|
||||
if cfg.TestNet {
|
||||
numNets++
|
||||
}
|
||||
if cfg.SimNet {
|
||||
@ -248,7 +248,7 @@ func loadConfig() (*config, []string, error) {
|
||||
|
||||
// Add default port to RPC server based on --testnet and --simnet flags
|
||||
// if needed.
|
||||
cfg.RPCServer = normalizeAddress(cfg.RPCServer, cfg.TestNet3,
|
||||
cfg.RPCServer = normalizeAddress(cfg.RPCServer, cfg.TestNet,
|
||||
cfg.SimNet, cfg.DevNet)
|
||||
|
||||
return &cfg, remainingArgs, nil
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
"github.com/daglabs/btcd/database"
|
||||
_ "github.com/daglabs/btcd/database/ffldb"
|
||||
"github.com/daglabs/btcd/util"
|
||||
"github.com/daglabs/btcd/wire"
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
)
|
||||
|
||||
@ -38,7 +37,7 @@ var (
|
||||
type config struct {
|
||||
DataDir string `short:"b" long:"datadir" description:"Location of the btcd data directory"`
|
||||
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
|
||||
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
||||
TestNet bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
DevNet bool `long:"devnet" description:"Use the development test network"`
|
||||
@ -57,24 +56,6 @@ func validDbType(dbType string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// netName returns the name used when referring to a bitcoin network. At the
|
||||
// time of writing, btcd currently places blocks for testnet version 3 in the
|
||||
// data and log directory "testnet", which does not match the Name field of the
|
||||
// dagconfig parameters. This function can be used to override this directory name
|
||||
// as "testnet" when the passed active network matches wire.TestNet3.
|
||||
//
|
||||
// A proper upgrade to move the data and log directories for this network to
|
||||
// "testnet3" is planned for the future, at which point this function can be
|
||||
// removed and the network parameter's name used instead.
|
||||
func netName(chainParams *dagconfig.Params) string {
|
||||
switch chainParams.Net {
|
||||
case wire.TestNet3:
|
||||
return "testnet"
|
||||
default:
|
||||
return chainParams.Name
|
||||
}
|
||||
}
|
||||
|
||||
// loadConfig initializes and parses the config using command line options.
|
||||
func loadConfig() (*config, []string, error) {
|
||||
// Default config.
|
||||
@ -99,9 +80,9 @@ func loadConfig() (*config, []string, error) {
|
||||
numNets := 0
|
||||
// Count number of network flags passed; assign active network params
|
||||
// while we're at it
|
||||
if cfg.TestNet3 {
|
||||
if cfg.TestNet {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.TestNet3Params
|
||||
activeNetParams = &dagconfig.TestNetParams
|
||||
}
|
||||
if cfg.RegressionTest {
|
||||
numNets++
|
||||
@ -140,7 +121,7 @@ func loadConfig() (*config, []string, error) {
|
||||
// All data is specific to a network, so namespacing the data directory
|
||||
// means each individual piece of serialized data does not have to
|
||||
// worry about changing names per network and such.
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, activeNetParams.Name)
|
||||
|
||||
// Validate the number of candidates.
|
||||
if cfg.NumCandidates < minCandidates || cfg.NumCandidates > maxCandidates {
|
||||
|
@ -134,7 +134,7 @@ type configFlags struct {
|
||||
OnionProxyPass string `long:"onionpass" default-mask:"-" description:"Password for onion proxy server"`
|
||||
NoOnion bool `long:"noonion" description:"Disable connecting to tor hidden services"`
|
||||
TorIsolation bool `long:"torisolation" description:"Enable Tor stream isolation by randomizing user credentials for each connection."`
|
||||
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
||||
TestNet bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
DevNet bool `long:"devnet" description:"Use the development test network"`
|
||||
@ -428,9 +428,9 @@ func loadConfig() (*Config, []string, error) {
|
||||
numNets := 0
|
||||
// Count number of network flags passed; assign active network params
|
||||
// while we're at it
|
||||
if cfg.TestNet3 {
|
||||
if cfg.TestNet {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.TestNet3Params
|
||||
activeNetParams = &dagconfig.TestNetParams
|
||||
}
|
||||
if cfg.RegressionTest {
|
||||
numNets++
|
||||
|
@ -38,7 +38,7 @@ func main() {
|
||||
|
||||
// Modify active network parameters if operating on testnet.
|
||||
if *testnet {
|
||||
chainParams = &chaincfg.TestNet3Params
|
||||
chainParams = &chaincfg.TestNetParams
|
||||
}
|
||||
|
||||
// later...
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// In addition to the main Bitcoin network, which is intended for the transfer
|
||||
// of monetary value, there also exists two currently active standard networks:
|
||||
// regression test and testnet (version 3). These networks are incompatible
|
||||
// regression test and testnet. These networks are incompatible
|
||||
// with each other (each sharing a different genesis block) and software should
|
||||
// handle errors where input intended for one network is used on an application
|
||||
// instance running on a different network.
|
||||
@ -39,7 +39,7 @@
|
||||
//
|
||||
// // Modify active network parameters if operating on testnet.
|
||||
// if *testnet {
|
||||
// chainParams = &dagconfig.TestNet3Params
|
||||
// chainParams = &dagconfig.TestNetParams
|
||||
// }
|
||||
//
|
||||
// // later...
|
||||
@ -57,5 +57,5 @@
|
||||
// a new Params struct may be created which defines the parameters for the
|
||||
// non-standard network. As a general rule of thumb, all network parameters
|
||||
// should be unique to the network, but parameter collisions can still occur
|
||||
// (unfortunately, this is the case with regtest and testnet3 sharing magics).
|
||||
// (unfortunately, this is the case with regtest and testnet sharing magics).
|
||||
package dagconfig
|
||||
|
@ -36,7 +36,7 @@ var genesisTxPayload = []byte{
|
||||
}
|
||||
|
||||
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
||||
// the main network, regression test network, and test network (version 3).
|
||||
// the main network, regression test network, and test network.
|
||||
var genesisCoinbaseTx = wire.NewSubnetworkMsgTx(1, genesisTxIns, genesisTxOuts, subnetworkid.SubnetworkIDCoinbase, 0, genesisTxPayload)
|
||||
|
||||
// genesisHash is the hash of the first block in the block DAG for the main
|
||||
@ -86,18 +86,18 @@ var regTestGenesisMerkleRoot = genesisMerkleRoot
|
||||
// as the public transaction ledger for the regression test network.
|
||||
var regTestGenesisBlock = genesisBlock
|
||||
|
||||
// testNet3GenesisHash is the hash of the first block in the block chain for the
|
||||
// test network (version 3).
|
||||
var testNet3GenesisHash = genesisHash
|
||||
// testNetGenesisHash is the hash of the first block in the block chain for the
|
||||
// test network.
|
||||
var testNetGenesisHash = genesisHash
|
||||
|
||||
// testNet3GenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
// block for the test network (version 3). It is the same as the merkle root
|
||||
// for the main network.
|
||||
var testNet3GenesisMerkleRoot = genesisMerkleRoot
|
||||
// testNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
// block for the test network. It is the same as the merkle root for the main
|
||||
// network.
|
||||
var testNetGenesisMerkleRoot = genesisMerkleRoot
|
||||
|
||||
// testNet3GenesisBlock defines the genesis block of the block chain which
|
||||
// serves as the public transaction ledger for the test network (version 3).
|
||||
var testNet3GenesisBlock = genesisBlock
|
||||
// testNetGenesisBlock defines the genesis block of the block chain which
|
||||
// serves as the public transaction ledger for the test network.
|
||||
var testNetGenesisBlock = genesisBlock
|
||||
|
||||
// simNetGenesisHash is the hash of the first block in the block chain for the
|
||||
// simulation test network.
|
||||
@ -113,7 +113,7 @@ var simNetGenesisMerkleRoot = genesisMerkleRoot
|
||||
var simNetGenesisBlock = genesisBlock
|
||||
|
||||
// devNetGenesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
||||
// the main network, regression test network, and test network (version 3).
|
||||
// the main network, regression test network, and test network.
|
||||
var devNetGenesisCoinbaseTx = genesisCoinbaseTx
|
||||
|
||||
// devGenesisHash is the hash of the first block in the block DAG for the development
|
||||
|
@ -64,30 +64,30 @@ func TestRegTestGenesisBlock(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestTestNet3GenesisBlock tests the genesis block of the test network (version
|
||||
// 3) for validity by checking the encoded bytes and hashes.
|
||||
func TestTestNet3GenesisBlock(t *testing.T) {
|
||||
// TestTestNetGenesisBlock tests the genesis block of the test network for
|
||||
// validity by checking the encoded bytes and hashes.
|
||||
func TestTestNetGenesisBlock(t *testing.T) {
|
||||
// Encode the genesis block to raw bytes.
|
||||
var buf bytes.Buffer
|
||||
err := TestNet3Params.GenesisBlock.Serialize(&buf)
|
||||
err := TestNetParams.GenesisBlock.Serialize(&buf)
|
||||
if err != nil {
|
||||
t.Fatalf("TestTestNet3GenesisBlock: %v", err)
|
||||
t.Fatalf("TestTestNetGenesisBlock: %v", err)
|
||||
}
|
||||
|
||||
// Ensure the encoded block matches the expected bytes.
|
||||
if !bytes.Equal(buf.Bytes(), testNet3GenesisBlockBytes) {
|
||||
t.Fatalf("TestTestNet3GenesisBlock: Genesis block does not "+
|
||||
if !bytes.Equal(buf.Bytes(), testNetGenesisBlockBytes) {
|
||||
t.Fatalf("TestTestNetGenesisBlock: Genesis block does not "+
|
||||
"appear valid - got %v, want %v",
|
||||
spew.Sdump(buf.Bytes()),
|
||||
spew.Sdump(testNet3GenesisBlockBytes))
|
||||
spew.Sdump(testNetGenesisBlockBytes))
|
||||
}
|
||||
|
||||
// Check hash of the block against expected hash.
|
||||
hash := TestNet3Params.GenesisBlock.BlockHash()
|
||||
if !TestNet3Params.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestTestNet3GenesisBlock: Genesis block hash does "+
|
||||
hash := TestNetParams.GenesisBlock.BlockHash()
|
||||
if !TestNetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestTestNetGenesisBlock: Genesis block hash does "+
|
||||
"not appear valid - got %v, want %v", spew.Sdump(hash),
|
||||
spew.Sdump(TestNet3Params.GenesisHash))
|
||||
spew.Sdump(TestNetParams.GenesisHash))
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,9 +145,9 @@ var genesisBlockBytes = []byte{
|
||||
// the regression test network as of protocol version 60002.
|
||||
var regTestGenesisBlockBytes = genesisBlockBytes
|
||||
|
||||
// testNet3GenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the test network (version 3) as of protocol version 60002.
|
||||
var testNet3GenesisBlockBytes = genesisBlockBytes
|
||||
// testNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the test network as of protocol version 60002.
|
||||
var testNetGenesisBlockBytes = genesisBlockBytes
|
||||
|
||||
// simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the simulation test network as of protocol version 70002.
|
||||
|
@ -20,29 +20,28 @@ import (
|
||||
// These variables are the chain proof-of-work limit parameters for each default
|
||||
// network.
|
||||
var (
|
||||
// bigOne is 1 represented as a big.Int. It is defined here to avoid
|
||||
// bigOne is 1 represented as a big.Int. It is defined here to avoid
|
||||
// the overhead of creating it multiple times.
|
||||
bigOne = big.NewInt(1)
|
||||
|
||||
// mainPowMax is the highest proof of work value a Bitcoin block can
|
||||
// have for the main network. It is the value 2^255 - 1.
|
||||
// have for the main network. It is the value 2^255 - 1.
|
||||
mainPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// regressionPowMax is the highest proof of work value a Bitcoin block
|
||||
// can have for the regression test network. It is the value 2^255 - 1.
|
||||
// can have for the regression test network. It is the value 2^255 - 1.
|
||||
regressionPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// testNet3PowMax is the highest proof of work value a Bitcoin block
|
||||
// can have for the test network (version 3). It is the value
|
||||
// 2^255 - 1.
|
||||
testNet3PowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
// testNetPowMax is the highest proof of work value a Bitcoin block
|
||||
// can have for the test network. It is the value 2^255 - 1.
|
||||
testNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// simNetPowMax is the highest proof of work value a Bitcoin block
|
||||
// can have for the simulation test network. It is the value 2^255 - 1.
|
||||
// can have for the simulation test network. It is the value 2^255 - 1.
|
||||
simNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// devNetPowMax is the highest proof of work value a Bitcoin block
|
||||
// can have for the development network. It is the value
|
||||
// can have for the development network. It is the value
|
||||
// 2^239 - 1.
|
||||
devNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 239), bigOne)
|
||||
)
|
||||
@ -254,7 +253,7 @@ var MainNetParams = Params{
|
||||
var RegressionNetParams = Params{
|
||||
K: phantomK,
|
||||
Name: "regtest",
|
||||
Net: wire.TestNet,
|
||||
Net: wire.RegTest,
|
||||
RPCPort: "18334",
|
||||
DefaultPort: "18444",
|
||||
DNSSeeds: []string{},
|
||||
@ -308,21 +307,19 @@ var RegressionNetParams = Params{
|
||||
HDCoinType: 1,
|
||||
}
|
||||
|
||||
// TestNet3Params defines the network parameters for the test Bitcoin network
|
||||
// (version 3). Not to be confused with the regression test network, this
|
||||
// network is sometimes simply called "testnet".
|
||||
var TestNet3Params = Params{
|
||||
// TestNetParams defines the network parameters for the test Bitcoin network.
|
||||
var TestNetParams = Params{
|
||||
K: phantomK,
|
||||
Name: "testnet3",
|
||||
Net: wire.TestNet3,
|
||||
Name: "testnet",
|
||||
Net: wire.TestNet,
|
||||
RPCPort: "18334",
|
||||
DefaultPort: "18333",
|
||||
DNSSeeds: []string{},
|
||||
|
||||
// DAG parameters
|
||||
GenesisBlock: &testNet3GenesisBlock,
|
||||
GenesisHash: &testNet3GenesisHash,
|
||||
PowMax: testNet3PowMax,
|
||||
GenesisBlock: &testNetGenesisBlock,
|
||||
GenesisHash: &testNetGenesisHash,
|
||||
PowMax: testNetPowMax,
|
||||
BlockCoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 210000,
|
||||
TargetTimePerBlock: time.Second * 1, // 1 second
|
||||
@ -547,7 +544,7 @@ func newHashFromStr(hexStr string) *daghash.Hash {
|
||||
func init() {
|
||||
// Register all default networks when the package is initialized.
|
||||
mustRegister(&MainNetParams)
|
||||
mustRegister(&TestNet3Params)
|
||||
mustRegister(&TestNetParams)
|
||||
mustRegister(&RegressionNetParams)
|
||||
mustRegister(&SimNetParams)
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ func TestRegister(t *testing.T) {
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
name: "duplicate testnet3",
|
||||
params: &TestNet3Params,
|
||||
name: "duplicate testnet",
|
||||
params: &TestNetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
@ -69,8 +69,8 @@ func TestRegister(t *testing.T) {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
priv: TestNet3Params.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestNet3Params.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: TestNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@ -128,8 +128,8 @@ func TestRegister(t *testing.T) {
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
name: "duplicate testnet3",
|
||||
params: &TestNet3Params,
|
||||
name: "duplicate testnet",
|
||||
params: &TestNetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
@ -150,8 +150,8 @@ func TestRegister(t *testing.T) {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
priv: TestNet3Params.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestNet3Params.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: TestNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
"github.com/daglabs/btcd/database"
|
||||
_ "github.com/daglabs/btcd/database/ffldb"
|
||||
"github.com/daglabs/btcd/util"
|
||||
"github.com/daglabs/btcd/wire"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -34,7 +33,7 @@ var (
|
||||
type config struct {
|
||||
DataDir string `short:"b" long:"datadir" description:"Location of the btcd data directory"`
|
||||
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
|
||||
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
||||
TestNet bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
DevNet bool `long:"devnet" description:"Use the development test network"`
|
||||
@ -61,24 +60,6 @@ func validDbType(dbType string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// netName returns the name used when referring to a bitcoin network. At the
|
||||
// time of writing, btcd currently places blocks for testnet version 3 in the
|
||||
// data and log directory "testnet", which does not match the Name field of the
|
||||
// dagconfig parameters. This function can be used to override this directory name
|
||||
// as "testnet" when the passed active network matches wire.TestNet3.
|
||||
//
|
||||
// A proper upgrade to move the data and log directories for this network to
|
||||
// "testnet3" is planned for the future, at which point this function can be
|
||||
// removed and the network parameter's name used instead.
|
||||
func netName(chainParams *dagconfig.Params) string {
|
||||
switch chainParams.Net {
|
||||
case wire.TestNet3:
|
||||
return "testnet"
|
||||
default:
|
||||
return chainParams.Name
|
||||
}
|
||||
}
|
||||
|
||||
// setupGlobalConfig examine the global configuration options for any conditions
|
||||
// which are invalid as well as performs any addition setup necessary after the
|
||||
// initial parse.
|
||||
@ -87,9 +68,9 @@ func setupGlobalConfig() error {
|
||||
// Count number of network flags passed; assign active network params
|
||||
// while we're at it
|
||||
numNets := 0
|
||||
if cfg.TestNet3 {
|
||||
if cfg.TestNet {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.TestNet3Params
|
||||
activeNetParams = &dagconfig.TestNetParams
|
||||
}
|
||||
if cfg.RegressionTest {
|
||||
numNets++
|
||||
@ -121,7 +102,7 @@ func setupGlobalConfig() error {
|
||||
// All data is specific to a network, so namespacing the data directory
|
||||
// means each individual piece of serialized data does not have to
|
||||
// worry about changing names per network and such.
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, activeNetParams.Name)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ func loadConfig() (*config, error) {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return nil, err
|
||||
} else if cfg.TestNet {
|
||||
activeNetParams = &dagconfig.TestNet3Params
|
||||
activeNetParams = &dagconfig.TestNetParams
|
||||
} else if cfg.DevNet {
|
||||
activeNetParams = &dagconfig.DevNetParams
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ The following is an overview of the RPC methods which are implemented by btcd, b
|
||||
|Parameters|None|
|
||||
|Description|Get bitcoin network btcd is running on.|
|
||||
|Returns|numeric|
|
||||
|Example Return|`3652501241` (mainnet)<br />`118034699` (testnet3)|
|
||||
|Example Return|`3652501241` (mainnet)<br />`118034699` (testnet)|
|
||||
[Return to Overview](#ExtMethodOverview)<br />
|
||||
|
||||
***
|
||||
|
@ -109,9 +109,9 @@ func New(activeNet *dagconfig.Params, handlers *rpcclient.NotificationHandlers,
|
||||
switch activeNet.Net {
|
||||
case wire.MainNet:
|
||||
// No extra flags since mainnet is the default
|
||||
case wire.TestNet3:
|
||||
extraArgs = append(extraArgs, "--testnet")
|
||||
case wire.TestNet:
|
||||
extraArgs = append(extraArgs, "--testnet")
|
||||
case wire.RegTest:
|
||||
extraArgs = append(extraArgs, "--regtest")
|
||||
case wire.SimNet:
|
||||
extraArgs = append(extraArgs, "--simnet")
|
||||
|
@ -1146,7 +1146,7 @@ func (p *Peer) writeMessage(msg wire.Message) error {
|
||||
// to send malformed messages without the peer being disconnected.
|
||||
func (p *Peer) isAllowedReadError(err error) bool {
|
||||
// Only allow read errors in regression test mode.
|
||||
if p.cfg.DAGParams.Net != wire.TestNet {
|
||||
if p.cfg.DAGParams.Net != wire.RegTest {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -2064,7 +2064,7 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer {
|
||||
|
||||
// Set the DAG parameters to testnet if the caller did not specify any.
|
||||
if cfg.DAGParams == nil {
|
||||
cfg.DAGParams = &dagconfig.TestNet3Params
|
||||
cfg.DAGParams = &dagconfig.TestNetParams
|
||||
}
|
||||
|
||||
p := Peer{
|
||||
|
@ -17,7 +17,7 @@ func handleGetInfo(s *Server, cmd interface{}, closeChan <-chan struct{}) (inter
|
||||
Connections: s.cfg.ConnMgr.ConnectedCount(),
|
||||
Proxy: config.MainConfig().Proxy,
|
||||
Difficulty: getDifficultyRatio(s.cfg.DAG.CurrentBits(), s.cfg.DAGParams),
|
||||
TestNet: config.MainConfig().TestNet3,
|
||||
TestNet: config.MainConfig().TestNet,
|
||||
DevNet: config.MainConfig().DevNet,
|
||||
RelayFee: config.MainConfig().MinRelayTxFee.ToBTC(),
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func handleGetMiningInfo(s *Server, cmd interface{}, closeChan <-chan struct{})
|
||||
HashesPerSec: int64(s.cfg.CPUMiner.HashesPerSecond()),
|
||||
NetworkHashPS: networkHashesPerSec,
|
||||
PooledTx: uint64(s.cfg.TxMemPool.Count()),
|
||||
TestNet: config.MainConfig().TestNet3,
|
||||
TestNet: config.MainConfig().TestNet,
|
||||
DevNet: config.MainConfig().DevNet,
|
||||
}
|
||||
return &result, nil
|
||||
|
@ -76,7 +76,7 @@ func signAndCheck(msg string, tx *wire.MsgTx, idx int, scriptPubKey []byte,
|
||||
hashType SigHashType, kdb KeyDB, sdb ScriptDB,
|
||||
previousScript []byte) error {
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNet3Params, tx, idx,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams, tx, idx,
|
||||
scriptPubKey, hashType, kdb, sdb, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to sign output %s: %v", msg, err)
|
||||
@ -199,7 +199,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
"for %s: %v", msg, err)
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -212,7 +212,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -298,7 +298,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
"for %s: %v", msg, err)
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
@ -311,7 +311,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
@ -432,7 +432,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -447,7 +447,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -569,7 +569,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
@ -584,7 +584,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
|
@ -64,7 +64,7 @@ func (w *WIF) IsForNet(privateKeyID byte) bool {
|
||||
// sequence:
|
||||
//
|
||||
// * 1 byte to identify the network, must be 0x80 for mainnet or 0xef for
|
||||
// either testnet3 or the regression test network
|
||||
// either testnet or the regression test network
|
||||
// * 32 bytes of a binary-encoded, big-endian, zero-padded private key
|
||||
// * Optional 1 byte (equal to 0x01) if the address being imported or exported
|
||||
// was created by taking the RIPEMD160 after SHA256 hash of a serialized
|
||||
|
@ -29,7 +29,7 @@ func TestEncodeDecodeWIF(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wif2, err := NewWIF(priv2, dagconfig.TestNet3Params.PrivateKeyID, true)
|
||||
wif2, err := NewWIF(priv2, dagconfig.TestNetParams.PrivateKeyID, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
||||
// the main network, regression test network, and test network (version 3).
|
||||
// the main network, regression test network, and test network.
|
||||
var genesisCoinbaseTxIns = []*TxIn{
|
||||
{
|
||||
PreviousOutpoint: Outpoint{
|
||||
|
@ -84,8 +84,8 @@ message and which bitcoin network the message applies to. This package provides
|
||||
the following constants:
|
||||
|
||||
wire.MainNet
|
||||
wire.TestNet (Regression test network)
|
||||
wire.TestNet3 (Test network version 3)
|
||||
wire.RegTest (Regression test network)
|
||||
wire.TestNet (Test network)
|
||||
wire.SimNet (Simulation test network)
|
||||
|
||||
Determining Message Type
|
||||
|
@ -208,8 +208,8 @@ func TestReadMessageWireErrors(t *testing.T) {
|
||||
testErr.Error(), wantErr)
|
||||
}
|
||||
|
||||
// Wire encoded bytes for main and testnet3 networks magic identifiers.
|
||||
testNet3Bytes := makeHeader(TestNet3, "", 0, 0)
|
||||
// Wire encoded bytes for main and testnet networks magic identifiers.
|
||||
testNetBytes := makeHeader(TestNet, "", 0, 0)
|
||||
|
||||
// Wire encoded bytes for a message that exceeds max overall message
|
||||
// length.
|
||||
@ -267,12 +267,12 @@ func TestReadMessageWireErrors(t *testing.T) {
|
||||
0,
|
||||
},
|
||||
|
||||
// Wrong network. Want MainNet, but giving TestNet3.
|
||||
// Wrong network. Want MainNet, but giving TestNet.
|
||||
{
|
||||
testNet3Bytes,
|
||||
testNetBytes,
|
||||
pver,
|
||||
btcnet,
|
||||
len(testNet3Bytes),
|
||||
len(testNetBytes),
|
||||
&MessageError{},
|
||||
24,
|
||||
},
|
||||
|
@ -100,11 +100,11 @@ const (
|
||||
// MainNet represents the main bitcoin network.
|
||||
MainNet BitcoinNet = 0xd9b4bef9
|
||||
|
||||
// TestNet represents the regression test network.
|
||||
TestNet BitcoinNet = 0xdab5bffa
|
||||
// TestNet represents the test network.
|
||||
TestNet BitcoinNet = 0x0709110b
|
||||
|
||||
// TestNet3 represents the test network (version 3).
|
||||
TestNet3 BitcoinNet = 0x0709110b
|
||||
// RegTest represents the regression test network.
|
||||
RegTest BitcoinNet = 0xdab5bffa
|
||||
|
||||
// SimNet represents the simulation test network.
|
||||
SimNet BitcoinNet = 0x12141c16
|
||||
@ -116,11 +116,11 @@ const (
|
||||
// bnStrings is a map of bitcoin networks back to their constant names for
|
||||
// pretty printing.
|
||||
var bnStrings = map[BitcoinNet]string{
|
||||
MainNet: "MainNet",
|
||||
TestNet: "TestNet",
|
||||
TestNet3: "TestNet3",
|
||||
SimNet: "SimNet",
|
||||
DevNet: "DevNet",
|
||||
MainNet: "MainNet",
|
||||
TestNet: "TestNet",
|
||||
RegTest: "RegTest",
|
||||
SimNet: "SimNet",
|
||||
DevNet: "DevNet",
|
||||
}
|
||||
|
||||
// String returns the BitcoinNet in human-readable form.
|
||||
|
@ -40,8 +40,8 @@ func TestBitcoinNetStringer(t *testing.T) {
|
||||
want string
|
||||
}{
|
||||
{MainNet, "MainNet"},
|
||||
{RegTest, "RegTest"},
|
||||
{TestNet, "TestNet"},
|
||||
{TestNet3, "TestNet3"},
|
||||
{SimNet, "SimNet"},
|
||||
{0xffffffff, "Unknown BitcoinNet (4294967295)"},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user