mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-02 19:56:23 -04:00
remove DAO
Co-authored-by: premek <1145361+premek@users.noreply.github.com>
This commit is contained in:
parent
f9f2cd07c3
commit
cefba8e4b5
621 changed files with 583 additions and 68805 deletions
|
@ -88,7 +88,6 @@ public class Monitor {
|
|||
Capability.ACK_MSG,
|
||||
Capability.PROPOSAL,
|
||||
Capability.BLIND_VOTE,
|
||||
Capability.DAO_STATE,
|
||||
Capability.BUNDLE_OF_ENVELOPES,
|
||||
Capability.REFUND_AGENT,
|
||||
Capability.MEDIATION,
|
||||
|
|
|
@ -19,13 +19,6 @@ package bisq.monitor.metric;
|
|||
|
||||
import bisq.monitor.OnionParser;
|
||||
import bisq.monitor.Reporter;
|
||||
|
||||
import bisq.core.dao.monitoring.model.StateHash;
|
||||
import bisq.core.dao.monitoring.network.messages.GetBlindVoteStateHashesRequest;
|
||||
import bisq.core.dao.monitoring.network.messages.GetDaoStateHashesRequest;
|
||||
import bisq.core.dao.monitoring.network.messages.GetProposalStateHashesRequest;
|
||||
import bisq.core.dao.monitoring.network.messages.GetStateHashesResponse;
|
||||
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
import bisq.network.p2p.network.Connection;
|
||||
import bisq.network.p2p.peers.getdata.messages.GetDataResponse;
|
||||
|
@ -61,7 +54,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
* buckets, the Metric reports (for each host) the message types observed and
|
||||
* their number.
|
||||
*
|
||||
* Furthermore, since the DAO is a thing now, the consistency of the DAO state held by each host is assessed and reported.
|
||||
*
|
||||
* @author Florian Reimair
|
||||
*
|
||||
|
@ -70,13 +62,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
public class P2PSeedNodeSnapshot extends P2PSeedNodeSnapshotBase {
|
||||
|
||||
final Map<NodeAddress, Statistics<Set<Integer>>> bucketsPerHost = new ConcurrentHashMap<>();
|
||||
private int daostateheight = 594000;
|
||||
private int proposalheight = daostateheight;
|
||||
private int blindvoteheight = daostateheight;
|
||||
|
||||
/**
|
||||
* Use a counter to do statistics.
|
||||
*/
|
||||
private static class MyStatistics extends Statistics<Set<Integer>> {
|
||||
|
||||
@Override
|
||||
|
@ -93,25 +79,13 @@ public class P2PSeedNodeSnapshot extends P2PSeedNodeSnapshotBase {
|
|||
public P2PSeedNodeSnapshot(Reporter reporter) {
|
||||
super(reporter);
|
||||
}
|
||||
|
||||
protected List<NetworkEnvelope> getRequests() {
|
||||
List<NetworkEnvelope> result = new ArrayList<>();
|
||||
|
||||
Random random = new Random();
|
||||
result.add(new PreliminaryGetDataRequest(random.nextInt(), hashes));
|
||||
|
||||
result.add(new GetDaoStateHashesRequest(daostateheight, random.nextInt()));
|
||||
|
||||
result.add(new GetProposalStateHashesRequest(proposalheight, random.nextInt()));
|
||||
|
||||
result.add(new GetBlindVoteStateHashesRequest(blindvoteheight, random.nextInt()));
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Report all the stuff. Uses the configured reporter directly.
|
||||
*/
|
||||
void report() {
|
||||
|
||||
// report
|
||||
|
@ -160,65 +134,6 @@ public class P2PSeedNodeSnapshot extends P2PSeedNodeSnapshotBase {
|
|||
|
||||
// - report
|
||||
reporter.report(report, getName());
|
||||
|
||||
// - assemble dao report
|
||||
Map<String, String> daoreport = new HashMap<>();
|
||||
|
||||
// - transcode
|
||||
Map<String, Map<NodeAddress, Tuple>> perType = new HashMap<>();
|
||||
daoData.forEach((nodeAddress, daostatistics) -> daostatistics.values().forEach((type, tuple) -> {
|
||||
perType.putIfAbsent(type, new HashMap<>());
|
||||
perType.get(type).put(nodeAddress, tuple);
|
||||
}));
|
||||
|
||||
// - process dao data
|
||||
perType.forEach((type, nodeAddressTupleMap) -> {
|
||||
// - find head
|
||||
int head = nodeAddressTupleMap.values().stream().max(Comparator.comparingLong(Tuple::getHeight))
|
||||
.map(value -> (int) value.height)
|
||||
.orElse(0);
|
||||
int oldest = nodeAddressTupleMap.values().stream().min(Comparator.comparingLong(Tuple::getHeight))
|
||||
.map(value -> (int) value.height)
|
||||
.orElse(0);
|
||||
|
||||
// - update queried height
|
||||
if (type.contains("DaoState"))
|
||||
daostateheight = oldest - 20;
|
||||
else if (type.contains("Proposal"))
|
||||
proposalheight = oldest - 20;
|
||||
else
|
||||
blindvoteheight = oldest - 20;
|
||||
|
||||
// - calculate diffs
|
||||
nodeAddressTupleMap.forEach((nodeAddress, tuple) -> daoreport.put(type + "." + OnionParser.prettyPrint(nodeAddress) + ".head", Long.toString(tuple.height - head)));
|
||||
|
||||
// - memorize hashes
|
||||
Map<ByteBuffer, Integer> hitcount = new HashMap<>();
|
||||
nodeAddressTupleMap.forEach((nodeAddress, tuple) -> {
|
||||
ByteBuffer hash = ByteBuffer.wrap(tuple.hash);
|
||||
if (hitcount.containsKey(hash)) {
|
||||
hitcount.put(hash, hitcount.get(hash) + 1);
|
||||
} else
|
||||
hitcount.put(hash, 1);
|
||||
});
|
||||
|
||||
hitcount.clear();
|
||||
|
||||
nodeAddressTupleMap.forEach((nodeAddress, tuple) ->
|
||||
daoreport.put(type + "." + OnionParser.prettyPrint(nodeAddress) + ".hash",
|
||||
Integer.toString(Arrays.asList(hitcount.entrySet().stream()
|
||||
.sorted((o1, o2) -> o2.getValue().compareTo(o1.getValue()))
|
||||
.map(Map.Entry::getKey).toArray()).indexOf(ByteBuffer
|
||||
.wrap(tuple.hash)))));
|
||||
|
||||
// - report reference head
|
||||
daoreport.put(type + ".referenceHead", Integer.toString(head));
|
||||
});
|
||||
|
||||
daoData.clear();
|
||||
|
||||
// - report
|
||||
reporter.report(daoreport, "DaoStateSnapshot");
|
||||
}
|
||||
|
||||
private static class Tuple {
|
||||
|
@ -232,22 +147,6 @@ public class P2PSeedNodeSnapshot extends P2PSeedNodeSnapshotBase {
|
|||
}
|
||||
}
|
||||
|
||||
private class DaoStatistics extends Statistics<Tuple> {
|
||||
|
||||
@Override
|
||||
public void log(Object message) {
|
||||
// get last entry
|
||||
StateHash last = (StateHash) ((GetStateHashesResponse) message).getStateHashes().get(((GetStateHashesResponse) message).getStateHashes().size() - 1);
|
||||
|
||||
// For logging different data types
|
||||
String className = last.getClass().getSimpleName();
|
||||
|
||||
buckets.putIfAbsent(className, new Tuple(last.getHeight(), last.getHash()));
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<NodeAddress, Statistics<Tuple>> daoData = new ConcurrentHashMap<>();
|
||||
|
||||
protected boolean treatMessage(NetworkEnvelope networkEnvelope, Connection connection) {
|
||||
checkNotNull(connection.getPeersNodeAddressProperty(),
|
||||
"although the property is nullable, we need it to not be null");
|
||||
|
@ -279,14 +178,9 @@ public class P2PSeedNodeSnapshot extends P2PSeedNodeSnapshotBase {
|
|||
});
|
||||
|
||||
bucketsPerHost.put(connection.getPeersNodeAddressProperty().getValue(), result);
|
||||
return true;
|
||||
} else if (networkEnvelope instanceof GetStateHashesResponse) {
|
||||
daoData.putIfAbsent(connection.getPeersNodeAddressProperty().getValue(), new DaoStatistics());
|
||||
|
||||
daoData.get(connection.getPeersNodeAddressProperty().getValue()).log(networkEnvelope);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue