Skip to content
Snippets Groups Projects
Commit 92c4360a authored by capossele's avatar capossele
Browse files

:sparkles: enables drng dispatcher

parent 6aaf8071
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ require ( ...@@ -7,6 +7,7 @@ require (
github.com/dgraph-io/badger/v2 v2.0.2 github.com/dgraph-io/badger/v2 v2.0.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/drand/drand v0.5.4 github.com/drand/drand v0.5.4
github.com/gobuffalo/logger v1.0.1
github.com/gobuffalo/packr/v2 v2.7.1 github.com/gobuffalo/packr/v2 v2.7.1
github.com/golang/protobuf v1.3.4 github.com/golang/protobuf v1.3.4
github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2 github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"github.com/iotaledger/goshimmer/plugins/cli" "github.com/iotaledger/goshimmer/plugins/cli"
"github.com/iotaledger/goshimmer/plugins/config" "github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/goshimmer/plugins/database" "github.com/iotaledger/goshimmer/plugins/database"
"github.com/iotaledger/goshimmer/plugins/drng"
"github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/iotaledger/goshimmer/plugins/gracefulshutdown" "github.com/iotaledger/goshimmer/plugins/gracefulshutdown"
"github.com/iotaledger/goshimmer/plugins/logger" "github.com/iotaledger/goshimmer/plugins/logger"
...@@ -28,4 +29,5 @@ var PLUGINS = node.Plugins( ...@@ -28,4 +29,5 @@ var PLUGINS = node.Plugins(
gossip.PLUGIN, gossip.PLUGIN,
gracefulshutdown.PLUGIN, gracefulshutdown.PLUGIN,
metrics.PLUGIN, metrics.PLUGIN,
drng.PLUGIN,
) )
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle" "github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/plugins/messagelayer" "github.com/iotaledger/goshimmer/plugins/messagelayer"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/marshalutil" "github.com/iotaledger/hive.go/marshalutil"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
) )
...@@ -15,9 +16,13 @@ const name = "DRNG" // name of the plugin ...@@ -15,9 +16,13 @@ const name = "DRNG" // name of the plugin
var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run)
var Instance *drng.Instance var (
Instance *drng.Instance
log *logger.Logger
)
func configure(*node.Plugin) { func configure(*node.Plugin) {
log = logger.NewLogger(name)
Instance = drng.New() Instance = drng.New()
configureEvents() configureEvents()
} }
...@@ -33,11 +38,15 @@ func configureEvents() { ...@@ -33,11 +38,15 @@ func configureEvents() {
parsedPayload, err := payload.Parse(marshalUtil) parsedPayload, err := payload.Parse(marshalUtil)
if err != nil { if err != nil {
//TODO: handle error //TODO: handle error
log.Info(err)
return return
} }
if err := Instance.Dispatch(msg.IssuerPublicKey(), msg.IssuingTime(), parsedPayload); err != nil { if err := Instance.Dispatch(msg.IssuerPublicKey(), msg.IssuingTime(), parsedPayload); err != nil {
//TODO: handle error //TODO: handle error
log.Info(err)
return
} }
log.Info(Instance.State.Randomness())
}) })
})) }))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment