diff --git a/node/cn/api_backend.go b/node/cn/api_backend.go index 89e7afdd4..58ba82f51 100644 --- a/node/cn/api_backend.go +++ b/node/cn/api_backend.go @@ -100,6 +100,8 @@ func (b *CNAPIBackend) SetHead(number uint64) error { b.cn.protocolManager.Downloader().Cancel() b.cn.protocolManager.SetSyncStop(true) defer b.cn.protocolManager.SetSyncStop(false) + b.cn.supplyManager.Stop() + defer b.cn.supplyManager.Start() return doSetHead(b.cn.blockchain, b.cn.engine, b.cn.governance, b.gpo, number) } diff --git a/node/cn/api_backend_test.go b/node/cn/api_backend_test.go index 6dff66337..21da8995d 100644 --- a/node/cn/api_backend_test.go +++ b/node/cn/api_backend_test.go @@ -173,6 +173,18 @@ func testGov() *governance.MixedEngine { return governance.NewMixedEngine(config, db) } +type testSupplyManager struct{} + +func (sm *testSupplyManager) Start() { +} + +func (sm *testSupplyManager) Stop() { +} + +func (sm *testSupplyManager) GetTotalSupply(num uint64) (*reward.TotalSupply, error) { + return &reward.TotalSupply{}, nil +} + func TestCNAPIBackend_SetHead(t *testing.T) { mockCtrl, mockBlockChain, _, api := newCNAPIBackend(t) defer mockCtrl.Finish() @@ -183,6 +195,7 @@ func TestCNAPIBackend_SetHead(t *testing.T) { api.cn.protocolManager = pm api.cn.engine = gxhash.NewFullFaker() api.cn.governance = testGov() + api.cn.supplyManager = &testSupplyManager{} api.gpo = gasprice.NewOracle(api, gasprice.Config{}, nil, api.cn.governance) number := uint64(123)