mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +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 {
|
} else {
|
||||||
// TODO check if in reorg cases it might be a valid case
|
// TODO check if in reorg cases it might be a valid case
|
||||||
checkArgument(height > daoStateBlockChain.getLast().getHeight(),
|
checkArgument(height == daoStateBlockChain.getLast().getHeight() + 1,
|
||||||
"We got a block the same blockHeight as our previous block in the daoStateBlockchain.");
|
"New block must be 1 block above previous block. height={}, " +
|
||||||
|
"daoStateBlockChain.getLast().getHeight()={}",
|
||||||
|
height, daoStateBlockChain.getLast().getHeight());
|
||||||
prevHash = daoStateBlockChain.getLast().getHash();
|
prevHash = daoStateBlockChain.getLast().getHash();
|
||||||
}
|
}
|
||||||
byte[] stateHash = daoStateService.getSerializedDaoState();
|
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.
|
// 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.
|
// 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);
|
int delayInSec = 1 + new Random().nextInt(5);
|
||||||
UserThread.runAfter(() -> daoStateNetworkService.broadcastMyStateHash(myDaoStateHash), delayInSec);
|
UserThread.runAfter(() -> daoStateNetworkService.broadcastMyStateHash(myDaoStateHash), delayInSec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ public abstract class StateNetworkService<Msg extends NewStateHashMessage,
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<NodeAddress, Han> requestStateHashHandlerMap = new HashMap<>();
|
private final Map<NodeAddress, Han> requestStateHashHandlerMap = new HashMap<>();
|
||||||
private final List<Listener<Msg, Req, StH>> listeners = new CopyOnWriteArrayList<>();
|
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() {
|
public void addListeners() {
|
||||||
networkNode.addMessageListener(this);
|
if (!messageListenerAdded) {
|
||||||
|
networkNode.addMessageListener(this);
|
||||||
|
messageListenerAdded = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendGetStateHashesResponse(Connection connection, int nonce, List<StH> stateHashes) {
|
public void sendGetStateHashesResponse(Connection connection, int nonce, List<StH> stateHashes) {
|
||||||
|
|
|
@ -175,9 +175,9 @@ public class DaoStateService implements DaoSetupService {
|
||||||
return daoState.getCycles();
|
return daoState.getCycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCycle(Cycle firstCycle) {
|
public void addCycle(Cycle cycle) {
|
||||||
assertDaoStateChange();
|
assertDaoStateChange();
|
||||||
getCycles().add(firstCycle);
|
getCycles().add(cycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
Loading…
Add table
Reference in a new issue