
com.quorum.tessera.p2p.partyinfo.PartyStore Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sync-jaxrs Show documentation
Show all versions of sync-jaxrs Show documentation
Tessera is a stateless Java system that is used to enable the encryption, decryption, and distribution of private transactions for Quorum.
package com.quorum.tessera.p2p.partyinfo;
import com.quorum.tessera.context.RuntimeContext;
import com.quorum.tessera.discovery.NodeUri;
import java.net.URI;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.stream.Collectors;
/*
* Support legacy collation of all parties to be added to
* party info responses so nodes learn of nodes.
*/
public interface PartyStore {
default void loadFromConfigIfEmpty() {
RuntimeContext runtimeContext = RuntimeContext.getInstance();
final Set parties = getParties();
final URI ownUri = NodeUri.create(runtimeContext.getP2pServerUri()).asURI();
final Set peerList =
runtimeContext.getPeers().stream()
.map(NodeUri::create)
.map(NodeUri::asURI)
.filter(p -> !p.equals(ownUri))
.collect(Collectors.toUnmodifiableSet());
if (parties.isEmpty() || !peerList.stream().anyMatch(parties::contains)) {
peerList.forEach(this::store);
}
}
Set getParties();
PartyStore store(URI party);
PartyStore remove(URI party);
static PartyStore getInstance() {
return ServiceLoader.load(PartyStore.class).findFirst().get();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy