From 1e41b5a46fd7ebafd6b5d8fec814486b4cbc411a Mon Sep 17 00:00:00 2001 From: xinran chen Date: Fri, 17 Apr 2026 18:55:23 +0800 Subject: [PATCH 1/3] remove unnecessary wg and WaitExit from kernel, make Startup() block directly Co-Authored-By: Claude Opus 4.6 --- core/kernel/kernel.go | 12 +----------- core/kernel/run.go | 5 +---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/core/kernel/kernel.go b/core/kernel/kernel.go index d8141eb..b17a176 100644 --- a/core/kernel/kernel.go +++ b/core/kernel/kernel.go @@ -1,8 +1,6 @@ package kernel import ( - "sync" - "github.com/sirupsen/logrus" "github.com/yu-org/yu/common" @@ -29,7 +27,6 @@ type Kernel struct { *env.ChainEnv Land *tripod.Land - wg *sync.WaitGroup } func NewKernel( @@ -46,7 +43,6 @@ func NewKernel( wsPort: ip.MakePort(cfg.WsPort), ChainEnv: env, Land: land, - wg: &sync.WaitGroup{}, } env.Execute = k.SeqExecuteWritings @@ -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() } func (k *Kernel) InitBlockChain() { diff --git a/core/kernel/run.go b/core/kernel/run.go index 7216bfb..b896ddd 100644 --- a/core/kernel/run.go +++ b/core/kernel/run.go @@ -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 { From 7a581c9c363f96873ff7ff56a4ecacc8081f97da Mon Sep 17 00:00:00 2001 From: xinran chen Date: Fri, 17 Apr 2026 19:04:51 +0800 Subject: [PATCH 2/3] stopchan --- core/kernel/kernel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/kernel/kernel.go b/core/kernel/kernel.go index b17a176..8d216b7 100644 --- a/core/kernel/kernel.go +++ b/core/kernel/kernel.go @@ -83,7 +83,7 @@ func (k *Kernel) Startup() { } func (k *Kernel) Stop() { - close(k.stopChan) + k.stopChan <- struct{}{} } func (k *Kernel) InitBlockChain() { From 53c02d401cf1e4818e1b956c36ebd36a1d25ab26 Mon Sep 17 00:00:00 2001 From: xinran chen Date: Fri, 17 Apr 2026 19:10:44 +0800 Subject: [PATCH 3/3] http admin stop --- core/kernel/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/kernel/http.go b/core/kernel/http.go index 103a1ad..927d1ac 100644 --- a/core/kernel/http.go +++ b/core/kernel/http.go @@ -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() }) }