Skip to content

Commit

Permalink
Makes some variables final
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-richardson committed Sep 2, 2019
1 parent 98bf38d commit 5588f31
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ public Optional<String> deletePrivacyGroup(String privacyGroupId, String from) {
return Optional.ofNullable(keyFuture.join());
}

public Optional<String> push(EncryptedPayload payload) {
CompletableFuture<String> pushFuture = new CompletableFuture<>();
public Optional<String> push(final EncryptedPayload payload) {
final CompletableFuture<String> pushFuture = new CompletableFuture<>();
httpClient.post(clientPort, "localhost", "/push").handler(resp -> {
if (resp.statusCode() == 200) {
resp.bodyHandler((body) -> {
Expand All @@ -203,9 +203,9 @@ public Optional<String> push(EncryptedPayload payload) {


public Optional<Boolean> pushToHistory(
String privacyGroupId,
String privacyMarkerTransactionHash,
String enclaveKey) {
final String privacyGroupId,
final String privacyMarkerTransactionHash,
final String enclaveKey) {
PushToHistoryRequest pushToHistoryRequest =
new PushToHistoryRequest(privacyGroupId, privacyMarkerTransactionHash, enclaveKey);
CompletableFuture<Boolean> keyFuture = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public static String sendTransactionPrivacyGroupId(EthClientStub sender, String
}

public static Boolean pushToHistory(
EthClientStub sender,
String privacyGroupId,
String privacyMarkerTransactionHash,
String enclaveKey) {
final EthClientStub sender,
final String privacyGroupId,
final String privacyMarkerTransactionHash,
final String enclaveKey) {
return sender.pushToHistory(privacyGroupId, privacyMarkerTransactionHash, enclaveKey).orElseThrow(
AssertionFailedError::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PushTransactionToPrivacyGroupHistoryTest {
private MemoryKeyStore memoryKeyStore;

@BeforeEach
void setUpDualNode(@TempDirectory Path tempDir) throws Exception {
void setUpDualNode(@TempDirectory final Path tempDir) throws Exception {
vertx = vertx();

Path key1pub = copyResource("key1.pub", tempDir.resolve("key1.pub"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class PushToHistoryRequest implements Serializable {

@JsonCreator
public PushToHistoryRequest(
@JsonProperty("privacyGroupId") String privacyGroupId,
@JsonProperty("privacyMarkerTransactionHash") String privacyMarkerTransactionHash,
@JsonProperty("enclaveKey") String enclaveKey) {
@JsonProperty("privacyGroupId") final String privacyGroupId,
@JsonProperty("privacyMarkerTransactionHash") final String privacyMarkerTransactionHash,
@JsonProperty("enclaveKey") final String enclaveKey) {

this.privacyGroupId = privacyGroupId;
this.privacyMarkerTxHash = privacyMarkerTransactionHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,31 @@ public PrivateTransactionStorage(KeyValueStore store) {
}

@Override
public AsyncResult<String> put(ArrayList<CommitmentPair> data) {
String key = generateDigest(data);
Bytes keyBytes = Bytes.wrap(key.getBytes(UTF_8));
Bytes dataBytes = Bytes.wrap(Serializer.serialize(HttpContentType.CBOR, data));
public AsyncResult<String> put(final ArrayList<CommitmentPair> data) {
final String key = generateDigest(data);
final Bytes keyBytes = Bytes.wrap(key.getBytes(UTF_8));
final Bytes dataBytes = Bytes.wrap(Serializer.serialize(HttpContentType.CBOR, data));
return store.putAsync(keyBytes, dataBytes).thenSupply(() -> key);
}

@Override
public String generateDigest(ArrayList<CommitmentPair> data) {
public String generateDigest(final ArrayList<CommitmentPair> data) {
return PREPEND + encodeBytes(Longs.toByteArray(data.hashCode()));
}

@Override
@SuppressWarnings("unchecked")
public AsyncResult<Optional<ArrayList<CommitmentPair>>> get(String key) {
Bytes keyBytes = Bytes.wrap((PREPEND + key).getBytes(UTF_8));
public AsyncResult<Optional<ArrayList<CommitmentPair>>> get(final String key) {
final Bytes keyBytes = Bytes.wrap((PREPEND + key).getBytes(UTF_8));
return store.getAsync(keyBytes).thenApply(
maybeBytes -> Optional.ofNullable(maybeBytes).map(
bytes -> Serializer.deserialize(HttpContentType.CBOR, ArrayList.class, bytes.toArrayUnsafe())));
}

@Override
public AsyncResult<Optional<ArrayList<CommitmentPair>>> update(String key, ArrayList<CommitmentPair> data) {
public AsyncResult<Optional<ArrayList<CommitmentPair>>> update(
final String key,
final ArrayList<CommitmentPair> data) {
return get(key).thenApply((result) -> {
Bytes keyBytes = Bytes.wrap((PREPEND + key).getBytes(UTF_8));
Bytes dataBytes = Bytes.wrap(Serializer.serialize(HttpContentType.CBOR, data));
Expand Down

0 comments on commit 5588f31

Please sign in to comment.