Skip to content

Commit

Permalink
thoth grpc service.
Browse files Browse the repository at this point in the history
an unfortunate reformatting event, also, too
  • Loading branch information
Hellblazer committed Dec 4, 2023
1 parent 2aac336 commit d0670d9
Show file tree
Hide file tree
Showing 26 changed files with 520 additions and 308 deletions.
24 changes: 15 additions & 9 deletions fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import com.google.common.collect.Multiset.Entry;
import com.google.common.collect.Ordering;
import com.google.protobuf.ByteString;
import com.salesfoce.apollo.cryptography.proto.Biff;
import com.salesfoce.apollo.fireflies.proto.*;
import com.salesfoce.apollo.stereotomy.event.proto.KERL_;
import com.salesfoce.apollo.stereotomy.event.proto.KeyState_;
import com.salesfoce.apollo.cryptography.proto.Biff;
import com.salesforce.apollo.archipelago.Router;
import com.salesforce.apollo.archipelago.Router.ServiceRouting;
import com.salesforce.apollo.archipelago.RouterImpl.CommonCommunications;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import com.salesforce.apollo.cryptography.*;
import com.salesforce.apollo.fireflies.Binding.Bound;
import com.salesforce.apollo.fireflies.ViewManagement.Ballot;
Expand All @@ -37,9 +38,7 @@
import com.salesforce.apollo.stereotomy.EventValidation;
import com.salesforce.apollo.stereotomy.identifier.SelfAddressingIdentifier;
import com.salesforce.apollo.utils.Entropy;
import com.salesforce.apollo.membership.RoundScheduler;
import com.salesforce.apollo.utils.Utils;
import com.salesforce.apollo.bloomFilters.BloomFilter;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.grpc.stub.StreamObserver;
Expand Down Expand Up @@ -86,15 +85,15 @@ public class View {
private static final String SCHEDULED_VIEW_CHANGE = "Scheduled View Change";
private final CommonCommunications<Entrance, Service> approaches;
private final CommonCommunications<Fireflies, Service> comm;
private final Context<Participant> context;
private final DigestAlgorithm digestAlgo;
private final RingCommunications<Participant, Fireflies> gossiper;
private final Context<Participant> context;
private final DigestAlgorithm digestAlgo;
private final RingCommunications<Participant, Fireflies> gossiper;
private final AtomicBoolean introduced = new AtomicBoolean();
private final Map<UUID, ViewLifecycleListener> lifecycleListeners = new HashMap<>();
private final FireflyMetrics metrics;
private final Node node;
private final Map<Digest, SignedViewChange> observations = new ConcurrentSkipListMap<>();
private final Parameters params;
private final Node node;
private final Map<Digest, SignedViewChange> observations = new ConcurrentSkipListMap<>();
private final Parameters params;
private final ConcurrentMap<Digest, RoundScheduler.Timer> pendingRebuttals = new ConcurrentSkipListMap<>();
private final RoundScheduler roundTimers;
private final Set<Digest> shunned = new ConcurrentSkipListSet<>();
Expand Down Expand Up @@ -174,6 +173,13 @@ public Context<Participant> getContext() {
return context;
}

/**
* @return the Digest ID of the Node of this View
*/
public Digest getNodeId() {
return node.getId();
}

/**
* Register a listener to receive view change events
*
Expand Down
7 changes: 7 additions & 0 deletions grpc/src/main/proto/thoth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ service Reconciliation {
rpc update (Updating) returns (google.protobuf.Empty) {}
}

service Thoth_ {
rpc commit (stereotomy.EventCoords) returns (google.protobuf.Empty) {}
rpc identifier(google.protobuf.Empty) returns (stereotomy.Ident) {}
rpc inception(stereotomy.Ident) returns (stereotomy.InceptionEvent) {}
rpc rotate(google.protobuf.Empty) returns (stereotomy.RotationEvent) {}
}

message Update {
repeated stereotomy.KeyEventWithAttachmentAndValidations_ events = 1;
repeated Interval intervals = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@

package com.salesforce.apollo.thoth;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.salesfoce.apollo.thoth.proto.Interval;
import com.salesforce.apollo.cryptography.Digest;

import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.salesfoce.apollo.thoth.proto.Interval;
import com.salesforce.apollo.cryptography.Digest;

/**
* @author hal.hildebrand
*
*/
public class CombinedIntervals implements Predicate<Digest> {
private final List<KeyInterval> intervals = new ArrayList<>();
Expand All @@ -40,8 +35,8 @@ public int compare(KeyInterval o1, KeyInterval o2) {
int comparison = o1.getBegin().compareTo(o2.getBegin());

return comparison == 0 // if both intervals begin the same
? o1.getEnd().compareTo(o2.getEnd()) // compare their ends
: comparison;
? o1.getEnd().compareTo(o2.getEnd()) // compare their ends
: comparison;
}
});
KeyInterval current = allIntervals.get(0);
Expand Down
31 changes: 14 additions & 17 deletions thoth/src/main/java/com/salesforce/apollo/thoth/KerlDHT.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,6 @@ static <T> T completeIt(T result) {
return result;
}

/**
* Clear the caches of the receiver
*/
public void clearCache() {
cache.clear();
}

public KeyState_ append(AttachmentEvent event) {
if (event == null) {
return null;
Expand Down Expand Up @@ -379,6 +372,13 @@ public KERL asKERL() {
return cache;
}

/**
* Clear the caches of the receiver
*/
public void clearCache() {
cache.clear();
}

public DigestAlgorithm digestAlgorithm() {
return kerlPool.getDigestAlgorithm();
}
Expand Down Expand Up @@ -964,10 +964,7 @@ private boolean valid(Digest from, int ring) {
if (successor == null) {
return false;
}
if (!successor.equals(member)) {
return false;
}
return true;
return successor.equals(member);
}

private DelegatedKERL wrap(ClosableKERL k) {
Expand Down Expand Up @@ -1043,12 +1040,6 @@ public void update(Updating update, Digest from) {

private class Service implements ProtoKERLService {

@Override
public Validations getValidations(EventCoords coordinates) {
log.trace("get validations for coordinates on: {}", member.getId());
return complete(k -> k.getValidations(coordinates));
}

@Override
public List<KeyState_> append(KERL_ kerl_) {
log.info("appending kerl on: {}", member.getId());
Expand Down Expand Up @@ -1142,5 +1133,11 @@ public KeyStateWithEndorsementsAndValidations_ getKeyStateWithEndorsementsAndVal
.build();
});
}

@Override
public Validations getValidations(EventCoords coordinates) {
log.trace("get validations for coordinates on: {}", member.getId());
return complete(k -> k.getValidations(coordinates));
}
}
}
Loading

0 comments on commit d0670d9

Please sign in to comment.