Skip to content

Commit

Permalink
5931 gossip encapsulation (#6607)
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <cody@swirldslabs.com>
  • Loading branch information
cody-littley committed May 22, 2023
1 parent 09d7828 commit 6057902
Show file tree
Hide file tree
Showing 19 changed files with 2,301 additions and 931 deletions.
4 changes: 3 additions & 1 deletion platform-sdk/sdk/settings.txt
Expand Up @@ -16,4 +16,6 @@ checkSignedStateFromDisk, true
loadKeysFromPfxFiles, false
event.preconsensus.enableStorage, false
enableEventStreaming, false
reconnect.active, true
reconnect.active, true
chatter.useChatter, false
sync.syncAsProtocolEnabled, false
Expand Up @@ -228,7 +228,7 @@ void readBackRawData(FilesTestType testType) throws IOException {
int repeatCount = getRepeatCountForKey(i);
// read size
int size = (int) longBuf.get();
// TODO be nice to assert size
// FUTURE WORK: be nice to assert size
// read key
assertEquals(i, longBuf.get(), "unexpected data value #2");
for (int j = 0; j < repeatCount; j++) {
Expand Down
Expand Up @@ -516,6 +516,11 @@ public static synchronized void launch(final Set<Integer> localNodesToStart, fin
}
logger = LogManager.getLogger(Browser.class);

if (Thread.getDefaultUncaughtExceptionHandler() == null) {
Thread.setDefaultUncaughtExceptionHandler((final Thread t, final Throwable e) ->
logger.error(EXCEPTION.getMarker(), "exception on thread {}", t.getName(), e));
}

final LoggerContextFactory factory = LogManager.getFactory();
if (factory instanceof final Log4jContextFactory contextFactory) {
// Do not allow log4j to use its own shutdown hook. Use our own shutdown
Expand Down Expand Up @@ -676,13 +681,10 @@ private Collection<SwirldsPlatform> createLocalPlatforms(
GuiPlatformAccessor.getInstance().setInstanceNumber(address.getId(), i);

final SwirldsPlatform platform = new SwirldsPlatform(
// all key pairs and CSPRNG state for this member
platformContext,
crypto.get(address.getNodeId()),
// address book index, which is the member ID
nodeId,
// copy of the address book,
initialAddressBook,
platformContext,
nodeId,
mainClassName,
swirldName,
appVersion,
Expand Down
Expand Up @@ -66,7 +66,7 @@
/**
* Used to construct platform components that use DI
*/
final class PlatformConstructor {
public final class PlatformConstructor {

/** The maximum size of the queue holding signed states ready to be hashed and signed by others. */
private static final int STATE_HASH_QUEUE_MAX = 1;
Expand All @@ -81,15 +81,15 @@ private PlatformConstructor() {}
*
* @param threadManager responsible for managing thread lifecycles
*/
static ParallelExecutor parallelExecutor(final ThreadManager threadManager) {
public static ParallelExecutor parallelExecutor(final ThreadManager threadManager) {
return new CachedPoolParallelExecutor(threadManager, "node-sync");
}

static SettingsProvider settingsProvider() {
public static SettingsProvider settingsProvider() {
return StaticSettingsProvider.getSingleton();
}

static SocketFactory socketFactory(final KeysAndCerts keysAndCerts, final CryptoConfig cryptoConfig) {
public static SocketFactory socketFactory(final KeysAndCerts keysAndCerts, final CryptoConfig cryptoConfig) {
if (!Settings.getInstance().isUseTLS()) {
return new TcpFactory(PlatformConstructor.settingsProvider());
}
Expand All @@ -105,7 +105,8 @@ static SocketFactory socketFactory(final KeysAndCerts keysAndCerts, final Crypto
}
}

static PlatformSigner platformSigner(final KeysAndCerts keysAndCerts) {
public static PlatformSigner platformSigner(@NonNull final KeysAndCerts keysAndCerts) {
Objects.requireNonNull(keysAndCerts);
try {
return new PlatformSigner(keysAndCerts);
} catch (final NoSuchAlgorithmException | NoSuchProviderException | InvalidKeyException e) {
Expand Down

Large diffs are not rendered by default.

0 comments on commit 6057902

Please sign in to comment.