Skip to content

Commit 03c6753

Browse files
committed
Add new build target; Add cli flag --checker.dsn for database storage of found nodes
Signed-off-by: Anton Litvinov <[email protected]>
1 parent 1c354be commit 03c6753

File tree

5 files changed

+229
-230
lines changed

5 files changed

+229
-230
lines changed

ci/packages/build.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,31 @@ import (
3232
"github.com/rs/zerolog/log"
3333
)
3434

35+
// BuildProvChecker builds myst binary with provider checker API. Like go tool, it supports cross-platform build with env vars: GOOS, GOARCH.
36+
func BuildProvChecker() error {
37+
logconfig.Bootstrap()
38+
if err := buildBinary(path.Join("cmd", "mysterium_node", "mysterium_node.go"), "myst", true); err != nil {
39+
return err
40+
}
41+
if err := copyConfig("myst"); err != nil {
42+
return err
43+
}
44+
if err := buildBinary(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", false); err != nil {
45+
return err
46+
}
47+
return nil
48+
}
49+
3550
// Build builds the project. Like go tool, it supports cross-platform build with env vars: GOOS, GOARCH.
3651
func Build() error {
3752
logconfig.Bootstrap()
38-
if err := buildBinary(path.Join("cmd", "mysterium_node", "mysterium_node.go"), "myst"); err != nil {
53+
if err := buildBinary(path.Join("cmd", "mysterium_node", "mysterium_node.go"), "myst", false); err != nil {
3954
return err
4055
}
4156
if err := copyConfig("myst"); err != nil {
4257
return err
4358
}
44-
if err := buildBinary(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor"); err != nil {
59+
if err := buildBinary(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", false); err != nil {
4560
return err
4661
}
4762
return nil
@@ -67,7 +82,7 @@ func buildCrossBinary(os, arch string) error {
6782
return sh.Run("bin/build_xgo", os+"/"+arch)
6883
}
6984

70-
func buildBinary(source, target string) error {
85+
func buildBinary(source, target string, provChecker bool) error {
7186
targetOS, ok := os.LookupEnv("GOOS")
7287
if !ok {
7388
targetOS = runtime.GOOS
@@ -76,10 +91,10 @@ func buildBinary(source, target string) error {
7691
if !ok {
7792
targetArch = runtime.GOARCH
7893
}
79-
return buildBinaryFor(source, target, targetOS, targetArch, nil, false)
94+
return buildBinaryFor(source, target, targetOS, targetArch, nil, false, provChecker)
8095
}
8196

82-
func buildBinaryFor(source, target, targetOS, targetArch string, extraEnvs map[string]string, buildStatic bool) error {
97+
func buildBinaryFor(source, target, targetOS, targetArch string, extraEnvs map[string]string, buildStatic, provChecker bool) error {
8398
log.Info().Msgf("Building %s -> %s %s/%s", source, target, targetOS, targetArch)
8499

85100
buildDir, err := filepath.Abs(path.Join("build", target))
@@ -100,6 +115,9 @@ func buildBinaryFor(source, target, targetOS, targetArch string, extraEnvs map[s
100115
if buildStatic {
101116
flags = append(flags, "-a", "-tags", "netgo")
102117
}
118+
if provChecker {
119+
flags = append(flags, "-tags", "prov_checker")
120+
}
103121

104122
if targetOS == "windows" {
105123
target += ".exe"

ci/packages/package.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,15 @@ func packageStandalone(binaryPath, os, arch string, extraEnvs map[string]string)
379379
if os == "linux" {
380380
filename := path.Base(binaryPath)
381381
binaryPath = path.Join("build", filename, filename)
382-
err = buildBinaryFor(path.Join("cmd", "mysterium_node", "mysterium_node.go"), filename, os, arch, extraEnvs, true)
382+
err = buildBinaryFor(path.Join("cmd", "mysterium_node", "mysterium_node.go"), filename, os, arch, extraEnvs, true, false)
383383
} else {
384384
err = buildCrossBinary(os, arch)
385385
}
386386
if err != nil {
387387
return err
388388
}
389389

390-
err = buildBinaryFor(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", os, arch, extraEnvs, true)
390+
err = buildBinaryFor(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", os, arch, extraEnvs, true, false)
391391
if err != nil {
392392
return err
393393
}

config/flags_network.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ var (
154154
Usage: "DNS listen port for services",
155155
Value: 11253,
156156
}
157+
158+
// FlagProvCheckerDatabaseDSN sets DNS for checker API database
159+
FlagProvCheckerDatabaseDSN = cli.StringFlag{
160+
Name: "checker.dsn",
161+
Usage: "Database DSN for provider checker",
162+
Value: "",
163+
}
157164
)
158165

159166
// RegisterFlagsNetwork function register network flags to flag list
@@ -179,6 +186,7 @@ func RegisterFlagsNetwork(flags *[]cli.Flag) {
179186
&FlagPortCheckServers,
180187
&FlagStatsReportInterval,
181188
&FlagDNSListenPort,
189+
&FlagProvCheckerDatabaseDSN,
182190
)
183191
}
184192

@@ -203,6 +211,7 @@ func ParseFlagsNetwork(ctx *cli.Context) {
203211
Current.ParseStringFlag(ctx, FlagPortCheckServers)
204212
Current.ParseDurationFlag(ctx, FlagStatsReportInterval)
205213
Current.ParseIntFlag(ctx, FlagDNSListenPort)
214+
Current.ParseStringFlag(ctx, FlagProvCheckerDatabaseDSN)
206215
}
207216

208217
// BlockchainNetwork defines a blockchain network
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//go:build !prov_checker
2+
3+
/*
4+
* Copyright (C) 2024 The "MysteriumNetwork/node" Authors.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
package endpoints
21+
22+
import (
23+
"github.com/gin-gonic/gin"
24+
25+
"github.com/mysteriumnetwork/node/core/connection"
26+
"github.com/mysteriumnetwork/node/core/node"
27+
"github.com/mysteriumnetwork/node/eventbus"
28+
"github.com/mysteriumnetwork/node/identity/selector"
29+
)
30+
31+
// AddRoutesForConnectionDiag adds proder check route to given router
32+
func AddRoutesForConnectionDiag(
33+
manager connection.DiagManager,
34+
stateProvider stateProvider,
35+
proposalRepository proposalRepository,
36+
identityRegistry identityRegistry,
37+
publisher eventbus.Publisher,
38+
subscriber eventbus.Subscriber,
39+
addressProvider addressProvider,
40+
identitySelector selector.Handler,
41+
options node.Options,
42+
) func(*gin.Engine) error {
43+
return func(e *gin.Engine) error {
44+
return nil
45+
}
46+
}

0 commit comments

Comments
 (0)