@@ -91,9 +91,15 @@ public void close() {
9191 }
9292 }
9393
94- public List <Miner > getSrMinerList () {
94+ public List <Miner > getSrMinerList (long epoch ) {
95+ List <ByteString > compareList ;
96+ if (epoch > maintenanceManager .getBeforeMaintenanceTime ()) {
97+ compareList = maintenanceManager .getCurrentWitness ();
98+ } else {
99+ compareList = maintenanceManager .getBeforeWitness ();
100+ }
95101 return Param .getInstance ().getMiners ().stream ()
96- .filter (miner -> chainBaseManager . getWitnesses () .contains (miner .getWitnessAddress ()))
102+ .filter (miner -> compareList .contains (miner .getWitnessAddress ()))
97103 .collect (Collectors .toList ());
98104 }
99105
@@ -115,10 +121,11 @@ public void onPrePrepare(PbftMessage message) {
115121 //
116122 checkPrepareMsgCache (key );
117123 //Into the preparation phase, if not the sr node does not need to be prepared
118- if (!checkIsCanSendMsg (message )) {
124+ long epoch = message .getPbftMessage ().getRawData ().getEpoch ();
125+ if (!checkIsCanSendMsg (epoch )) {
119126 return ;
120127 }
121- for (Miner miner : getSrMinerList ()) {
128+ for (Miner miner : getSrMinerList (epoch )) {
122129 PbftMessage paMessage = message .buildPrePareMessage (miner );
123130 forwardMessage (paMessage );
124131 try {
@@ -153,7 +160,8 @@ public synchronized void onPrepare(PbftMessage message) {
153160 pareVoteMap .put (key , message );
154161 //
155162 checkCommitMsgCache (message .getNo ());
156- if (!checkIsCanSendMsg (message )) {
163+ long epoch = message .getPbftMessage ().getRawData ().getEpoch ();
164+ if (!checkIsCanSendMsg (epoch )) {
157165 return ;
158166 }
159167 //The number of votes plus 1
@@ -162,7 +170,7 @@ public synchronized void onPrepare(PbftMessage message) {
162170 if (agCou >= Param .getInstance ().getAgreeNodeCount ()) {
163171 agreePare .remove (message .getDataKey ());
164172 //Entering the submission stage
165- for (Miner miner : getSrMinerList ()) {
173+ for (Miner miner : getSrMinerList (epoch )) {
166174 PbftMessage cmMessage = message .buildCommitMessage (miner );
167175 doneMsg .put (message .getNo (), cmMessage );
168176 forwardMessage (cmMessage );
@@ -239,19 +247,11 @@ private void checkCommitMsgCache(String key) {
239247 }
240248 }
241249
242- public boolean checkIsCanSendMsg (PbftMessage msg ) {
250+ public boolean checkIsCanSendMsg (long epoch ) {
243251 if (!Param .getInstance ().isEnable ()) {//is witness
244252 return false ;
245253 }
246- ByteString publicKey = Param .getInstance ().getMiner ().getPrivateKeyAddress ();
247- List <ByteString > compareList ;
248- long epoch = msg .getPbftMessage ().getRawData ().getEpoch ();
249- if (epoch > maintenanceManager .getBeforeMaintenanceTime ()) {
250- compareList = maintenanceManager .getCurrentWitness ();
251- } else {
252- compareList = maintenanceManager .getBeforeWitness ();
253- }
254- if (!compareList .contains (publicKey )) {
254+ if (getSrMinerList (epoch ).isEmpty ()) {
255255 return false ;
256256 }
257257 return !isSyncing ();
0 commit comments