generated from Wysteriya/baby-chain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (46 loc) · 1.36 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"baby-chain/gpp"
"baby-chain/gpp/services"
"log"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func publicRoutes(rg *gin.RouterGroup) {
clientRoute := rg.Group("/public", func(ctx *gin.Context) {
gpp.SaveHyperParams()
})
clientRoute.GET("/sync", services.SyncGet)
clientRoute.POST("/sync", services.SyncPost)
clientRoute.POST("/register_ins", services.RegisterIns)
clientRoute.GET("/list_ins", services.INSList)
clientRoute.POST("/ins_havs", services.InsHavs)
clientRoute.POST("/login", services.Login)
clientRoute.POST("/user_login", services.UserLogin)
}
func privateRoutes(rg *gin.RouterGroup) {
clientRoute := rg.Group("/private", func(ctx *gin.Context) {
gpp.SaveHyperParams()
})
clientRoute.POST("/node", services.NodePost)
clientRoute.POST("/buy_ins", services.BuyIns)
clientRoute.POST("/claim_ins", services.ClaimIns)
clientRoute.POST("/status", services.Status)
}
func main() {
gpp.BC, gpp.SD, gpp.CSAlgo = gpp.FetchHyperParams()
gpp.SaveHyperParams()
chainName := "baby_chain"
go func() {
server := gin.Default()
server.Use(cors.Default())
basePath := server.Group("/" + chainName)
privateRoutes(basePath)
log.Fatalln(server.Run(":9080"))
}()
server := gin.Default()
server.Use(cors.Default())
basePath := server.Group("/" + chainName)
publicRoutes(basePath)
log.Fatalln(server.Run(":9090"))
}