/
plugin.go
40 lines (32 loc) · 930 Bytes
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package drng
import (
"github.com/iotaledger/hive.go/node"
"github.com/labstack/echo"
"go.uber.org/dig"
"github.com/iotaledger/goshimmer/packages/drng"
"github.com/iotaledger/goshimmer/packages/tangle"
)
// PluginName is the name of the web API DRNG endpoint plugin.
const PluginName = "WebAPIDRNGEndpoint"
type dependencies struct {
dig.In
Server *echo.Echo
DrngInstance *drng.DRNG `optional:"true"`
Tangle *tangle.Tangle
}
var (
// Plugin is the plugin instance of the web API DRNG endpoint plugin.
Plugin *node.Plugin
deps = new(dependencies)
)
func init() {
Plugin = node.NewPlugin(PluginName, deps, node.Enabled, configure)
}
func configure(_ *node.Plugin) {
if deps.DrngInstance == nil {
return
}
deps.Server.POST("drng/collectiveBeacon", collectiveBeaconHandler)
deps.Server.GET("drng/info/committee", committeeHandler)
deps.Server.GET("drng/info/randomness", randomnessHandler)
}