Skip to content

Commit

Permalink
Update fastsync.go according to interface change
Browse files Browse the repository at this point in the history
  • Loading branch information
mksong76 committed Nov 10, 2023
1 parent 8a1afc6 commit 94c8d23
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions icon/icconsensus/fastsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func newFastSyncer(
parent: parent,
bpp: bpp,
log: l,
r1: consensusReactor{l},
r2: consensusReactor{l},
r1: consensusReactor{l, c.NID()},
r2: consensusReactor{l, c.NID()},
}
return f
}
Expand Down Expand Up @@ -238,6 +238,15 @@ func (f *fastSyncer) GetBTPBlockHeaderAndProof(blk module.Block, nid int64, flag

type consensusReactor struct {
log log.Logger
nid int
}

func (r *consensusReactor) ValidNID(nid uint32) bool {
return r.nid == int(nid)
}

func (r *consensusReactor) NID() int {
return r.nid
}

func (r *consensusReactor) OnReceive(pi module.ProtocolInfo, b []byte, id module.PeerID) (bool, error) {
Expand All @@ -247,7 +256,7 @@ func (r *consensusReactor) OnReceive(pi module.ProtocolInfo, b []byte, id module
return false, err
}
r.log.Debugf("OnReceive(msg:%v, from:%v)\n", msg, common.HexPre(id.Bytes()))
if err = msg.Verify(); err != nil {
if err = msg.Verify(r); err != nil {
r.log.Warnf("consensus message verify failed: OnReceive(msg:%v, from:%v): %+v\n", msg, common.HexPre(id.Bytes()), err)
return false, err
}
Expand Down

0 comments on commit 94c8d23

Please sign in to comment.