Search in sources :

Example 1 with PrivateTransactionEvent

use of org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent in project besu by hyperledger.

the class FlexiblePrivacyPrecompiledContract method sendParticipantRemovedEvent.

private void sendParticipantRemovedEvent(final PrivateTransaction privateTransaction) {
    if (isRemovingParticipant(privateTransaction)) {
        // get first participant parameter - there is only one for removal transaction
        final String removedParticipant = getRemovedParticipantFromParameter(privateTransaction.getPayload());
        final PrivateTransactionEvent removalEvent = new PrivateTransactionEvent(privateTransaction.getPrivacyGroupId().get().toBase64String(), removedParticipant);
        privateTransactionEventObservers.forEach(sub -> sub.onPrivateTransactionProcessed(removalEvent));
    }
}
Also used : PrivateTransactionEvent(org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent)

Example 2 with PrivateTransactionEvent

use of org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent in project besu by hyperledger.

the class SubscriptionManagerTest method shouldUnsubscribeIfUserRemovedFromPrivacyGroup.

@Test
public void shouldUnsubscribeIfUserRemovedFromPrivacyGroup() {
    final String enclavePublicKey = "C1bVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=";
    final FilterParameter filterParameter = new FilterParameter(BlockParameter.EARLIEST, BlockParameter.LATEST, null, null, null, null, null, null, null);
    final String privacyGroupId = "ZDmkMK7CyxA1F1rktItzKFTfRwApg7aWzsTtm2IOZ5Y=";
    final PrivateSubscribeRequest privateSubscribeRequest = new PrivateSubscribeRequest(SubscriptionType.LOGS, filterParameter, null, CONNECTION_ID, privacyGroupId, enclavePublicKey);
    final Long subscriptionId = subscriptionManager.subscribe(privateSubscribeRequest);
    assertThat(subscriptionManager.subscriptionsOfType(SubscriptionType.LOGS, PrivateLogsSubscription.class).size()).isEqualTo(1);
    subscriptionManager.onPrivateTransactionProcessed(new PrivateTransactionEvent(privacyGroupId, enclavePublicKey));
    subscriptionManager.onBlockAdded();
    assertThat(subscriptionManager.subscriptionsOfType(SubscriptionType.LOGS, PrivateLogsSubscription.class).size()).isEqualTo(0);
    assertThat(subscriptionManager.getSubscriptionById(subscriptionId)).isNull();
}
Also used : PrivateTransactionEvent(org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent) PrivateLogsSubscription(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription) PrivateSubscribeRequest(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.PrivateSubscribeRequest) FilterParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter) Test(org.junit.Test)

Example 3 with PrivateTransactionEvent

use of org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent in project besu by hyperledger.

the class FilterManagerLogFilterTest method privateTransactionEvent.

private void privateTransactionEvent(final String privacyGroupId, final String privacyUserId) {
    PrivateTransactionEvent event = new PrivateTransactionEvent(privacyGroupId, privacyUserId);
    filterManager.processRemovalEvent(event);
}
Also used : PrivateTransactionEvent(org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent)

Aggregations

PrivateTransactionEvent (org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent)3 FilterParameter (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter)1 PrivateLogsSubscription (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.logs.PrivateLogsSubscription)1 PrivateSubscribeRequest (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.PrivateSubscribeRequest)1 Test (org.junit.Test)1