lbcd/params.go
Dave Collins 629a1c9d06 Rework the data path and db type handling.
This commit modifies the way the data paths are handled.  Since there will
ultimately be more data associated with each network than just the block
database, the data path has been modified to be "namespaced" based on the
network.  This allows all data associated with a specific network to
simply use the data path without having to worry about conflicts with data
from other networks.

In addition, this commit renames the block database to "blocks" plus a
suffix which denotes the database type.  This prevents issues that would
otherwise arise if the user decides to use a different database type and
a file/folder with the same name already eixsts but is of the old database
type.  For most users this won't matter, but it does provide nice
properties for testing and development as well since it makes it easy to
go back and forth between database types.

This commit also includes code to upgrade the old database paths to the
new ones so the change is seamless for the user.

Finally, bump the version to 0.2.0.
2013-09-15 14:25:32 -05:00

101 lines
3 KiB
Go

// Copyright (c) 2013 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
import (
"github.com/conformal/btcchain"
"github.com/conformal/btcwire"
"math/big"
)
// activeNetParams is a pointer to the parameters specific to the
// currently active bitcoin network.
var activeNetParams = netParams(defaultBtcnet)
// params is used to group parameters for various networks such as the main
// network and test networks.
type params struct {
netName string
btcnet btcwire.BitcoinNet
genesisBlock *btcwire.MsgBlock
genesisHash *btcwire.ShaHash
powLimit *big.Int
powLimitBits uint32
peerPort string
listenPort string
rpcPort string
dnsSeeds []string
}
// mainNetParams contains parameters specific to the main network
// (btcwire.MainNet).
var mainNetParams = params{
netName: "mainnet",
btcnet: btcwire.MainNet,
genesisBlock: btcchain.ChainParams(btcwire.MainNet).GenesisBlock,
genesisHash: btcchain.ChainParams(btcwire.MainNet).GenesisHash,
powLimit: btcchain.ChainParams(btcwire.MainNet).PowLimit,
powLimitBits: btcchain.ChainParams(btcwire.MainNet).PowLimitBits,
listenPort: btcwire.MainPort,
peerPort: btcwire.MainPort,
rpcPort: "8332",
dnsSeeds: []string{
"seed.bitcoin.sipa.be",
"dnsseed.bluematt.me",
"dnsseed.bitcoin.dashjr.org",
"bitseed.xf2.org",
},
}
// regressionParams contains parameters specific to the regression test network
// (btcwire.TestNet).
var regressionParams = params{
netName: "regtest",
btcnet: btcwire.TestNet,
genesisBlock: btcchain.ChainParams(btcwire.TestNet).GenesisBlock,
genesisHash: btcchain.ChainParams(btcwire.TestNet).GenesisHash,
powLimit: btcchain.ChainParams(btcwire.TestNet).PowLimit,
powLimitBits: btcchain.ChainParams(btcwire.TestNet).PowLimitBits,
listenPort: btcwire.RegressionTestPort,
peerPort: btcwire.TestNetPort,
rpcPort: "18332",
dnsSeeds: []string{},
}
// testNet3Params contains parameters specific to the test network (version 3)
// (btcwire.TestNet3).
var testNet3Params = params{
netName: "testnet",
btcnet: btcwire.TestNet3,
genesisBlock: btcchain.ChainParams(btcwire.TestNet3).GenesisBlock,
genesisHash: btcchain.ChainParams(btcwire.TestNet3).GenesisHash,
powLimit: btcchain.ChainParams(btcwire.TestNet3).PowLimit,
powLimitBits: btcchain.ChainParams(btcwire.TestNet3).PowLimitBits,
listenPort: btcwire.TestNetPort,
peerPort: btcwire.TestNetPort,
rpcPort: "18332",
dnsSeeds: []string{
"testnet-seed.bitcoin.petertodd.org",
"testnet-seed.bluematt.me",
},
}
// netParams returns parameters specific to the passed bitcoin network.
func netParams(btcnet btcwire.BitcoinNet) *params {
switch btcnet {
case btcwire.TestNet:
return &regressionParams
case btcwire.TestNet3:
return &testNet3Params
// Return main net by default.
case btcwire.MainNet:
fallthrough
default:
return &mainNetParams
}
}