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 (
github.com/dgraph-io/badger/v2 v2.0.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/drand/drand v0.5.4
github.com/gobuffalo/logger v1.0.1
github.com/gobuffalo/packr/v2 v2.7.1
github.com/golang/protobuf v1.3.4
github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2
......
......@@ -6,6 +6,7 @@ import (
"github.com/iotaledger/goshimmer/plugins/cli"
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/goshimmer/plugins/database"
"github.com/iotaledger/goshimmer/plugins/drng"
"github.com/iotaledger/goshimmer/plugins/gossip"
"github.com/iotaledger/goshimmer/plugins/gracefulshutdown"
"github.com/iotaledger/goshimmer/plugins/logger"
......@@ -28,4 +29,5 @@ var PLUGINS = node.Plugins(
gossip.PLUGIN,
gracefulshutdown.PLUGIN,
metrics.PLUGIN,
drng.PLUGIN,
)
......@@ -7,6 +7,7 @@ import (
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/plugins/messagelayer"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/marshalutil"
"github.com/iotaledger/hive.go/node"
)
......@@ -15,9 +16,13 @@ const name = "DRNG" // name of the plugin
var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run)
var Instance *drng.Instance
var (
Instance *drng.Instance
log *logger.Logger
)
func configure(*node.Plugin) {
log = logger.NewLogger(name)
Instance = drng.New()
configureEvents()
}
......@@ -33,11 +38,15 @@ func configureEvents() {
parsedPayload, err := payload.Parse(marshalUtil)
if err != nil {
//TODO: handle error
log.Info(err)
return
}
if err := Instance.Dispatch(msg.IssuerPublicKey(), msg.IssuingTime(), parsedPayload); err != nil {
//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