Commit 027e4966 authored by yahtoo's avatar yahtoo Committed by Paladz

Fix mined block broadcast err (#1726)

parent 5fa917a1
......@@ -85,7 +85,7 @@ func (a *API) submitBlock(ctx context.Context, req *SubmitBlockReq) Response {
return NewErrorResponse(errors.New("block submitted is orphan"))
}
if err = a.eventDispatcher.Post(event.NewMinedBlockEvent{Block: req.Block}); err != nil {
if err = a.eventDispatcher.Post(event.NewMinedBlockEvent{Block: *req.Block}); err != nil {
return NewErrorResponse(err)
}
......
......@@ -24,7 +24,7 @@ var (
ErrDuplicateSubscribe = errors.New("event: subscribe duplicate type")
)
type NewMinedBlockEvent struct{ Block *types.Block }
type NewMinedBlockEvent struct{ Block types.Block }
// TypeMuxEvent is a time-tagged notification pushed to subscribers.
type TypeMuxEvent struct {
......
......@@ -102,7 +102,7 @@ out:
}).Info("Miner processed block")
// Broadcast the block and announce chain insertion event
if err = m.eventDispatcher.Post(event.NewMinedBlockEvent{Block: block}); err != nil {
if err = m.eventDispatcher.Post(event.NewMinedBlockEvent{Block: *block}); err != nil {
log.WithFields(log.Fields{"module": logModule, "height": block.BlockHeader.Height, "error": err}).Errorf("Miner fail on post block")
}
} else {
......
......@@ -121,7 +121,7 @@ func (m *MiningPool) submitWork(bh *types.BlockHeader) error {
return errors.New("submit result is orphan")
}
if err := m.eventDispatcher.Post(event.NewMinedBlockEvent{Block: m.block}); err != nil {
if err := m.eventDispatcher.Post(event.NewMinedBlockEvent{Block: *m.block}); err != nil {
return err
}
......
......@@ -480,7 +480,7 @@ func (sm *SyncManager) minedBroadcastLoop() {
continue
}
if err := sm.peers.broadcastMinedBlock(ev.Block); err != nil {
if err := sm.peers.broadcastMinedBlock(&ev.Block); err != nil {
log.WithFields(log.Fields{"module": logModule, "err": err}).Error("fail on broadcast mine block")
continue
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment