mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
This resurrects the regression test network that was removed before initial launch although it really should not have been. The simulation test network and the regression test network do not serve the same purpose. Specifically, the regression test network is intended for unit tests, RPC server tests, and consensus tests. On the other hand, the simulation test network is intended for private use within a group of individuals doing simulation testing and full integration tests between different applications such as wallets, voting service providers, mining pools, block explorers, and other services that build on Decred. Keeping the concerns separate will allow the simulation test network to be modified in ways such as activating consensus changes that have been successfully voted into mainnet without also needing to vote them in on the simulation test network while still preserving the ability for the unit tests to properly test the voting semantics and handling to help prevent regressions. In addition to resurrecting the regression test network, this also fully fleshes out new values for the various addresses prefixes (Rk, Rs, Re, etc), HD key prefixes (rprv, rpub), and treasury multisig details. As a part of resurrecting the network, a new CLI flag `--regnet` is added to allow the RPC test harness connect to a running instance, the areas of the code which involve votes have been modified to allow the votes to apply to the new network, and tests have been added to the relevant modules. This bumps the affected module versions as follows: - github.com/decred/dcrd/wire@v1.2.0 - github.com/decred/dcrd/chaincfg@v1.2.0 - github.com/decred/dcrd/dcrutil@v1.2.0 - github.com/decred/dcrd/hdkeychain@v1.1.1 The blockchain module is also affected, but since its version has already been bumped since the last release tag, it is not bumped again. Finally, this does not include switching unit tests or the RPC test harness over the new network since that will be done in a separate commit.
144 lines
3.7 KiB
Go
144 lines
3.7 KiB
Go
// Copyright (c) 2013-2016 The btcsuite developers
|
|
// Copyright (c) 2015-2018 The Decred developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package wire
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// InitialProcotolVersion is the initial protocol version for the
|
|
// network.
|
|
InitialProcotolVersion uint32 = 1
|
|
|
|
// ProtocolVersion is the latest protocol version this package supports.
|
|
ProtocolVersion uint32 = 6
|
|
|
|
// NodeBloomVersion is the protocol version which added the SFNodeBloom
|
|
// service flag (unused).
|
|
NodeBloomVersion uint32 = 2
|
|
|
|
// SendHeadersVersion is the protocol version which added a new
|
|
// sendheaders message.
|
|
SendHeadersVersion uint32 = 3
|
|
|
|
// MaxBlockSizeVersion is the protocol version which increased the
|
|
// original blocksize.
|
|
MaxBlockSizeVersion uint32 = 4
|
|
|
|
// FeeFilterVersion is the protocol version which added a new
|
|
// feefilter message.
|
|
FeeFilterVersion uint32 = 5
|
|
|
|
// NodeCFVersion is the protocol version which adds the SFNodeCF service
|
|
// flag and the cfheaders, cfilter, cftypes, getcfheaders, getcfilter and
|
|
// getcftypes messages.
|
|
NodeCFVersion uint32 = 6
|
|
)
|
|
|
|
// ServiceFlag identifies services supported by a Decred peer.
|
|
type ServiceFlag uint64
|
|
|
|
const (
|
|
// SFNodeNetwork is a flag used to indicate a peer is a full node.
|
|
SFNodeNetwork ServiceFlag = 1 << iota
|
|
|
|
// SFNodeBloom is a flag used to indiciate a peer supports bloom
|
|
// filtering.
|
|
SFNodeBloom
|
|
|
|
// SFNodeCF is a flag used to indicate a peer supports committed
|
|
// filters (CFs).
|
|
SFNodeCF
|
|
)
|
|
|
|
// Map of service flags back to their constant names for pretty printing.
|
|
var sfStrings = map[ServiceFlag]string{
|
|
SFNodeNetwork: "SFNodeNetwork",
|
|
SFNodeBloom: "SFNodeBloom",
|
|
SFNodeCF: "SFNodeCF",
|
|
}
|
|
|
|
// orderedSFStrings is an ordered list of service flags from highest to
|
|
// lowest.
|
|
var orderedSFStrings = []ServiceFlag{
|
|
SFNodeNetwork,
|
|
SFNodeBloom,
|
|
SFNodeCF,
|
|
}
|
|
|
|
// String returns the ServiceFlag in human-readable form.
|
|
func (f ServiceFlag) String() string {
|
|
// No flags are set.
|
|
if f == 0 {
|
|
return "0x0"
|
|
}
|
|
|
|
// Add individual bit flags.
|
|
s := ""
|
|
for _, flag := range orderedSFStrings {
|
|
if f&flag == flag {
|
|
s += sfStrings[flag] + "|"
|
|
f -= flag
|
|
}
|
|
}
|
|
|
|
// Add any remaining flags which aren't accounted for as hex.
|
|
s = strings.TrimRight(s, "|")
|
|
if f != 0 {
|
|
s += "|0x" + strconv.FormatUint(uint64(f), 16)
|
|
}
|
|
s = strings.TrimLeft(s, "|")
|
|
return s
|
|
}
|
|
|
|
// CurrencyNet represents which Decred network a message belongs to.
|
|
type CurrencyNet uint32
|
|
|
|
// Constants used to indicate the message Decred network. They can also be
|
|
// used to seek to the next message when a stream's state is unknown, but
|
|
// this package does not provide that functionality since it's generally a
|
|
// better idea to simply disconnect clients that are misbehaving over TCP.
|
|
const (
|
|
// MainNet represents the main Decred network.
|
|
MainNet CurrencyNet = 0xd9b400f9
|
|
|
|
// RegNet represents the regression test network.
|
|
RegNet CurrencyNet = 0xdab500fa
|
|
|
|
// RegTest represents the regression test network.
|
|
//
|
|
// DEPRECATED. This will be removed in the next major version bump.
|
|
// Use Regnet instead.
|
|
RegTest CurrencyNet = RegNet
|
|
|
|
// TestNet3 represents the 3rd test network.
|
|
TestNet3 CurrencyNet = 0xb194aa75
|
|
|
|
// SimNet represents the simulation test network.
|
|
SimNet CurrencyNet = 0x12141c16
|
|
)
|
|
|
|
// bnStrings is a map of Decred networks back to their constant names for
|
|
// pretty printing.
|
|
var bnStrings = map[CurrencyNet]string{
|
|
MainNet: "MainNet",
|
|
TestNet3: "TestNet3",
|
|
RegNet: "RegNet",
|
|
SimNet: "SimNet",
|
|
}
|
|
|
|
// String returns the CurrencyNet in human-readable form.
|
|
func (n CurrencyNet) String() string {
|
|
if s, ok := bnStrings[n]; ok {
|
|
return s
|
|
}
|
|
|
|
return fmt.Sprintf("Unknown CurrencyNet (%d)", uint32(n))
|
|
}
|