Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/kernel/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (k *Kernel) HandleHttp() {
if k.cfg.IsAdmin {
admin := api.Group(AdminType)
admin.GET("stop", func(c *gin.Context) {
close(k.stopChan)
k.Stop()
})
}

Expand Down
14 changes: 2 additions & 12 deletions core/kernel/kernel.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package kernel

import (
"sync"

"github.com/sirupsen/logrus"

"github.com/yu-org/yu/common"
Expand All @@ -29,7 +27,6 @@ type Kernel struct {
*env.ChainEnv

Land *tripod.Land
wg *sync.WaitGroup
}

func NewKernel(
Expand All @@ -46,7 +43,6 @@ func NewKernel(
wsPort: ip.MakePort(cfg.WsPort),
ChainEnv: env,
Land: land,
wg: &sync.WaitGroup{},
}

env.Execute = k.SeqExecuteWritings
Expand Down Expand Up @@ -76,24 +72,18 @@ func (k *Kernel) WithExecuteFn(fn env.ExecuteFn) {
k.Execute = fn
}

func (k *Kernel) WaitExit() {
k.wg.Wait()
}

func (k *Kernel) Startup() {
k.InitBlockChain()

go k.HandleHttp()
go k.HandleWS()

k.wg.Add(1)
go k.AcceptUnpkgTxnsJob()
go k.Run()
k.Run()
}

func (k *Kernel) Stop() {
close(k.stopChan)
k.wg.Wait()
k.stopChan <- struct{}{}
}

func (k *Kernel) InitBlockChain() {
Expand Down
5 changes: 1 addition & 4 deletions core/kernel/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ func (k *Kernel) AcceptUnpkgTxnsJob() {
}

func (k *Kernel) Run() {
defer func() {
logrus.Info("Run exit")
k.wg.Done()
}()
defer logrus.Info("Run exit")
switch k.RunMode {
case common.LocalNode:
for {
Expand Down
Loading