mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Reflect code review comments
This commit is contained in:
parent
59bed76c0c
commit
3411cde8b7
3 changed files with 12 additions and 5 deletions
|
@ -233,8 +233,10 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
|
|||
}
|
||||
} else {
|
||||
// TODO check if in reorg cases it might be a valid case
|
||||
checkArgument(height > daoStateBlockChain.getLast().getHeight(),
|
||||
"We got a block the same blockHeight as our previous block in the daoStateBlockchain.");
|
||||
checkArgument(height == daoStateBlockChain.getLast().getHeight() + 1,
|
||||
"New block must be 1 block above previous block. height={}, " +
|
||||
"daoStateBlockChain.getLast().getHeight()={}",
|
||||
height, daoStateBlockChain.getLast().getHeight());
|
||||
prevHash = daoStateBlockChain.getLast().getHash();
|
||||
}
|
||||
byte[] stateHash = daoStateService.getSerializedDaoState();
|
||||
|
@ -256,6 +258,7 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
|
|||
|
||||
// We delay broadcast to give peers enough time to have received the block.
|
||||
// Otherwise they would ignore our data if received block is in future to their local blockchain.
|
||||
//TODO increase to 5-10 sec
|
||||
int delayInSec = 1 + new Random().nextInt(5);
|
||||
UserThread.runAfter(() -> daoStateNetworkService.broadcastMyStateHash(myDaoStateHash), delayInSec);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ public abstract class StateNetworkService<Msg extends NewStateHashMessage,
|
|||
@Getter
|
||||
private final Map<NodeAddress, Han> requestStateHashHandlerMap = new HashMap<>();
|
||||
private final List<Listener<Msg, Req, StH>> listeners = new CopyOnWriteArrayList<>();
|
||||
private boolean messageListenerAdded;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -147,7 +148,10 @@ public abstract class StateNetworkService<Msg extends NewStateHashMessage,
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void addListeners() {
|
||||
if (!messageListenerAdded) {
|
||||
networkNode.addMessageListener(this);
|
||||
messageListenerAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGetStateHashesResponse(Connection connection, int nonce, List<StH> stateHashes) {
|
||||
|
|
|
@ -175,9 +175,9 @@ public class DaoStateService implements DaoSetupService {
|
|||
return daoState.getCycles();
|
||||
}
|
||||
|
||||
public void addCycle(Cycle firstCycle) {
|
||||
public void addCycle(Cycle cycle) {
|
||||
assertDaoStateChange();
|
||||
getCycles().add(firstCycle);
|
||||
getCycles().add(cycle);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
Loading…
Add table
Reference in a new issue