Skip to content
Snippets Groups Projects
Commit 0919f990 authored by Sydney Erickson's avatar Sydney Erickson
Browse files

Move graph gen params to server.yaml

parent be9f9415
Branches
Tags
No related merge requests found
package conf
// Contains graph generator config params
type GraphGen struct {
minInputSize uint32
defaultNumTh uint8
outputSize uint32
outputThreshold float32
}
package conf
var ExpectedGraphGen = GraphGen{
minInputSize: 4,
defaultNumTh: 2,
outputSize: 4,
outputThreshold: 0.0,
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import (
"gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/utils"
"gitlab.com/elixxir/server/server"
"gitlab.com/elixxir/server/services"
"golang.org/x/crypto/blake2b"
"net"
)
......@@ -39,6 +40,7 @@ type Params struct {
Gateways Gateways
Permissioning Permissioning
Metrics Metrics
GraphGen GraphGen
}
// NewParams gets elements of the viper object
......@@ -69,6 +71,11 @@ func NewParams(vip *viper.Viper) (*Params, error) {
params.Permissioning.Address = vip.GetString("permissioning.address")
params.Permissioning.RegistrationCode = vip.GetString("permissioning.registrationCode")
params.GraphGen.defaultNumTh = uint8(vip.GetUint("graphgen.defaultNumTh"))
params.GraphGen.minInputSize = vip.GetUint32("graphgen.mininputsize")
params.GraphGen.outputSize = vip.GetUint32("graphgen.outputsize")
params.GraphGen.outputThreshold = float32(vip.GetFloat64("graphgen.outputthreshold"))
params.Batch = vip.GetUint32("batch")
params.SkipReg = vip.GetBool("skipReg")
params.Verbose = vip.GetBool("verbose")
......@@ -267,5 +274,13 @@ func (p *Params) ConvertToDefinition() *server.Definition {
def.Permissioning.PublicKey = &rsa.PublicKey{PublicKey: *permCert.PublicKey.(*gorsa.PublicKey)}
}
PanicHandler := func(g, m string, err error) {
jww.FATAL.Panicf(fmt.Sprintf("Error in module %s of graph %s: %+v", g,
m, err))
}
def.GraphGenerator = services.NewGraphGenerator(p.GraphGen.minInputSize, PanicHandler,
p.GraphGen.defaultNumTh, p.GraphGen.outputSize, p.GraphGen.outputThreshold)
return def
}
......@@ -50,4 +50,9 @@ skipReg: true
keepBuffers: true
metrics:
log: "~/.elixxir/metrics.log"
graphgen:
defaultNumTh: 2
mininputsize: 4
outputsize: 4
outputthreshold: 0.0
...
......@@ -28,6 +28,7 @@ func TestNewParams_ReturnsParamsWhenGivenValidViper(t *testing.T) {
Gateways: ExpectedGateways,
Permissioning: ExpectedPermissioning,
Metrics: ExpectedMetrics,
GraphGen: ExpectedGraphGen,
}
vip := viper.New()
......@@ -92,4 +93,8 @@ func TestNewParams_ReturnsParamsWhenGivenValidViper(t *testing.T) {
"\n\treceived:\t%v\n\texpected:\t%v",
params.RngScalingFactor, expectedParams.RngScalingFactor)
}
if !reflect.DeepEqual(expectedParams.GraphGen, params.GraphGen) {
t.Errorf("Graph generator values do not match expected values")
}
}
......@@ -25,7 +25,6 @@ import (
"gitlab.com/elixxir/server/node"
"gitlab.com/elixxir/server/permissioning"
"gitlab.com/elixxir/server/server"
"gitlab.com/elixxir/server/services"
"runtime"
"time"
)
......@@ -150,13 +149,13 @@ func StartServer(vip *viper.Viper) {
round, payload, "FULL/BATCH")
}
PanicHandler := func(g, m string, err error) {
jww.FATAL.Panicf(fmt.Sprintf("Error in module %s of graph %s: %+v", g,
m, err))
}
//PanicHandler := func(g, m string, err error) {
// jww.FATAL.Panicf(fmt.Sprintf("Error in module %s of graph %s: %+v", g,
// m, err))
//}
def.GraphGenerator = services.NewGraphGenerator(4, PanicHandler,
uint8(runtime.NumCPU()), 4, 0.0)
//def.GraphGenerator = services.NewGraphGenerator(4, PanicHandler,
// uint8(runtime.NumCPU()), 4, 0.0)
def.RngStreamGen = fastRNG.NewStreamGenerator(params.RngScalingFactor,
uint(runtime.NumCPU()), csprng.NewSystemRNG)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment