update stop agent processor
@@ -45,6 +45,9 @@ public class StopAgentTxProcessor implements TransactionProcessor<StopAgentTrans
@Autowired
private AccountLedgerService accountLedgerService;
+ @Autowired
+ private DepositStorageService depositStorageService;
+
@Override
public Result onRollback(StopAgentTransaction tx, Object secondaryData) {
AgentPo agentPo = agentStorageService.get(tx.getTxData().getCreateTxHash());
@@ -52,7 +55,17 @@ public class StopAgentTxProcessor implements TransactionProcessor<StopAgentTrans
throw new NulsRuntimeException(KernelErrorCode.DATA_ERROR, "the agent is not exist or it's never stopped!");
}
agentPo.setDelHeight(-1L);
-
+ List<DepositPo> depositPoList = depositStorageService.getList();
+ for (DepositPo depositPo : depositPoList) {
+ if (depositPo.getDelHeight() != tx.getBlockHeight()) {
+ continue;
+ }
+ if (!depositPo.getAgentHash().equals(agentPo.getHash())) {
+ continue;
+ }
+ depositPo.setDelHeight(-1L);
+ depositStorageService.save(depositPo);
+ }
boolean b = agentStorageService.save(agentPo);
if (!b) {
return Result.getFailed("update agent failed!");
@@ -70,6 +83,17 @@ public class StopAgentTxProcessor implements TransactionProcessor<StopAgentTrans
if (null == agentPo || agentPo.getDelHeight() > 0) {
throw new NulsRuntimeException(KernelErrorCode.DATA_ERROR, "the agent is not exist or had deleted!");
}
+ List<DepositPo> depositPoList = depositStorageService.getList();
+ for (DepositPo depositPo : depositPoList) {
+ if (depositPo.getDelHeight() > -1L) {
+ continue;
+ }
+ if (!depositPo.getAgentHash().equals(agentPo.getHash())) {
+ continue;
+ }
+ depositPo.setDelHeight(tx.getBlockHeight());
+ depositStorageService.save(depositPo);
+ }
agentPo.setDelHeight(tx.getBlockHeight());
tx.getTxData().setAddress(agentPo.getAgentAddress());
