Skip to content

Commit 395e1f5

Browse files
authored
Set defaults based on network (#264)
1 parent 31687e9 commit 395e1f5

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

conf/conf.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"sync"
66
"time"
7+
"github.com/perlin-network/wavelet/sys"
78
)
89

910
type config struct {
@@ -53,7 +54,7 @@ func init() {
5354
}
5455

5556
func defaultConfig() config {
56-
return config{
57+
defConf := config{
5758
snowballK: 2,
5859
snowballBeta: 50,
5960

@@ -74,6 +75,13 @@ func defaultConfig() config {
7475
maxDepthDiff: 10,
7576
pruningLimit: 30,
7677
}
78+
79+
switch sys.VersionMeta {
80+
case "testnet":
81+
defConf.snowballK = 10
82+
}
83+
84+
return defConf
7785
}
7886

7987
type Option func(*config)

scripts/helper.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set -eu
3030
# common variables
3131
GIT_COMMIT=$(git rev-parse --short HEAD)
3232
GO_VERSION=$(go version | awk '{print $3}')
33+
BUILD_NETWORK="${BUILD_NETWORK:-testnet}"
3334

3435
# loop through each architecture and build to an output
3536
set -e
@@ -61,7 +62,8 @@ for os_arch in $( echo ${OS_ARCH} | tr "," " " ); do
6162
-ldflags "\
6263
-X ${PROJ_DIR}/sys.GitCommit=${GIT_COMMIT} \
6364
-X ${PROJ_DIR}/sys.GoVersion=${GO_VERSION} \
64-
-X ${PROJ_DIR}/sys.OSArch=${os_arch}" \
65+
-X ${PROJ_DIR}/sys.OSArch=${os_arch} \
66+
-X ${PROJ_DIR}/sys.VersionMeta=${BUILD_NETWORK}" \
6567
.
6668
)
6769

@@ -73,7 +75,8 @@ for os_arch in $( echo ${OS_ARCH} | tr "," " " ); do
7375
-ldflags " \
7476
-X ${PROJ_DIR}/sys.GitCommit=${GIT_COMMIT} \
7577
-X ${PROJ_DIR}/sys.GoVersion=${GO_VERSION} \
76-
-X ${PROJ_DIR}/sys.OSArch=${os_arch}" \
78+
-X ${PROJ_DIR}/sys.OSArch=${os_arch} \
79+
-X ${PROJ_DIR}/sys.VersionMeta=${BUILD_NETWORK}" \
7780
.
7881
)
7982

@@ -85,7 +88,8 @@ for os_arch in $( echo ${OS_ARCH} | tr "," " " ); do
8588
-ldflags "\
8689
-X ${PROJ_DIR}/sys.GitCommit=${GIT_COMMIT} \
8790
-X ${PROJ_DIR}/sys.GoVersion=${GO_VERSION} \
88-
-X ${PROJ_DIR}/sys.OSArch=${os_arch}" \
91+
-X ${PROJ_DIR}/sys.OSArch=${os_arch} \
92+
-X ${PROJ_DIR}/sys.VersionMeta=${BUILD_NETWORK}" \
8993
.
9094
)
9195

sys/const.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ var (
290290
ContractMaxGlobals = 64
291291
)
292292

293+
func init() {
294+
switch VersionMeta {
295+
case "testnet":
296+
MinimumStake = 10000
297+
}
298+
}
299+
293300
// String converts a given tag to a string.
294301
func (tag Tag) String() string {
295302
if tag < 0 || tag > 4 { // Check out of bounds

sys/version.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ const (
2828
VersionMinor = 1
2929
// VersionPatch is patch version component of the current release
3030
VersionPatch = 1
31-
// VersionMeta is append to the version string
32-
VersionMeta = "testing"
3331
)
3432

3533
// variables set via linker flags
3634
var (
3735
GitCommit = "unset"
3836
GoVersion = "unset"
3937
OSArch = "unset"
38+
39+
// VersionMeta is append to the version string
40+
VersionMeta = "testing"
4041
)
4142

4243
// Version holds the textual version string.

0 commit comments

Comments
 (0)