-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathmain.go
30 lines (24 loc) · 1018 Bytes
/
main.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
package main
import (
"fmt"
"github.com/ten-protocol/go-ten/go/common/container"
tenflag "github.com/ten-protocol/go-ten/go/common/flag"
"github.com/ten-protocol/go-ten/go/config"
enclavecontainer "github.com/ten-protocol/go-ten/go/enclave/container"
)
// Runs an Obscuro enclave as a standalone process.
func main() {
// fetch and parse flags
flags := config.EnclaveFlags // fetch the flags that enclave requires
err := tenflag.CreateCLIFlags(config.EnclaveFlags) // using tenflag convert those flags into the golang flags package ( go flags is a singlen )
if err != nil {
panic(fmt.Errorf("could not create CLI flags. Cause: %w", err))
}
tenflag.Parse() // parse the golang flags package defined flags from CLI
enclaveConfig, err := config.NewConfigFromFlags(flags)
if err != nil {
panic(fmt.Errorf("unable to create config from flags - %w", err))
}
enclaveContainer := enclavecontainer.NewEnclaveContainerFromConfig(enclaveConfig)
container.Serve(enclaveContainer)
}