diff --git a/hmy/downloader/beaconhelper.go b/hmy/downloader/beaconhelper.go index 663eab0193..4b0e643e68 100644 --- a/hmy/downloader/beaconhelper.go +++ b/hmy/downloader/beaconhelper.go @@ -17,6 +17,7 @@ type ( // insert the latest blocks to the beacon chain. beaconHelper struct { bc blockChain + ih insertHelper blockC <-chan *types.Block // TODO: refactor this hook to consensus module. We'd better put it in // consensus module under a subscription. @@ -33,9 +34,10 @@ type ( } ) -func newBeaconHelper(bc blockChain, blockC <-chan *types.Block, insertHook func()) *beaconHelper { +func newBeaconHelper(bc blockChain, ih insertHelper, blockC <-chan *types.Block, insertHook func()) *beaconHelper { return &beaconHelper{ bc: bc, + ih: ih, blockC: blockC, insertHook: insertHook, lastMileCache: newBlocksByNumber(lastMileCap), @@ -118,7 +120,7 @@ func (bh *beaconHelper) insertLastMileBlocks() (inserted int, bn uint64, err err bn-- return } - if _, err = bh.bc.InsertChain(types.Blocks{b}, true); err != nil { + if err = bh.ih.verifyAndInsertBlock(b); err != nil { bn-- return } diff --git a/hmy/downloader/downloader.go b/hmy/downloader/downloader.go index 7eb8335cc0..905b91f77e 100644 --- a/hmy/downloader/downloader.go +++ b/hmy/downloader/downloader.go @@ -58,7 +58,7 @@ func NewDownloader(host p2p.Host, bc *core.BlockChain, config Config) *Downloade var bh *beaconHelper if config.BHConfig != nil && bc.ShardID() == 0 { - bh = newBeaconHelper(bc, config.BHConfig.BlockC, config.BHConfig.InsertHook) + bh = newBeaconHelper(bc, ih, config.BHConfig.BlockC, config.BHConfig.InsertHook) } ctx, cancel := context.WithCancel(context.Background()) diff --git a/p2p/stream/protocols/sync/message/msg.pb.go b/p2p/stream/protocols/sync/message/msg.pb.go index a52b59794e..d6dbdcf82a 100644 --- a/p2p/stream/protocols/sync/message/msg.pb.go +++ b/p2p/stream/protocols/sync/message/msg.pb.go @@ -7,12 +7,11 @@ package message import ( - reflect "reflect" - sync "sync" - proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const (