diff --git a/platform-sdk/platform-apps/demos/CryptocurrencyDemo/src/main/java/com/swirlds/demo/crypto/CryptocurrencyDemoMain.java b/platform-sdk/platform-apps/demos/CryptocurrencyDemo/src/main/java/com/swirlds/demo/crypto/CryptocurrencyDemoMain.java index 48aa4341b179..6171ff26c9f0 100644 --- a/platform-sdk/platform-apps/demos/CryptocurrencyDemo/src/main/java/com/swirlds/demo/crypto/CryptocurrencyDemoMain.java +++ b/platform-sdk/platform-apps/demos/CryptocurrencyDemo/src/main/java/com/swirlds/demo/crypto/CryptocurrencyDemoMain.java @@ -143,7 +143,7 @@ public void init(final Platform platform, final NodeId id) { this.platform = platform; this.selfId = id; this.console = createConsole(platform, true); // create the window, make it visible - SwirldsGui.setAbout(platform.getSelfId().getId(), "Cryptocurrency and stock market demo v. 1.0\n"); + SwirldsGui.setAbout(platform.getSelfId().id(), "Cryptocurrency and stock market demo v. 1.0\n"); this.console.addKeyListener(keyListener); } diff --git a/platform-sdk/platform-apps/demos/HashgraphDemo/src/main/java/com/swirlds/demo/hashgraph/HashgraphDemoMain.java b/platform-sdk/platform-apps/demos/HashgraphDemo/src/main/java/com/swirlds/demo/hashgraph/HashgraphDemoMain.java index 53eb0bbfa419..29345ad0d146 100644 --- a/platform-sdk/platform-apps/demos/HashgraphDemo/src/main/java/com/swirlds/demo/hashgraph/HashgraphDemoMain.java +++ b/platform-sdk/platform-apps/demos/HashgraphDemo/src/main/java/com/swirlds/demo/hashgraph/HashgraphDemoMain.java @@ -244,7 +244,7 @@ public void paintComponent(final Graphics g) { print(g, "%5.3f sec, create to consensus", createCons); print(g, "%5.3f sec, receive to consensus", recCons); final Address address = - platform.getAddressBook().getAddress(platform.getSelfId().getId()); + platform.getAddressBook().getAddress(platform.getSelfId().id()); print(g, "Internal: " + Network.getInternalIPAddress() + " : " + address.getPortInternalIpv4(), 0); final ExternalIpAddress ipAddress = Network.getExternalIpAddress(); @@ -392,11 +392,11 @@ private void calcNames() { @Override public void init(final Platform platform, final NodeId id) { this.platform = platform; - this.selfId = id.getId(); + this.selfId = id.id(); final String[] parameters = ((PlatformWithDeprecatedMethods) platform).getParameters(); SwirldsGui.setAbout( - platform.getSelfId().getId(), + platform.getSelfId().id(), "Hashgraph Demo v. 1.1\n" + "\n" + "trans/sec = # transactions added to the hashgraph per second\n" + "events/sec = # events added to the hashgraph per second\n" diff --git a/platform-sdk/platform-apps/demos/HelloSwirldDemo/src/main/java/com/swirlds/demo/hello/HelloSwirldDemoMain.java b/platform-sdk/platform-apps/demos/HelloSwirldDemo/src/main/java/com/swirlds/demo/hello/HelloSwirldDemoMain.java index a398ddd93c11..d5a48f3e03c9 100644 --- a/platform-sdk/platform-apps/demos/HelloSwirldDemo/src/main/java/com/swirlds/demo/hello/HelloSwirldDemoMain.java +++ b/platform-sdk/platform-apps/demos/HelloSwirldDemo/src/main/java/com/swirlds/demo/hello/HelloSwirldDemoMain.java @@ -78,9 +78,9 @@ public void init(final Platform platform, final NodeId id) { platform.getNotificationEngine().register(PlatformStatusChangeListener.class, this::platformStatusChange); this.platform = (SwirldsPlatform) platform; - this.selfId = id.getId(); + this.selfId = id.id(); this.console = createConsole(platform, true); // create the window, make it visible - SwirldsGui.setAbout(platform.getSelfId().getId(), "Hello Swirld v. 1.0\n"); + SwirldsGui.setAbout(platform.getSelfId().id(), "Hello Swirld v. 1.0\n"); this.platform.setSleepAfterSync(sleepPeriod); } diff --git a/platform-sdk/platform-apps/demos/StatsDemo/src/main/java/com/swirlds/demo/stats/StatsDemoMain.java b/platform-sdk/platform-apps/demos/StatsDemo/src/main/java/com/swirlds/demo/stats/StatsDemoMain.java index 62bea5df4768..ad00b9a7a99a 100644 --- a/platform-sdk/platform-apps/demos/StatsDemo/src/main/java/com/swirlds/demo/stats/StatsDemoMain.java +++ b/platform-sdk/platform-apps/demos/StatsDemo/src/main/java/com/swirlds/demo/stats/StatsDemoMain.java @@ -210,7 +210,7 @@ public void init(final Platform platform, final NodeId id) { long syncDelay; this.platform = platform; - selfId = id.getId(); + selfId = id.id(); // parse the config.txt parameters, and allow optional _ as in 1_000_000 final String[] parameters = ((PlatformWithDeprecatedMethods) platform).getParameters(); headless = (parameters[0].equals("1")); @@ -227,7 +227,7 @@ public void init(final Platform platform, final NodeId id) { console = createConsole(platform, true); } SwirldsGui.setAbout( - platform.getSelfId().getId(), + platform.getSelfId().id(), "Stats Demo v. 1.2\nThis writes statistics to a log file," + " such as the number of transactions per second."); ((PlatformWithDeprecatedMethods) platform).setSleepAfterSync(syncDelay); diff --git a/platform-sdk/platform-apps/tests/AddressBookTestingTool/src/main/java/com/swirlds/demo/addressbook/AddressBookTestingToolState.java b/platform-sdk/platform-apps/tests/AddressBookTestingTool/src/main/java/com/swirlds/demo/addressbook/AddressBookTestingToolState.java index 465b8cdf64e2..a5639ec8450d 100644 --- a/platform-sdk/platform-apps/tests/AddressBookTestingTool/src/main/java/com/swirlds/demo/addressbook/AddressBookTestingToolState.java +++ b/platform-sdk/platform-apps/tests/AddressBookTestingTool/src/main/java/com/swirlds/demo/addressbook/AddressBookTestingToolState.java @@ -159,7 +159,7 @@ public void init( parseArguments(((PlatformWithDeprecatedMethods) platform).getParameters()); } - this.selfId = platform.getSelfId().getId(); + this.selfId = platform.getSelfId().id(); } /** diff --git a/platform-sdk/platform-apps/tests/ISSTestingTool/src/main/java/com/swirlds/demo/iss/ISSTestingToolState.java b/platform-sdk/platform-apps/tests/ISSTestingTool/src/main/java/com/swirlds/demo/iss/ISSTestingToolState.java index dea6011e89cc..b4fb7a3422de 100644 --- a/platform-sdk/platform-apps/tests/ISSTestingTool/src/main/java/com/swirlds/demo/iss/ISSTestingToolState.java +++ b/platform-sdk/platform-apps/tests/ISSTestingTool/src/main/java/com/swirlds/demo/iss/ISSTestingToolState.java @@ -141,7 +141,7 @@ public void init( parseArguments(((PlatformWithDeprecatedMethods) platform).getParameters()); } - this.selfId = platform.getSelfId().getId(); + this.selfId = platform.getSelfId().id(); } /** diff --git a/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolMain.java b/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolMain.java index bf92ae9d8c06..8228292cc1d8 100644 --- a/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolMain.java +++ b/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolMain.java @@ -70,11 +70,11 @@ public void init(final Platform platform, final NodeId selfId) { final String[] parameters = ((PlatformWithDeprecatedMethods) platform).getParameters(); logger.info(MARKER, "Parsing arguments {}", (Object) parameters); - seed = Long.parseLong(parameters[0]) + selfId.getId(); + seed = Long.parseLong(parameters[0]) + selfId.id(); maximumTransactionsPerNode = Integer.parseInt(parameters[1]); generator = new TransactionGenerator(seed); - SwirldsGui.setAbout(platform.getSelfId().getId(), "MigrationTestingApp"); + SwirldsGui.setAbout(platform.getSelfId().id(), "MigrationTestingApp"); // Initialize application statistics initAppStats(); diff --git a/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java b/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java index 99da1bb474eb..2ecf9de39757 100644 --- a/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java +++ b/platform-sdk/platform-apps/tests/MigrationTestingTool/src/main/java/com/swirlds/demo/migration/MigrationTestingToolState.java @@ -221,7 +221,7 @@ private void genesisInit(final Platform platform) { .preferDiskBasedIndexes(false); setVirtualMap(new VirtualMap<>("virtualMap", jasperDbBuilder)); - selfId = platform.getSelfId().getId(); + selfId = platform.getSelfId().id(); } /** @@ -242,7 +242,7 @@ public void init( if (virtualMap != null) { logger.info(MARKER, "VirtualMap initialized with {} values", virtualMap.size()); } - selfId = platform.getSelfId().getId(); + selfId = platform.getSelfId().id(); if (trigger == InitTrigger.GENESIS) { logger.error(MARKER, "InitTrigger was {} when expecting RESTART or RECONNECT", trigger); diff --git a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/AppClient.java b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/AppClient.java index 3b991305f5ac..b36766eaf98f 100644 --- a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/AppClient.java +++ b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/AppClient.java @@ -66,7 +66,7 @@ public class AppClient extends Thread { transactionPool = new TransactionPool( platform, - platform.getSelfId().getId(), + platform.getSelfId().id(), payloadConfig, myName, currentConfig.getFcmConfig(), diff --git a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolMain.java b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolMain.java index 1ebac0ae05e4..b62dabc12623 100644 --- a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolMain.java +++ b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolMain.java @@ -537,7 +537,7 @@ public void init(Platform platform, NodeId id) { platform.getNotificationEngine().register(PlatformStatusChangeListener.class, this::platformStatusChange); registerReconnectCompleteListener(); - SwirldsGui.setAbout(selfId.getId(), "Platform Testing Demo"); + SwirldsGui.setAbout(selfId.id(), "Platform Testing Demo"); try { final PlatformTestingToolState state = ((PlatformWithDeprecatedMethods) platform).getState(); @@ -608,8 +608,7 @@ public void init(Platform platform, NodeId id) { final Pair entitiesFirstIds = extractFirstIdForEntitiesFromSavedState(platform); virtualMerkleConfig.setFirstAccountId(entitiesFirstIds.getKey()); virtualMerkleConfig.setFirstSmartContractId(entitiesFirstIds.getValue()); - VirtualMerkleStateInitializer.initStateChildren( - platform, selfId.getId(), virtualMerkleConfig); + VirtualMerkleStateInitializer.initStateChildren(platform, selfId.id(), virtualMerkleConfig); } final Metrics metrics = platform.getContext().getMetrics(); if (state.getVirtualMap() != null) { @@ -629,7 +628,7 @@ public void init(Platform platform, NodeId id) { // through calls to the setFirstAccountId and setFirstSmartContractId methods. transactionPool = new TransactionPool( platform, - platform.getSelfId().getId(), + platform.getSelfId().id(), payloadConfig, myName, currentConfig.getFcmConfig(), @@ -710,7 +709,7 @@ private void initBasedOnPayloadCfgSimple(final PayloadCfgSimple pConfig) { } private void initializeAppClient(final String[] pars, final ObjectMapper objectMapper) throws IOException { - if (pars.length < 2 || !selfId.equalsMain(0)) { + if (pars.length < 2 || !selfId.equals(new NodeId(0L))) { return; } @@ -720,9 +719,9 @@ private void initializeAppClient(final String[] pars, final ObjectMapper objectM for (int k = 0; k < CLIENT_AMOUNT; k++) { appClient[k] = new AppClient( this.platform, - this.selfId.getId(), + this.selfId.id(), clientConfig, - platform.getAddressBook().getAddress(selfId.getId()).getNickname()); + platform.getAddressBook().getAddress(selfId.id()).getNickname()); appClient[k].start(); } } @@ -782,7 +781,7 @@ public void run() { // if single mode only node 0 can submit transactions // if not single mode anyone can submit transactions - if (!submitConfig.isSingleNodeSubmit() || selfId.equalsMain(0)) { + if (!submitConfig.isSingleNodeSubmit() || selfId.equals(new NodeId(0L))) { if (submitConfig.isSubmitInTurn()) { // Delay the start of transactions by interval multiply by node id @@ -952,7 +951,7 @@ private void registerReconnectCompleteListener() { final PlatformTestingToolState state = ((PlatformWithDeprecatedMethods) platform).getState(); state.initControlStructures(this::handleMessageQuorum); SyntheticBottleneckConfig.getActiveConfig() - .registerReconnect(platform.getSelfId().getId()); + .registerReconnect(platform.getSelfId().id()); } finally { ((PlatformWithDeprecatedMethods) platform).releaseState(); } @@ -1088,7 +1087,7 @@ private void handleEnterValidation(final Instant consensusTime) { final PlatformTestingToolState state = ((PlatformWithDeprecatedMethods) platform).getState(); final String expectedMapFile = - createExpectedMapName(platform.getSelfId().getId(), consensusTime); + createExpectedMapName(platform.getSelfId().id(), consensusTime); logger.info( LOGM_DEMO_QUORUM, "Achieved Quorum on ENTER_VALIDATION transaction [ expectedMapFile = {}, consensusTime = {} ]", @@ -1121,7 +1120,7 @@ private void handleEnterValidation(final Instant consensusTime) { }; new ThreadConfiguration(getStaticThreadManager()) - .setNodeId(platform.getSelfId().getId()) + .setNodeId(platform.getSelfId().id()) .setComponent(PTT_COMPONENT) .setThreadName(ENTER_VALIDATION_THREAD_NAME) .setRunnable(fn) @@ -1139,7 +1138,7 @@ private void handleExitValidation(final Instant consensusTime) { // the first node sends a freeze transaction after all transaction finish // This is for guaranteeing that all nodes generated same amount of signed states - if (platform.getSelfId().getId() == 0) { + if (platform.getSelfId().id() == 0) { sendFreezeTransaction(); } @@ -1152,7 +1151,7 @@ private void handleExitValidation(final Instant consensusTime) { }; new ThreadConfiguration(getStaticThreadManager()) - .setNodeId(platform.getSelfId().getId()) + .setNodeId(platform.getSelfId().id()) .setComponent(PTT_COMPONENT) .setThreadName(EXIT_VALIDATION_THREAD_NAME) .setRunnable(fn) diff --git a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolState.java b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolState.java index f07145cde82a..b96e848752ba 100644 --- a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolState.java +++ b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/PlatformTestingToolState.java @@ -592,7 +592,7 @@ public long getLastPurgeTimestamp() { } public synchronized void setPayloadConfig(final FCMConfig fcmConfig) { - expectedFCMFamily.setNodeId(platform.getSelfId().getId()); + expectedFCMFamily.setNodeId(platform.getSelfId().id()); expectedFCMFamily.setFcmConfig(fcmConfig); expectedFCMFamily.setWeightedNodeNum(platform.getAddressBook().getNumberWithWeight()); @@ -615,7 +615,7 @@ public void initChildren() { void initControlStructures(final Action action) { this.controlQuorum = new QuorumTriggeredAction<>( - () -> platform.getSelfId().getId(), + () -> platform.getSelfId().id(), platform.getAddressBook()::getSize, platform.getAddressBook()::getNumberWithWeight, action); @@ -698,7 +698,7 @@ private void delay() { } } SyntheticBottleneckConfig.getActiveConfig() - .throttleIfNeeded(platform.getSelfId().getId()); + .throttleIfNeeded(platform.getSelfId().id()); } /** @@ -816,7 +816,7 @@ private void handleFCMTransaction( serialize( expectedFCMFamily.getExpectedMap(), new File(STORAGE_DIRECTORY), - createExpectedMapName(platform.getSelfId().getId(), timestamp), + createExpectedMapName(platform.getSelfId().id(), timestamp), false); TransactionSubmitter.setForcePauseCanSubmitMore(new AtomicBoolean(false)); logger.info(LOGM_DEMO_INFO, "handling SAVE_EXPECTED_MAP"); @@ -1068,7 +1068,7 @@ private void handleConsensusTransaction( TESTING_EXCEPTIONS_ACCEPTABLE_RECONNECT.getMarker(), "handleConsensusRound Interrupted [ nodeId = {}, round = {} ]. " + "This should happen only during a reconnect", - platform.getSelfId().getId(), + platform.getSelfId().id(), roundNum); Thread.currentThread().interrupt(); } catch (final ExecutionException e) { @@ -1234,7 +1234,7 @@ public void init( setConfig(new PayloadCfgSimple()); } - expectedFCMFamily.setNodeId(platform.getSelfId().getId()); + expectedFCMFamily.setNodeId(platform.getSelfId().id()); expectedFCMFamily.setWeightedNodeNum(platform.getAddressBook().getNumberWithWeight()); // initialize data structures used for FCQueue transaction records expiration diff --git a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/TransactionPool.java b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/TransactionPool.java index 83af1c68ad3a..436d794fd380 100644 --- a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/TransactionPool.java +++ b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/java/com/swirlds/demo/platform/TransactionPool.java @@ -23,6 +23,7 @@ import com.google.protobuf.ByteString; import com.swirlds.common.FastCopyable; +import com.swirlds.common.system.NodeId; import com.swirlds.common.system.Platform; import com.swirlds.common.test.crypto.ECDSASigningProvider; import com.swirlds.common.test.crypto.ED25519SigningProvider; @@ -49,6 +50,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Random; import org.apache.commons.lang3.tuple.Triple; import org.apache.logging.log4j.LogManager; @@ -170,7 +172,9 @@ public TransactionPool( } /** If the startFreezeAfterMin is 0, we don't send freeze transaction */ - if (freezeConfig != null && platform.getSelfId().equalsMain(0) && freezeConfig.getStartFreezeAfterMin() > 0) { + if (freezeConfig != null + && Objects.equals(platform.getSelfId(), new NodeId(0L)) + && freezeConfig.getStartFreezeAfterMin() > 0) { this.freezeConfig = freezeConfig; this.needToSubmitFreezeTx = true; } diff --git a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/MapValueFCQTests.java b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/MapValueFCQTests.java index 7e240c8299ae..8bb819eb6a8e 100644 --- a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/MapValueFCQTests.java +++ b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/MapValueFCQTests.java @@ -84,7 +84,7 @@ public static void setUp() throws ConstructableRegistryException { mapKey = new MapKey(0, 0, random.nextLong()); state = Mockito.spy(PlatformTestingToolState.class); Platform platform = Mockito.spy(PlatformWithDeprecatedMethods.class); - when(platform.getSelfId()).thenReturn(NodeId.createMain(0)); + when(platform.getSelfId()).thenReturn(new NodeId(0L)); AddressBook addressBook = Mockito.spy(AddressBook.class); when(addressBook.getNumberWithWeight()).thenReturn(4); when(platform.getAddressBook()).thenReturn(addressBook); diff --git a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/internal/ExpectedFCMFamilyTest.java b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/internal/ExpectedFCMFamilyTest.java index 08b93ad28b19..3ee00138db67 100644 --- a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/internal/ExpectedFCMFamilyTest.java +++ b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/merkle/map/internal/ExpectedFCMFamilyTest.java @@ -151,7 +151,7 @@ class ExpectedFCMFamilyTest { static { platform = Mockito.mock(Platform.class); - Mockito.when(platform.getSelfId()).thenReturn(NodeId.createMain(0)); + Mockito.when(platform.getSelfId()).thenReturn(new NodeId(0L)); } @BeforeAll diff --git a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/platform/TransactionPoolTest.java b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/platform/TransactionPoolTest.java index db5a30cb1489..31063448ed65 100644 --- a/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/platform/TransactionPoolTest.java +++ b/platform-sdk/platform-apps/tests/PlatformTestingTool/src/test/java/com/swirlds/demo/platform/TransactionPoolTest.java @@ -72,7 +72,7 @@ public class TransactionPoolTest { static { platform = Mockito.mock(Platform.class); - Mockito.when(platform.getSelfId()).thenReturn(NodeId.createMain(myID)); + Mockito.when(platform.getSelfId()).thenReturn(new NodeId(myID)); System.arraycopy(payload, 0, payloadWithSig, 0, payload.length); expectedFCMFamily = new DummyExpectedFCMFamily(myID); fCMFamily = new FCMFamily(true); diff --git a/platform-sdk/platform-apps/tests/StatsSigningTestingTool/src/main/java/com/swirlds/demo/stats/signing/StatsSigningTestingToolMain.java b/platform-sdk/platform-apps/tests/StatsSigningTestingTool/src/main/java/com/swirlds/demo/stats/signing/StatsSigningTestingToolMain.java index 27e9325b9613..b64a1d42f2a3 100644 --- a/platform-sdk/platform-apps/tests/StatsSigningTestingTool/src/main/java/com/swirlds/demo/stats/signing/StatsSigningTestingToolMain.java +++ b/platform-sdk/platform-apps/tests/StatsSigningTestingTool/src/main/java/com/swirlds/demo/stats/signing/StatsSigningTestingToolMain.java @@ -160,7 +160,7 @@ public void init(final Platform platform, final NodeId id) { final long syncDelay; this.platform = platform; - selfId = id.getId(); + selfId = id.id(); // parse the config.txt parameters, and allow optional _ as in 1_000_000 final String[] parameters = ((PlatformWithDeprecatedMethods) platform).getParameters(); headless = (parameters[0].equals("1")); @@ -184,13 +184,13 @@ public void init(final Platform platform, final NodeId id) { transPerEventMax = 1024; } SwirldsGui.setAbout( - platform.getSelfId().getId(), + platform.getSelfId().id(), "Stats Signing Demo v. 1.3\nThis writes statistics to a log file," + " such as the number of transactions per second."); ((PlatformWithDeprecatedMethods) platform).setSleepAfterSync(syncDelay); transactionPool = new TransactionPool( - platform.getSelfId().getId(), + platform.getSelfId().id(), signedTransPoolSize, bytesPerTrans, true, @@ -205,7 +205,7 @@ public void init(final Platform platform, final NodeId id) { public void run() { final Thread shutdownHook = new ThreadConfiguration(getStaticThreadManager()) .setDaemon(false) - .setNodeId(platform.getSelfId().getId()) + .setNodeId(platform.getSelfId().id()) .setComponent("app") .setThreadName("demo_log_time_pulse") .setRunnable(() -> { diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/noop/NoOpMetrics.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/noop/NoOpMetrics.java index b79288de7628..317fb04df2d6 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/noop/NoOpMetrics.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/noop/NoOpMetrics.java @@ -42,7 +42,7 @@ public class NoOpMetrics implements Metrics { @Override public NodeId getNodeId() { - return NodeId.createMain(42L); + return new NodeId(42L); } @Override diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/LegacyCsvWriter.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/LegacyCsvWriter.java index 40e6b33f3429..91a837c4d7b4 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/LegacyCsvWriter.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/LegacyCsvWriter.java @@ -109,7 +109,7 @@ public LegacyCsvWriter(final NodeId selfId, final Path folderPath, final Metrics throwArgNull(folderPath, "folderPath"); this.metricsConfig = throwArgNull(metricsConfig, "metricsConfig"); - final String fileName = String.format("%s%d.csv", metricsConfig.csvFileName(), selfId.getId()); + final String fileName = String.format("%s%d.csv", metricsConfig.csvFileName(), selfId.id()); this.csvFilePath = folderPath.resolve(fileName); } diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapter.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapter.java index cc7c7b097a54..cc3b9e6a0eec 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapter.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapter.java @@ -77,7 +77,7 @@ public void update(final Snapshot snapshot, final NodeId nodeId) { gauge.set(newValue); } else { throwArgNull(nodeId, "nodeId"); - final Gauge.Child child = gauge.labels(Long.toString(nodeId.getId())); + final Gauge.Child child = gauge.labels(Long.toString(nodeId.id())); child.set(newValue); } } diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapter.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapter.java index ecc1e80ff93a..ae7bda42d79b 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapter.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapter.java @@ -78,7 +78,7 @@ public void update(final Snapshot snapshot, final NodeId nodeId) { counter.inc(newValue - oldValue); } else { throwArgNull(nodeId, "nodeId"); - final Counter.Child child = counter.labels(Long.toString(nodeId.getId())); + final Counter.Child child = counter.labels(Long.toString(nodeId.id())); final double oldValue = child.get(); child.inc(newValue - oldValue); } diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapter.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapter.java index fd7595473f86..d780a4f70da2 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapter.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapter.java @@ -86,7 +86,7 @@ public void update(final Snapshot snapshot, final NodeId nodeId) { }; final Gauge.Child child = adapterType == GLOBAL ? gauge.labels(valueType) - : gauge.labels(Long.toString(nodeId.getId()), valueType); + : gauge.labels(Long.toString(nodeId.id()), valueType); child.set(((Number) entry.value()).doubleValue()); } } diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapter.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapter.java index 606512c02b07..5a315a3d54e7 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapter.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapter.java @@ -75,7 +75,7 @@ public void update(final Snapshot snapshot, final NodeId nodeId) { gauge.set(newValue); } else { throwArgNull(nodeId, "nodeId"); - final Gauge.Child child = gauge.labels(Long.toString(nodeId.getId())); + final Gauge.Child child = gauge.labels(Long.toString(nodeId.id())); child.set(newValue); } } diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/StringAdapter.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/StringAdapter.java index 5180cc522110..84b79ad3b863 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/StringAdapter.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/metrics/platform/prometheus/StringAdapter.java @@ -75,7 +75,7 @@ public void update(final Snapshot snapshot, final NodeId nodeId) { info.info("value", newValue); } else { throwArgNull(nodeId, "nodeId"); - final Info.Child child = info.labels(Long.toString(nodeId.getId())); + final Info.Child child = info.labels(Long.toString(nodeId.id())); child.info("value", newValue); } } diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/stream/EventStreamManager.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/stream/EventStreamManager.java index f9f6f48ab334..760d981aa0be 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/stream/EventStreamManager.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/stream/EventStreamManager.java @@ -120,7 +120,7 @@ public EventStreamManager( EventStreamType.getInstance()); writeQueueThread = new QueueThreadObjectStreamConfiguration(threadManager) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent("event-stream") .setThreadName("write-queue") .setCapacity(eventStreamQueueCapacity) @@ -147,7 +147,7 @@ public EventStreamManager( final RunningHashCalculatorForStream runningHashCalculator = new RunningHashCalculatorForStream<>(); hashCalculator = new HashCalculatorForStream<>(runningHashCalculator); hashQueueThread = new QueueThreadObjectStreamConfiguration(threadManager) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent("event-stream") .setThreadName("hash-queue") .setForwardTo(hashCalculator) diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/NodeId.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/NodeId.java index 83d60dd8ead1..9efa0fd20b91 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/NodeId.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/NodeId.java @@ -16,148 +16,47 @@ package com.swirlds.common.system; +import edu.umd.cs.findbugs.annotations.NonNull; +import java.util.Objects; + /** - * A class that is used to uniquely identify a Swirlds Node + * A class that is used to uniquely identify a Swirlds Node. + * + * @param id ID number unique within the network */ -public class NodeId implements EventCreationRule { - /** used to distinguish between a main node and a mirror node */ - private boolean isMirror; - /** ID number unique within the network, unique set for main network and mirror network */ - private long id; - - /** - * Constructs a NodeId object - * - * @param isMirror - * is it a mirror node or main node - * @param id - * the ID number - */ - public NodeId(boolean isMirror, long id) { - this.isMirror = isMirror; - this.id = id; - } +public record NodeId(long id) implements Comparable { - /** - * Constructs a main network NodeId object - * - * @param id - * the ID number - * @return the object created - */ - public static NodeId createMain(long id) { - return new NodeId(false, id); - } - - /** - * Constructs a mirror network NodeId object - * - * @param id - * the ID number - * @return the object created - */ - static NodeId createMirror(long id) { - return new NodeId(true, id); - } + /** The first allowed Node ID. */ + public static final long LOWEST_NODE_NUMBER = 0L; /** - * Checks if two IDs belong to the same network + * Constructs a NodeId object with the given ID number. The ID number must be non-negative. * - * @param nodeId - * the NodeId to compare to - * @return true if networks are the same, false if not + * @param id the ID number + * @throws IllegalArgumentException if the ID number is negative */ - public boolean sameNetwork(NodeId nodeId) { - return this.isMirror() == nodeId.isMirror(); - } - - private boolean equals(boolean isMirror, long id) { - return this.isMirror() == isMirror && id == this.getId(); + public NodeId { + if (id < LOWEST_NODE_NUMBER) { + throw new IllegalArgumentException("id must be non-negative"); + } } /** * {@inheritDoc} */ @Override - public boolean equals(Object obj) { - if (!(obj instanceof NodeId)) { - throw new IllegalArgumentException("obj must be a NodeId object"); - } - return equals((NodeId) obj); - } - - @Override - public int hashCode() { - return Boolean.hashCode(isMirror) + Long.hashCode(id); - } - - /** - * Checks if IDs are equal - * - * @param nodeId - * the NodeId to compare - * @return true if equal, false if not - */ - public boolean equals(NodeId nodeId) { - return equals(nodeId.isMirror(), nodeId.getId()); - } - - /** - * Checks if this NodeId is main network and if the ID value is equal - * - * @param id - * the ID value to compare - * @return true if this is a main network ID and its ID value is equal to the supplied value, false if either of - * these conditions are not true - */ - public boolean equalsMain(long id) { - return equals(false, id); - } - - /** - * Checks if this NodeId is mirror network and if the ID value is equal - * - * @param id - * the ID value to compare - * @return true if this is a mirror network ID and its ID value is equal to the supplied value, false if either of - * these conditions are not true - */ - public boolean equalsMirror(long id) { - return equals(true, id); - } - - /** - * Check if ID is part of mirror network - * - * @return true if this ID is part of the mirror network, false if not - */ - public boolean isMirror() { - return isMirror; - } - - /** - * Check if ID is part of main network - * - * @return true if this ID is part of the main network, false if not - */ - public boolean isMain() { - return !isMirror; - } - - /** - * Check if numeric part of this ID - * - * @return the numeric part of this ID - */ - public long getId() { - return id; + public int compareTo(@NonNull final NodeId other) { + Objects.requireNonNull(other, "NodeId cannot be null"); + return Long.compare(this.id, other.id); } /** * get numeric part of ID and cast to an Integer * * @return the numeric part of this ID, cast to an integer + * @deprecated use {@link #id()} instead. */ + @Deprecated(since = "0.39.0", forRemoval = true) public int getIdAsInt() { return (int) id; } @@ -165,21 +64,9 @@ public int getIdAsInt() { /** * {@inheritDoc} */ + @NonNull @Override public String toString() { - return (isMirror ? "m" : "") + id; - } - - /** - * {@inheritDoc} - */ - @Override - public EventCreationRuleResponse shouldCreateEvent() { - // Only main nodes should create events - if (isMain()) { - return EventCreationRuleResponse.PASS; - } else { - return EventCreationRuleResponse.DONT_CREATE; - } + return Long.toString(id); } } diff --git a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/PlatformIdentity.java b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/PlatformIdentity.java index f5fd4d8f3f1f..9c5392cdbbda 100644 --- a/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/PlatformIdentity.java +++ b/platform-sdk/swirlds-common/src/main/java/com/swirlds/common/system/PlatformIdentity.java @@ -44,7 +44,7 @@ public interface PlatformIdentity { * @return this node's address */ default Address getSelfAddress() { - return getAddressBook().getAddress(getSelfId().getId()); + return getAddressBook().getAddress(getSelfId().id()); } /** diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/context/internal/DefaultPlatformContextTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/context/internal/DefaultPlatformContextTest.java index f30bac2c02d4..6bfec3513c62 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/context/internal/DefaultPlatformContextTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/context/internal/DefaultPlatformContextTest.java @@ -33,7 +33,7 @@ class DefaultPlatformContextTest { void testNoNullServices() { // given final Configuration configuration = new TestConfigBuilder().getOrCreateConfig(); - final NodeId nodeId = new NodeId(false, 3256733545L); + final NodeId nodeId = new NodeId(3256733545L); final MetricsProvider metricsProvider = new DefaultMetricsProvider(configuration); metricsProvider.createGlobalMetrics(); diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/DefaultMetricsTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/DefaultMetricsTest.java index 7991029e1295..635d5096f7c8 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/DefaultMetricsTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/DefaultMetricsTest.java @@ -54,7 +54,7 @@ @ExtendWith(MockitoExtension.class) class DefaultMetricsTest { - private static final NodeId NODE_ID = NodeId.createMain(42L); + private static final NodeId NODE_ID = new NodeId(42L); private static final String CATEGORY_1 = "CaTeGoRy1"; private static final String CATEGORY_1a = "CaTeGoRy1.a"; private static final String CATEGORY_1b = "CaTeGoRy1.b"; diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/LegacyCsvWriterTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/LegacyCsvWriterTest.java index f98ecf6ce313..fd082ca0307a 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/LegacyCsvWriterTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/LegacyCsvWriterTest.java @@ -51,7 +51,7 @@ class LegacyCsvWriterTest { - private static final NodeId NODE_ID = NodeId.createMain(42L); + private static final NodeId NODE_ID = new NodeId(42L); private Metrics metrics; private MetricsConfig metricsConfig; diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/MetricKeyRegistrationTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/MetricKeyRegistrationTest.java index bda6cd97a061..2ffa1f7d2570 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/MetricKeyRegistrationTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/MetricKeyRegistrationTest.java @@ -26,7 +26,7 @@ class MetricKeyRegistrationTest { - private static final NodeId NODE_ID = NodeId.createMain(1L); + private static final NodeId NODE_ID = new NodeId(1L); private static final String METRIC_KEY = calculateMetricKey("CaTeGoRy", "NaMe"); @Test @@ -98,7 +98,7 @@ void testAddingExistingPlatformMetricForOtherPlatform() { registry.register(NODE_ID, METRIC_KEY, Counter.class); // when - final boolean result = registry.register(NodeId.createMain(111L), METRIC_KEY, Counter.class); + final boolean result = registry.register(new NodeId(111L), METRIC_KEY, Counter.class); // then assertThat(result).isTrue(); @@ -187,7 +187,7 @@ void testAddingPlatformMetricWhenGlobalMetricWasDeleted() { @Test void testAddingGlobalMetricWhenOnlyOnePlatformMetricWasDeleted() { // given - final NodeId nodeId2 = NodeId.createMain(111L); + final NodeId nodeId2 = new NodeId(111L); final MetricKeyRegistry registry = new MetricKeyRegistry(); registry.register(NODE_ID, METRIC_KEY, Counter.class); registry.register(nodeId2, METRIC_KEY, Counter.class); diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/SnapshotServiceTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/SnapshotServiceTest.java index 937873e016a9..2905107c325a 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/SnapshotServiceTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/SnapshotServiceTest.java @@ -55,8 +55,8 @@ @ExtendWith(MockitoExtension.class) class SnapshotServiceTest { - private static final NodeId NODE_ID_1 = NodeId.createMain(1L); - private static final NodeId NODE_ID_2 = NodeId.createMain(2L); + private static final NodeId NODE_ID_1 = new NodeId(1L); + private static final NodeId NODE_ID_2 = new NodeId(2L); @Mock private DefaultMetric globalMetric; diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapterTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapterTest.java index a12bf293997e..7d09032044d1 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapterTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/BooleanAdapterTest.java @@ -145,7 +145,7 @@ void testUpdatePlatformMetric() { final BooleanAdapter adapter = new BooleanAdapter(registry, metric, PLATFORM); // when - adapter.update(Snapshot.of(metric), NodeId.createMain(1L)); + adapter.update(Snapshot.of(metric), new NodeId(1L)); // then assertThat(registry.getSampleValue(MAPPING_NAME, NODE_LABEL, NODE_VALUE)) @@ -159,7 +159,7 @@ void testUpdateWithNullParameters() { final DefaultFunctionGauge metric = new DefaultFunctionGauge<>(new FunctionGauge.Config<>(CATEGORY, NAME, Boolean.class, () -> true)); final BooleanAdapter adapter = new BooleanAdapter(registry, metric, PLATFORM); - final NodeId nodeId = NodeId.createMain(1L); + final NodeId nodeId = new NodeId(1L); // then assertThatThrownBy(() -> adapter.update(null, null)).isInstanceOf(IllegalArgumentException.class); diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapterTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapterTest.java index a3579ebda854..5cc906ef2ad7 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapterTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/CounterAdapterTest.java @@ -142,7 +142,7 @@ void testUpdatePlatformMetric() { final CounterAdapter adapter = new CounterAdapter(registry, metric, PLATFORM); // when - adapter.update(Snapshot.of(metric), NodeId.createMain(1L)); + adapter.update(Snapshot.of(metric), new NodeId(1L)); // then assertThat(registry.getSampleValue(MAPPING_NAME + "_total", NODE_LABEL, NODE_VALUE)) @@ -155,7 +155,7 @@ void testUpdateWithNullParameters() { final CollectorRegistry registry = new CollectorRegistry(); final DefaultCounter metric = new DefaultCounter(new Counter.Config(CATEGORY, NAME)); final CounterAdapter adapter = new CounterAdapter(registry, metric, PLATFORM); - final NodeId nodeId = NodeId.createMain(1L); + final NodeId nodeId = new NodeId(1L); // then assertThatThrownBy(() -> adapter.update(null, null)).isInstanceOf(IllegalArgumentException.class); diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapterTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapterTest.java index 4921b24cd8c1..aaf24070ed8a 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapterTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/DistributionAdapterTest.java @@ -155,7 +155,7 @@ void testUpdatePlatformMetric() { final DistributionAdapter adapter = new DistributionAdapter(registry, metric, PLATFORM); // when - adapter.update(Snapshot.of(metric), NodeId.createMain(1L)); + adapter.update(Snapshot.of(metric), new NodeId(1L)); // then assertThat(registry.getSampleValue(MAPPING_NAME, NODE_LABEL, new String[] {"1", "mean"})) @@ -175,7 +175,7 @@ void testUpdateWithNullParameters() { final DefaultRunningAverageMetric metric = new DefaultRunningAverageMetric(new RunningAverageMetric.Config(CATEGORY, NAME)); final DistributionAdapter adapter = new DistributionAdapter(registry, metric, PLATFORM); - final NodeId nodeId = NodeId.createMain(1L); + final NodeId nodeId = new NodeId(1L); // then assertThatThrownBy(() -> adapter.update(null, null)).isInstanceOf(IllegalArgumentException.class); diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapterTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapterTest.java index 0e9dfc012f63..28fe7c7eed09 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapterTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/NumberAdapterTest.java @@ -145,7 +145,7 @@ void testUpdatePlatformMetric() { final NumberAdapter adapter = new NumberAdapter(registry, metric, PLATFORM); // when - adapter.update(Snapshot.of(metric), NodeId.createMain(1L)); + adapter.update(Snapshot.of(metric), new NodeId(1L)); // then assertThat(registry.getSampleValue(MAPPING_NAME, NODE_LABEL, NODE_VALUE)) @@ -158,7 +158,7 @@ void testUpdateWithNullParameters() { final CollectorRegistry registry = new CollectorRegistry(); final DefaultIntegerGauge metric = new DefaultIntegerGauge(new IntegerGauge.Config(CATEGORY, NAME)); final NumberAdapter adapter = new NumberAdapter(registry, metric, PLATFORM); - final NodeId nodeId = NodeId.createMain(1L); + final NodeId nodeId = new NodeId(1L); // then assertThatThrownBy(() -> adapter.update(null, null)).isInstanceOf(IllegalArgumentException.class); diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/PrometheusEndpointTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/PrometheusEndpointTest.java index 07b120a48268..3afff41372e9 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/PrometheusEndpointTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/PrometheusEndpointTest.java @@ -79,10 +79,10 @@ class PrometheusEndpointTest { private static final String CATEGORY = "CaTeGoRy"; private static final String NAME = "NaMe"; - private static final NodeId NODE_ID_1 = NodeId.createMain(1L); - private static final String LABEL_1 = String.valueOf(NODE_ID_1.getId()); - private static final NodeId NODE_ID_2 = NodeId.createMain(2L); - private static final String LABEL_2 = String.valueOf(NODE_ID_2.getId()); + private static final NodeId NODE_ID_1 = new NodeId(1L); + private static final String LABEL_1 = String.valueOf(NODE_ID_1.id()); + private static final NodeId NODE_ID_2 = new NodeId(2L); + private static final String LABEL_2 = String.valueOf(NODE_ID_2.id()); private static final InetSocketAddress ADDRESS = new InetSocketAddress(0); diff --git a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/StringAdapterTest.java b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/StringAdapterTest.java index 776435bda13c..f10c264544e7 100644 --- a/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/StringAdapterTest.java +++ b/platform-sdk/swirlds-common/src/test/java/com/swirlds/common/metrics/platform/prometheus/StringAdapterTest.java @@ -148,7 +148,7 @@ void testUpdatePlatformMetric() { final StringAdapter adapter = new StringAdapter(registry, metric, PLATFORM); // when - adapter.update(Snapshot.of(metric), NodeId.createMain(1L)); + adapter.update(Snapshot.of(metric), new NodeId(1L)); // then assertThat(registry.getSampleValue(MAPPING_NAME + "_info", NODE_LABEL, new String[] {"1", "Hello World"})) @@ -162,7 +162,7 @@ void testUpdateWithNullParameters() { final DefaultFunctionGauge metric = new DefaultFunctionGauge<>( new FunctionGauge.Config<>(CATEGORY, NAME, String.class, () -> "Hello World")); final StringAdapter adapter = new StringAdapter(registry, metric, PLATFORM); - final NodeId nodeId = NodeId.createMain(1L); + final NodeId nodeId = new NodeId(1L); // then assertThatThrownBy(() -> adapter.update(null, null)).isInstanceOf(IllegalArgumentException.class); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/Browser.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/Browser.java index 846da391c994..0faafb74f405 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/Browser.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/Browser.java @@ -624,7 +624,7 @@ private Collection createLocalPlatforms( + " - " + address.getSelfName() + " - " + infoSwirld.name + " - " + infoSwirld.app.name; - final NodeId nodeId = NodeId.createMain(i); + final NodeId nodeId = new NodeId(i); final PlatformContext platformContext = new DefaultPlatformContext(nodeId, metricsProvider, configuration); @@ -693,7 +693,7 @@ private Collection createLocalPlatforms( appMain.init(platform, nodeId); final Thread appThread = new ThreadConfiguration(getStaticThreadManager()) - .setNodeId(nodeId.getId()) + .setNodeId(nodeId.id()) .setComponent("app") .setThreadName("appMain") .setRunnable(appMain) diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java index 2f19b005fdd3..6c697551cae5 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/SwirldsPlatform.java @@ -633,9 +633,9 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods, if (chatterConfig.useChatter()) { criticalQuorum = new CriticalQuorumImpl( - metrics, selfId.getId(), initialAddressBook, false, chatterConfig.criticalQuorumSoftening()); + metrics, selfId.id(), initialAddressBook, false, chatterConfig.criticalQuorumSoftening()); } else { - criticalQuorum = new CriticalQuorumImpl(metrics, selfId.getId(), initialAddressBook); + criticalQuorum = new CriticalQuorumImpl(metrics, selfId.id(), initialAddressBook); } final LoadedState loadedState = initializeLoadedStateFromSignedState(loadedSignedState); @@ -644,7 +644,7 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods, // Queue thread that stores and handles signed states that need to be hashed and have signatures collected. final QueueThread stateHashSignQueueThread = PlatformConstructor.stateHashSignQueue( - threadManager, selfId.getId(), stateManagementComponent::newSignedStateFromTransactions); + threadManager, selfId.id(), stateManagementComponent::newSignedStateFromTransactions); stateHashSignQueueThread.start(); final State stateToLoad; @@ -688,7 +688,7 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods, consensusRoundHandler = components.add(PlatformConstructor.consensusHandler( platformContext, threadManager, - selfId.getId(), + selfId.id(), PlatformConstructor.settingsProvider(), swirldStateManager, new ConsensusHandlingMetrics(metrics, time), @@ -825,7 +825,7 @@ public class SwirldsPlatform implements Platform, PlatformWithDeprecatedMethods, } intakeQueue = components.add(new QueueThreadConfiguration(threadManager) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) .setThreadName("event-intake") .setHandler(intakeHandler) @@ -1201,7 +1201,7 @@ private PreConsensusEventWriter buildPreConsensusEventWriter() { final PreConsensusEventFileManager fileManager; try { - fileManager = new PreConsensusEventFileManager(platformContext, OSTime.getInstance(), selfId.getId()); + fileManager = new PreConsensusEventFileManager(platformContext, OSTime.getInstance(), selfId.id()); } catch (final IOException e) { throw new UncheckedIOException("unable load preconsensus files", e); } @@ -1221,8 +1221,8 @@ public void start() { intakeQueue, topology.getConnectionGraph(), selfId, - new EventCreationRules(List.of( - selfId, swirldStateManager.getTransactionPool(), startUpEventFrozenManager, freezeManager)), + new EventCreationRules( + List.of(swirldStateManager.getTransactionPool(), startUpEventFrozenManager, freezeManager)), criticalQuorum, initialAddressBook, fallenBehindManager)); @@ -1396,7 +1396,7 @@ public StaticConnectionManagers startCommonNetwork() { inboundConnectionHandler::handle); new StoppableThreadConfiguration<>(threadManager) .setPriority(settings.getThreadPrioritySync()) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) .setThreadName("connectionServer") .setWork(connectionServer) @@ -1417,7 +1417,7 @@ public void startChatterNetwork() { // first create all instances because of thread safety for (final NodeId otherId : topology.getNeighbors()) { - chatterCore.newPeerInstance(otherId.getId(), eventTaskCreator::addEvent); + chatterCore.newPeerInstance(otherId.id(), eventTaskCreator::addEvent); } // If we still need an emergency recovery state, we need it via emergency reconnect. @@ -1431,7 +1431,7 @@ public void startChatterNetwork() { final ParallelExecutor parallelExecutor = new CachedPoolParallelExecutor(threadManager, "chatter"); parallelExecutor.start(); for (final NodeId otherId : topology.getNeighbors()) { - final PeerInstance chatterPeer = chatterCore.getPeerInstance(otherId.getId()); + final PeerInstance chatterPeer = chatterCore.getPeerInstance(otherId.id()); final ParallelExecutor shadowgraphExecutor = PlatformConstructor.parallelExecutor(threadManager); shadowgraphExecutor.start(); final ShadowGraphSynchronizer chatterSynchronizer = new ShadowGraphSynchronizer( @@ -1453,9 +1453,9 @@ public void startChatterNetwork() { chatterThreads.add(new StoppableThreadConfiguration<>(threadManager) .setPriority(Thread.NORM_PRIORITY) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) - .setOtherNodeId(otherId.getId()) + .setOtherNodeId(otherId.id()) .setThreadName("ChatterReader") .setHangingThreadPeriod(basicConfig.hangingThreadDuration()) .setWork(new NegotiatorThread( @@ -1598,9 +1598,9 @@ public void startSyncNetwork() { // create and start new threads to listen for incoming sync requests new StoppableThreadConfiguration<>(threadManager) .setPriority(Thread.NORM_PRIORITY) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) - .setOtherNodeId(otherId.getId()) + .setOtherNodeId(otherId.id()) .setThreadName("listener") .setWork(new Listener(protocolHandlers, connectionManagers.getManager(otherId, false))) .build() @@ -1609,10 +1609,10 @@ public void startSyncNetwork() { // create and start new thread to send heartbeats on the SyncCaller channels new StoppableThreadConfiguration<>(threadManager) .setPriority(settings.getThreadPrioritySync()) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) .setThreadName("heartbeat") - .setOtherNodeId(otherId.getId()) + .setOtherNodeId(otherId.id()) .setWork(new HeartbeatSender( otherId, sharedConnectionLocks, networkMetrics, PlatformConstructor.settingsProvider())) .build() @@ -1646,16 +1646,16 @@ private void startSyncAsProtocolNetwork(@NonNull final StaticConnectionManagers if (initialAddressBook.getSize() == 1) { syncProtocolThreads.add(new StoppableThreadConfiguration<>(threadManager) .setPriority(Thread.NORM_PRIORITY) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) - .setOtherNodeId(selfId.getId()) + .setOtherNodeId(selfId.id()) .setThreadName("SingleNodeNetworkSync") .setHangingThreadPeriod(hangingThreadDuration) .setWork(new SingleNodeNetworkSync( this::checkPlatformStatus, eventTaskCreator::createEvent, this::getSleepAfterSync, - selfId.getId())) + selfId.id())) .build(true)); return; @@ -1674,10 +1674,10 @@ private void startSyncAsProtocolNetwork(@NonNull final StaticConnectionManagers for (final NodeId otherId : topology.getNeighbors()) { syncProtocolThreads.add(new StoppableThreadConfiguration<>(threadManager) .setPriority(Thread.NORM_PRIORITY) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) - .setOtherNodeId(otherId.getId()) - .setThreadName("SyncProtocolWith" + otherId.getId()) + .setOtherNodeId(otherId.id()) + .setThreadName("SyncProtocolWith" + otherId.id()) .setHangingThreadPeriod(hangingThreadDuration) .setWork(new NegotiatorThread( connectionManagers.getManager(otherId, topology.shouldConnectTo(otherId)), @@ -1739,7 +1739,7 @@ private void spawnSyncCaller(final int callerNumber) { /* the thread that repeatedly initiates syncs with other members */ final Thread syncCallerThread = new ThreadConfiguration(threadManager) .setPriority(settings.getThreadPrioritySync()) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) .setThreadName("syncCaller-" + callerNumber) .setRunnable(syncCaller) diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventCreator.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventCreator.java index ae5a73aefc7a..e4bb4f3dd114 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventCreator.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventCreator.java @@ -184,7 +184,7 @@ protected EventImpl buildEvent(final EventImpl selfParent, final EventImpl other final BaseEventHashedData hashedData = new BaseEventHashedData( softwareVersion, - selfId.getId(), + selfId.id(), EventUtils.getEventGeneration(selfParent), EventUtils.getEventGeneration(otherParent), EventUtils.getEventHash(selfParent), @@ -208,7 +208,7 @@ protected EventImpl buildEvent(final EventImpl selfParent, final EventImpl other * the ID of the node supplying the other parent */ protected boolean hasOtherParentAlreadyBeenUsed(final long otherId) { - return !selfId.equalsMain(otherId) && eventMapper.hasMostRecentEventBeenUsedAsOtherParent(otherId); + return selfId.id() != otherId && eventMapper.hasMostRecentEventBeenUsedAsOtherParent(otherId); } /** diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventMapper.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventMapper.java index 5c5e2252c687..318997ce68d0 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventMapper.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventMapper.java @@ -61,7 +61,7 @@ public EventMapper(@NonNull final Metrics metrics, @NonNull final NodeId selfId) mappings = new HashMap<>(); metrics.getOrCreate(new FunctionGauge.Config<>( - INFO_CATEGORY, "lastGen", Long.class, () -> getHighestGenerationNumber(selfId.getId())) + INFO_CATEGORY, "lastGen", Long.class, () -> getHighestGenerationNumber(selfId.id())) .withDescription("last event generation number by me") .withFormat("%d")); } @@ -116,7 +116,7 @@ public synchronized EventImpl getMostRecentEvent(final long nodeId) { */ @Override public synchronized EventImpl getMostRecentSelfEvent() { - return getMostRecentEvent(selfId.getId()); + return getMostRecentEvent(selfId.id()); } /** diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventTaskCreator.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventTaskCreator.java index d5f6bdd3063d..7c9d2afeb824 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventTaskCreator.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/EventTaskCreator.java @@ -127,7 +127,7 @@ public void syncDone(final SyncResult result) { return; } - createEvent(result.getOtherId().getId()); + createEvent(result.getOtherId().id()); logger.debug(SYNC.getMarker(), "{} created event for sync otherId:{}", selfId, result.getOtherId()); @@ -142,7 +142,7 @@ private void randomEvent() { if (settings.getRandomEventProbability() > 0 && r.nextInt(settings.getRandomEventProbability()) == 0) { final long randomOtherId = r.nextInt(addressBook.getSize()); // we don't want to create an event with selfId==otherId - if (!selfId.equalsMain(randomOtherId)) { + if (selfId.id() != randomOtherId) { createEvent(randomOtherId); logger.debug(SYNC.getMarker(), "{} created random event otherId:{}", selfId, randomOtherId); } @@ -161,7 +161,7 @@ public void rescueChildlessEvents() { } for (int i = 0; i < addressBook.getSize(); i++) { - if (selfId.equalsMain(i)) { + if (selfId.id() == i) { // we don't rescue our own event, this might have been the cause of a reconnect issue continue; } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/state/DefaultStateManagementComponent.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/state/DefaultStateManagementComponent.java index b9e5e7a9e25a..2f03b5211940 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/state/DefaultStateManagementComponent.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/components/state/DefaultStateManagementComponent.java @@ -254,7 +254,7 @@ public DefaultStateManagementComponent( OSTime.getInstance(), dispatchBuilder, stateConfig, - selfId.getId(), + selfId.id(), haltRequestedConsumer, fatalErrorConsumer, issConsumer); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/EventCreatorThread.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/EventCreatorThread.java index c9e7288f6a8d..f115dc1d2f07 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/EventCreatorThread.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/EventCreatorThread.java @@ -65,13 +65,13 @@ public EventCreatorThread( this.random = random; this.otherNodes = StreamSupport.stream(addressBook.spliterator(), false) // don't create events with self as other parent - .filter(a -> !selfId.equalsMain(a.getId())) - .map(a -> NodeId.createMain(a.getId())) + .filter(a -> selfId.id() != a.getId()) + .map(a -> new NodeId(a.getId())) .collect(Collectors.toList()); creatorThread = new StoppableThreadConfiguration<>(threadManager) .setPriority(Thread.NORM_PRIORITY) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setMaximumRate(attemptedChatterEventPerSecond) .setComponent("Chatter") .setThreadName("EventGenerator") @@ -86,12 +86,12 @@ public EventCreatorThread( public void createEvent() { // in case of a single node network, create events that have self as the other parent if (otherNodes.isEmpty()) { - this.eventCreator.apply(selfId.getId()); + this.eventCreator.apply(selfId.id()); return; } Collections.shuffle(otherNodes, random); for (final NodeId neighbor : otherNodes) { - if (this.eventCreator.apply(neighbor.getId())) { + if (this.eventCreator.apply(neighbor.id())) { // try all neighbors until we create an event break; } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/creation/ChatterEventCreator.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/creation/ChatterEventCreator.java index 73ee65828d8b..213659d53ae3 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/creation/ChatterEventCreator.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/creation/ChatterEventCreator.java @@ -104,7 +104,7 @@ public boolean createEvent(final long otherId) { if (basicRulesResponse == EventCreationRuleResponse.DONT_CREATE) { return false; } - final GossipEvent selfParent = mostRecentEventById.apply(selfId.getId()); + final GossipEvent selfParent = mostRecentEventById.apply(selfId.id()); final GossipEvent otherParent = mostRecentEventById.apply(otherId); // if the basic rules returned a CREATE, this overrides all subsequent rules, so we don't check the parent based // rules @@ -130,7 +130,7 @@ private GossipEvent buildEvent(final BaseEvent selfParent, final BaseEvent other final BaseEventHashedData hashedData = new BaseEventHashedData( softwareVersion, - selfId.getId(), + selfId.id(), EventUtils.getEventGeneration(selfParent), EventUtils.getEventGeneration(otherParent), EventUtils.getEventHash(selfParent), diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/PreConsensusEventHandler.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/PreConsensusEventHandler.java index 43ea0f5603d4..5b19be5dc53b 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/PreConsensusEventHandler.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/PreConsensusEventHandler.java @@ -93,7 +93,7 @@ public PreConsensusEventHandler( INITIAL_PRE_CONS_EVENT_QUEUE_CAPACITY, EventUtils::consensusPriorityComparator); queueThread = new QueueThreadConfiguration(threadManager) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setQueue(queue) .setComponent(PLATFORM_THREAD_POOL_NAME) .setThreadName("thread-curr") diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/FallenBehindManagerImpl.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/FallenBehindManagerImpl.java index 381d144624fb..692ed14d4cf7 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/FallenBehindManagerImpl.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/FallenBehindManagerImpl.java @@ -75,14 +75,14 @@ public FallenBehindManagerImpl( @Override public synchronized void reportFallenBehind(final NodeId id) { final boolean previouslyFallenBehind = hasFallenBehind(); - if (reportFallenBehind.add(id.getId())) { + if (reportFallenBehind.add(id.id())) { if (numReportFallenBehind == 0) { // we have received the first indication that we have fallen behind, so we need to check with other // nodes to confirm notYetReportFallenBehind.addAll(allNeighbors); } // we don't need to check with this node - notYetReportFallenBehind.remove(id.getId()); + notYetReportFallenBehind.remove(id.id()); numReportFallenBehind++; if (!previouslyFallenBehind && hasFallenBehind()) { notifyPlatform.run(); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/ChatterSyncProtocol.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/ChatterSyncProtocol.java index 2931edbe346f..6a9e992b8c24 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/ChatterSyncProtocol.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/ChatterSyncProtocol.java @@ -93,7 +93,7 @@ public boolean shouldAccept() { */ private boolean fallenBehindSync() { final List notReportedFallenBehind = fallenBehindManager.getNeededForFallenBehind(); - return notReportedFallenBehind == null || notReportedFallenBehind.contains(peerId.getId()); + return notReportedFallenBehind == null || notReportedFallenBehind.contains(peerId.id()); } @Override diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/protocol/heartbeat/HeartbeatSender.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/protocol/heartbeat/HeartbeatSender.java index 9f1d8da08528..e4221dcbe519 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/protocol/heartbeat/HeartbeatSender.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/chatter/protocol/heartbeat/HeartbeatSender.java @@ -57,7 +57,7 @@ public HeartbeatSender( final BiConsumer pingConsumer, final Duration heartbeatInterval, final Time time) { - this.peerId = NodeId.createMain(peerId); + this.peerId = new NodeId(peerId); this.pingConsumer = pingConsumer; this.heartbeatInterval = heartbeatInterval; this.time = time; diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncCaller.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncCaller.java index 3d3ef90bed87..9ae3338a0241 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncCaller.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncCaller.java @@ -185,8 +185,7 @@ private int callRequestSync() { // self is the only member, so create an event for just this one transaction, // and immediately put it into the hashgraph. No syncing is needed. platform.getEventTaskCreator() - .createEvent( - selfId.getId() /*selfId assumed to be main*/); // otherID (so self will count as the + .createEvent(selfId.id() /*selfId assumed to be main*/); // otherID (so self will count as the // "other") Thread.sleep(50); // selfId assumed to be main @@ -218,7 +217,7 @@ private int callRequestSync() { } try (final MaybeLockedResource resource = - platform.getSharedConnectionLocks().tryLockConnection(NodeId.createMain(otherId))) { + platform.getSharedConnectionLocks().tryLockConnection(new NodeId(otherId))) { if (!resource.isLockAcquired()) { continue; } @@ -332,7 +331,7 @@ private boolean doReconnect(final List reconnectNeighbors) { for (final Long neighborId : reconnectNeighbors) { // try to get the lock, it should be available if we have fallen behind try (final MaybeLockedResource resource = - platform.getSharedConnectionLocks().tryLockConnection(NodeId.createMain(neighborId))) { + platform.getSharedConnectionLocks().tryLockConnection(new NodeId(neighborId))) { if (!resource.isLockAcquired()) { peerInfo.addPeerInfo(neighborId, "failed to acquire lock, blocked by heartbeat thread"); continue; diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncManagerImpl.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncManagerImpl.java index afa6a775981e..bcb57ee53718 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncManagerImpl.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncManagerImpl.java @@ -232,8 +232,8 @@ public boolean shouldCreateEvent(final SyncResult info) { } // check 3: if neither node is part of the superMinority in the latest round, don't create an event - if (!criticalQuorum.isInCriticalQuorum(info.getOtherId().getId()) - && !criticalQuorum.isInCriticalQuorum(selfId.getId())) { + if (!criticalQuorum.isInCriticalQuorum(info.getOtherId().id()) + && !criticalQuorum.isInCriticalQuorum(selfId.id())) { return false; } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncProtocolResponder.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncProtocolResponder.java index a92e328bee0d..75b5b4558c4d 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncProtocolResponder.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/SyncProtocolResponder.java @@ -62,7 +62,7 @@ public void protocolInitiated(final byte initialByte, final Connection connectio rejectSync(connection); } else { try (final MaybeLocked lock = - syncThrottle.trySync(connection.getOtherId().getId(), false)) { + syncThrottle.trySync(connection.getOtherId().id(), false)) { if (!lock.isLockAcquired()) { // we should not be syncing, so reply NACK rejectSync(connection); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/protocol/SyncProtocol.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/protocol/SyncProtocol.java index 8a7c8fae9544..20d951f9970a 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/protocol/SyncProtocol.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gossip/sync/protocol/SyncProtocol.java @@ -144,7 +144,7 @@ public SyncProtocol( private boolean peerNeededForFallenBehind() { final List neededForFallenBehind = fallenBehindManager.getNeededForFallenBehind(); - return neededForFallenBehind != null && neededForFallenBehind.contains(peerId.getId()); + return neededForFallenBehind != null && neededForFallenBehind.contains(peerId.id()); } /** @@ -169,7 +169,7 @@ public boolean shouldInitiate() { } // is there a reason to initiate? - if (peerNeededForFallenBehind() || criticalQuorum.isInCriticalQuorum(peerId.getId())) { + if (peerNeededForFallenBehind() || criticalQuorum.isInCriticalQuorum(peerId.id())) { permit = permitProvider.tryAcquire(); final boolean isLockAcquired = permit.isLockAcquired(); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/SwirldsGui.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/SwirldsGui.java index 0c00aead21cd..27af076c428e 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/SwirldsGui.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/SwirldsGui.java @@ -63,7 +63,7 @@ public static Console createConsole(final Platform platform, final boolean visib } final AddressBook addressBook = platform.getAddressBook(); - final long selfId = platform.getSelfId().getId(); + final long selfId = platform.getSelfId().id(); final int winNum = platform.getInstanceNumber(); final Rectangle winRect = winRect(addressBook, winNum); @@ -90,7 +90,7 @@ public static JFrame createWindow(final Platform platform, final boolean visible } final AddressBook addressBook = platform.getAddressBook(); - final long selfId = platform.getSelfId().getId(); + final long selfId = platform.getSelfId().id(); final int winNum = platform.getInstanceNumber(); final Rectangle winRect = winRect(addressBook, winNum); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/SwirldMenu.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/SwirldMenu.java index b1cf74631f2c..2062a736e876 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/SwirldMenu.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/gui/internal/SwirldMenu.java @@ -295,7 +295,7 @@ public void actionPerformed(ActionEvent e) { (platform == null ? "" : SwirldsGui.getAbout( - platform.getSelfId().getId())) + "\n\n" + platform.getSelfId().id())) + "\n\n" + PlatformVersion.locateOrDefault().license(), // message "About this app", // title JOptionPane.DEFAULT_OPTION, // optionType diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/internal/EventImpl.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/internal/EventImpl.java index a8a10b605547..94ef571dcb42 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/internal/EventImpl.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/internal/EventImpl.java @@ -251,7 +251,7 @@ public synchronized void estimateTime( /* number of seconds to add to the base time */ double sec; - if (selfId.equalsMain(getCreatorId())) { + if (selfId.id() == getCreatorId()) { // event by self t = getTimeCreated(); // seconds from self creating an event to the consensus timestamp that event receives @@ -581,7 +581,7 @@ public int getNumTransactions() { } public boolean isCreatedBy(final NodeId id) { - return getCreatorId() == id.getId(); + return getCreatorId() == id.id(); } public boolean isCreatedBy(final long id) { diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/ConsensusMetricsImpl.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/ConsensusMetricsImpl.java index 3b47ffcec8d3..ec5203a2598c 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/ConsensusMetricsImpl.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/metrics/ConsensusMetricsImpl.java @@ -162,7 +162,7 @@ public ConsensusMetricsImpl(final NodeId selfId, final Metrics metrics) { @Override public void addedEvent(final EventImpl event) { // this method is only ever called by 1 thread, so no need for locks - if (!selfId.equalsMain(event.getCreatorId()) + if (selfId.id() != event.getCreatorId() && event.getRoundCreated() > lastRoundNumber) { // if first event in a round final Instant now = Instant.now(); if (firstEventInLastRoundTime != null) { @@ -187,7 +187,7 @@ public void coinRounds(final long numCoinRounds) { */ @Override public void lastFamousInRound(final EventImpl event) { - if (!selfId.equalsMain(event.getCreatorId())) { // record this for events received + if (selfId.id() != event.getCreatorId()) { // record this for events received avgReceivedFamousTime.update( event.getTimeReceived().until(Instant.now(), ChronoUnit.NANOS) * NANOSECONDS_TO_SECONDS); } @@ -215,7 +215,7 @@ public void consensusReached(final EventImpl event) { // Because of transThrottle, these statistics can end up being misleading, so we are only tracking events that // have user transactions in them. if (event.hasUserTransactions()) { - if (selfId.equalsMain(event.getCreatorId())) { // set either created or received time to now + if (selfId.id() == event.getCreatorId()) { // set either created or received time to now avgCreatedConsensusTime.update( event.getTimeReceived().until(Instant.now(), ChronoUnit.NANOS) * NANOSECONDS_TO_SECONDS); } else { @@ -229,7 +229,7 @@ public void consensusReached(final EventImpl event) { // Because of transThrottle, these statistics can end up being misleading, so we are only tracking events that // have user transactions in them. if (event.hasUserTransactions()) { - if (selfId.equalsMain(event.getCreatorId())) { + if (selfId.id() == event.getCreatorId()) { avgSelfCreatedTimestamp.update( event.getTimeCreated().until(event.getConsensusTimestamp(), ChronoUnit.NANOS) * NANOSECONDS_TO_SECONDS); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/InboundConnectionHandler.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/InboundConnectionHandler.java index 219499ab3a58..48c561cc5b1b 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/InboundConnectionHandler.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/InboundConnectionHandler.java @@ -115,7 +115,7 @@ public void handle(final Socket clientSocket) { clientSocket.getOutputStream(), settings.connectionStreamBufferSize()); final SocketConnection sc = SocketConnection.create( - selfId, NodeId.createMain(otherId), connectionTracker, false, clientSocket, sis, sos); + selfId, new NodeId(otherId), connectionTracker, false, clientSocket, sis, sos); newConnectionConsumer.accept(sc); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/OutboundConnectionCreator.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/OutboundConnectionCreator.java index d696d99b6c0e..100948b616af 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/OutboundConnectionCreator.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/connectivity/OutboundConnectionCreator.java @@ -82,8 +82,8 @@ public OutboundConnectionCreator( * @return the new connection, or a connection that is not connected if it couldn't connect on the first try */ public Connection createConnection(final NodeId otherId) { - final Address other = addressBook.getAddress(otherId.getId()); - final Address ownAddress = addressBook.getAddress(selfId.getId()); + final Address other = addressBook.getAddress(otherId.id()); + final Address ownAddress = addressBook.getAddress(selfId.id()); final int port = other.getConnectPortIpv4(ownAddress); final byte[] ip = getConnectAddressIpv4(ownAddress, other); final String ipAddress = Address.ipString(ip); @@ -113,7 +113,7 @@ public Connection createConnection(final NodeId otherId) { } } - dos.writeUTF(addressBook.getAddress(selfId.getId()).getNickname()); + dos.writeUTF(addressBook.getAddress(selfId.id()).getNickname()); dos.flush(); final int ack = dis.readInt(); // read the ACK for creating the connection diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/topology/StaticTopology.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/topology/StaticTopology.java index 4e08ed6cf3eb..8c3719e800ed 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/topology/StaticTopology.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/topology/StaticTopology.java @@ -61,7 +61,7 @@ public List getNeighbors() { public List getNeighbors(final Predicate filter) { return Arrays.stream(connectionGraph.getNeighbors(selfId.getIdAsInt())) .mapToLong(i -> (long) i) - .mapToObj(NodeId::createMain) + .mapToObj(NodeId::new) .filter(filter) .collect(Collectors.toList()); } @@ -71,7 +71,7 @@ public List getNeighbors(final Predicate filter) { */ @Override public boolean shouldConnectToMe(final NodeId nodeId) { - return isNeighbor(nodeId) && (unidirectional || nodeId.getId() < selfId.getId()); + return isNeighbor(nodeId) && (unidirectional || nodeId.id() < selfId.id()); } /** @@ -82,9 +82,8 @@ public boolean shouldConnectToMe(final NodeId nodeId) { * @return true if this node is my neighbor, false if not */ private boolean isNeighbor(final NodeId nodeId) { - return selfId.sameNetwork(nodeId) - && nodeId.getId() >= 0 - && nodeId.getId() < networkSize + return nodeId.id() >= 0 + && nodeId.id() < networkSize && connectionGraph.isAdjacent(selfId.getIdAsInt(), nodeId.getIdAsInt()); } @@ -93,7 +92,7 @@ private boolean isNeighbor(final NodeId nodeId) { */ @Override public boolean shouldConnectTo(final NodeId nodeId) { - return isNeighbor(nodeId) && (unidirectional || nodeId.getId() > selfId.getId()); + return isNeighbor(nodeId) && (unidirectional || nodeId.id() > selfId.id()); } /** diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/unidirectional/SharedConnectionLocks.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/unidirectional/SharedConnectionLocks.java index 69b2769841e2..fd1dcad3bce0 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/unidirectional/SharedConnectionLocks.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/network/unidirectional/SharedConnectionLocks.java @@ -75,7 +75,7 @@ public SharedConnectionLocks(final NetworkTopology topology, final StaticConnect for (final NodeId peerId : topology.getNeighbors()) { final ConnectionManager supplier = suppliers.getManager(peerId, true); Objects.requireNonNull(supplier); - locks.put(peerId.getId(), Locks.createResourceLock(supplier)); + locks.put(peerId.id(), Locks.createResourceLock(supplier)); } } @@ -94,7 +94,7 @@ public MaybeLockedResource tryLockConnection(final NodeId nod if (!topology.shouldConnectTo(nodeId)) { return NOT_ACQUIRED; } - return locks.get(nodeId.getId()).tryLock(); + return locks.get(nodeId.id()).tryLock(); } /** @@ -113,6 +113,6 @@ public LockedResource lockConnectIfNeeded(final NodeId nodeId if (!topology.shouldConnectTo(nodeId)) { return NOT_ACQUIRED; } - return locks.get(nodeId.getId()).lock(); + return locks.get(nodeId.id()).lock(); } } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocol.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocol.java index a18ca02ee7f3..42711cc1e63b 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocol.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocol.java @@ -83,7 +83,7 @@ public ReconnectProtocol( @Override public boolean shouldInitiate() { // if this neighbor has not told me I have fallen behind, I will not reconnect with him - if (!fallenBehindManager.shouldReconnectFrom(peerId.getId())) { + if (!fallenBehindManager.shouldReconnectFrom(peerId.id())) { return false; } @@ -117,7 +117,7 @@ public boolean shouldAccept() { logger.info( RECONNECT.getMarker(), "Rejecting reconnect request from node {} due to lack of a fully signed state", - peerId.getId()); + peerId.id()); return false; } @@ -127,7 +127,7 @@ public boolean shouldAccept() { logger.warn( RECONNECT.getMarker(), "Rejecting reconnect request from node {} " + "due to lack of an initialized signed state.", - peerId.getId()); + peerId.id()); return false; } else if (!teacherState.get().isComplete()) { // this is only possible if signed state manager violates its contractual obligations @@ -138,12 +138,12 @@ public boolean shouldAccept() { "Rejecting reconnect request from node {} due to lack of a fully signed state." + " The signed state manager attempted to provide a state that was not" + " fully signed, which should not be possible.", - peerId.getId()); + peerId.id()); return false; } // Check if a reconnect with the learner is permitted by the throttle. - final boolean reconnectPermittedByThrottle = teacherThrottle.initiateReconnect(peerId.getId()); + final boolean reconnectPermittedByThrottle = teacherThrottle.initiateReconnect(peerId.id()); if (reconnectPermittedByThrottle) { initiatedBy = InitiatedBy.PEER; return true; @@ -208,8 +208,8 @@ private void teacher(final Connection connection) { threadManager, connection, reconnectSocketTimeout, - connection.getSelfId().getId(), - connection.getOtherId().getId(), + connection.getSelfId().id(), + connection.getOtherId().id(), state.get().getRound(), reconnectMetrics) .execute(state.get()); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocolResponder.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocolResponder.java index dbf6438b4636..25133e5e52f6 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocolResponder.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/ReconnectProtocolResponder.java @@ -84,7 +84,7 @@ public void protocolInitiated(final byte initialByte, final Connection connectio logger.info( RECONNECT.getMarker(), "Rejecting reconnect request from node {} due to lack of a fully signed state", - connection.getOtherId().getId()); + connection.getOtherId().id()); ReconnectUtils.denyReconnect(connection); return; } @@ -94,7 +94,7 @@ public void protocolInitiated(final byte initialByte, final Connection connectio logger.warn( RECONNECT.getMarker(), "Rejecting reconnect request from node {} due to lack of an initialized signed state.", - connection.getOtherId().getId()); + connection.getOtherId().id()); return; } else if (!state.get().isComplete()) { // this is only possible if signed state manager violates its contractual obligations @@ -104,11 +104,11 @@ public void protocolInitiated(final byte initialByte, final Connection connectio "Rejecting reconnect request from node {} due to lack of a fully signed state." + " The signed state manager attempted to provide a state that was not" + " fully signed, which should not be possible.", - connection.getOtherId().getId()); + connection.getOtherId().id()); return; } - if (!reconnectThrottle.initiateReconnect(connection.getOtherId().getId())) { + if (!reconnectThrottle.initiateReconnect(connection.getOtherId().id())) { ReconnectUtils.denyReconnect(connection); return; } @@ -119,8 +119,8 @@ public void protocolInitiated(final byte initialByte, final Connection connectio threadManager, connection, settings.getAsyncStreamTimeoutMilliseconds(), - connection.getSelfId().getId(), - connection.getOtherId().getId(), + connection.getSelfId().id(), + connection.getOtherId().id(), state.get().getRound(), stats) .execute(state.get()); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocol.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocol.java index 6994621ec92b..735919a035c1 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocol.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocol.java @@ -113,7 +113,7 @@ public void initiateFailed() { @Override public boolean shouldAccept() { // if the throttle is initiated, we should call markReconnectFinished in teacher() - final boolean shouldAccept = teacherThrottle.initiateReconnect(peerId.getId()); + final boolean shouldAccept = teacherThrottle.initiateReconnect(peerId.id()); if (shouldAccept) { initiatedBy = InitiatedBy.PEER; } @@ -136,7 +136,7 @@ public void runProtocol(final Connection connection) default -> throw new NetworkProtocolException(String.format( "runProtocol() called for emergency reconnect with peer %d " + "but it is unclear who the teacher and who the learner is", - peerId.getId())); + peerId.id())); } } finally { initiatedBy = InitiatedBy.NO_ONE; @@ -178,7 +178,7 @@ private void emergencyReconnectComplete(final ReconnectCompleteNotification noti RECONNECT.getMarker(), "Emergency Reconnect Complete, round {} received from peer {}", notification.getRoundNumber(), - peerId.getId()); + peerId.id()); emergencyRecoveryManager.emergencyStateLoaded(); } } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTeacher.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTeacher.java index d22682734b3c..9a78535820cc 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTeacher.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTeacher.java @@ -101,8 +101,8 @@ public void execute(final Connection connection) { threadManager, connection, reconnectSocketTimeout, - connection.getSelfId().getId(), - connection.getOtherId().getId(), + connection.getSelfId().id(), + connection.getOtherId().id(), reservedState.get().getRound(), reconnectMetrics) .execute(reservedState.get()); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/internal/RecoveryPlatform.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/internal/RecoveryPlatform.java index 64a233b9e348..67500860311f 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/internal/RecoveryPlatform.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/recovery/internal/RecoveryPlatform.java @@ -70,7 +70,7 @@ public RecoveryPlatform( final long selfId, final boolean loadSigningKeys) { - this.selfId = new NodeId(false, selfId); + this.selfId = new NodeId(selfId); this.addressBook = initialState.getAddressBook(); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerImpl.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerImpl.java index ad0f797ae0a0..9c2582ef2ec5 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerImpl.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManagerImpl.java @@ -132,7 +132,7 @@ public SwirldStateManagerImpl( this.transactionPool = new EventTransactionPool(platformContext.getMetrics(), settings, inFreeze); this.transactionHandler = new TransactionHandler(selfId, stats); - this.uptimeTracker = new UptimeTracker(platformContext, addressBook, selfId.getId(), OSTime.getInstance()); + this.uptimeTracker = new UptimeTracker(platformContext, addressBook, selfId.id(), OSTime.getInstance()); initialState(state); } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java index bb11a41af7de..0a120cffa5d6 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java @@ -62,7 +62,7 @@ public void preHandle(final EventImpl event, final SwirldState swirldState) { logger.error( EXCEPTION.getMarker(), "error invoking SwirldState.preHandle() [ nodeId = {} ] with event {}", - selfId.getId(), + selfId.id(), event.toMediumString(), t); } @@ -105,7 +105,7 @@ public void handleRound(final ConsensusRound round, final State state) { logger.error( EXCEPTION.getMarker(), "error invoking SwirldState.handleConsensusRound() [ nodeId = {} ] with round {}", - selfId.getId(), + selfId.id(), round.getRoundNum(), t); } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookMetrics.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookMetrics.java index b42ef3e82354..800140435235 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookMetrics.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/address/AddressBookMetrics.java @@ -41,7 +41,7 @@ private AddressBookMetrics() {} public static void registerAddressBookMetrics( @NonNull final Metrics metrics, @NonNull final AddressBook addressBook, @NonNull final NodeId selfId) { - metrics.getOrCreate(new FunctionGauge.Config<>(INFO_CATEGORY, "memberID", Long.class, selfId::getId) + metrics.getOrCreate(new FunctionGauge.Config<>(INFO_CATEGORY, "memberID", Long.class, selfId::id) .withUnit("node ID") .withDescription("The node ID number of this member")); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java index fcf8a4bd38e2..bfcaa05c4eda 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileManager.java @@ -143,7 +143,7 @@ public SignedStateFileManager( .setCapacity(stateConfig.stateSavingQueueSize()) .setMaxBufferSize(1) .setPriority(basicConfig.threadPriorityNonSync()) - .setNodeId(selfId.getId()) + .setNodeId(selfId.id()) .setComponent(PLATFORM_THREAD_POOL_NAME) .setThreadName("signed-state-file-manager") .setHandler(Runnable::run) @@ -221,7 +221,7 @@ private boolean saveSignedStateToDisk( final long round = reservedSignedState.get().getRound(); try (reservedSignedState) { try { - writeSignedStateToDisk(selfId.getId(), directory, reservedSignedState.get(), taskDescription); + writeSignedStateToDisk(selfId.id(), directory, reservedSignedState.get(), taskDescription); metrics.getWriteStateToDiskTimeMetric() .update(TimeUnit.NANOSECONDS.toMillis(time.nanoTime() - start)); @@ -289,7 +289,7 @@ public void dumpState( signedState, getSignedStatesBaseDirectory() .resolve(reason) - .resolve(String.format("node%d_round%d", selfId.getId(), signedState.getRound())), + .resolve(String.format("node%d_round%d", selfId.id(), signedState.getRound())), reason, success -> latch.countDown()); diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileUtils.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileUtils.java index b8a6f5b8f6e7..001ba940016b 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileUtils.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/signed/SignedStateFileUtils.java @@ -128,7 +128,7 @@ public static Path getSignedStatesDirectoryForApp(final String mainClassName) { */ public static Path getSignedStatesDirectoryForNode(final String mainClassName, final NodeId selfId) { - return getSignedStatesDirectoryForApp(mainClassName).resolve(Long.toString(selfId.getId())); + return getSignedStatesDirectoryForApp(mainClassName).resolve(Long.toString(selfId.id())); } /** diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileManagerTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileManagerTests.java index d95271bc51e5..7fa72125b616 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileManagerTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileManagerTests.java @@ -88,7 +88,7 @@ @DisplayName("SignedStateFileManager Tests") class SignedStateFileManagerTests { - private static final NodeId SELF_ID = new NodeId(false, 1234); + private static final NodeId SELF_ID = new NodeId(1234); private static final String MAIN_CLASS_NAME = "com.swirlds.foobar"; private static final String SWIRLD_NAME = "mySwirld"; /** diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java index 06437c0fd504..3b5e8d42140a 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SignedStateFileReadWriteTest.java @@ -77,7 +77,7 @@ @DisplayName("SignedState Read/Write Test") class SignedStateFileReadWriteTest { - private static final NodeId SELF_ID = new NodeId(false, 1234); + private static final NodeId SELF_ID = new NodeId(1234); private static final String MAIN_CLASS_NAME = "com.swirlds.foobar"; private static final String SWIRLD_NAME = "mySwirld"; /** @@ -205,14 +205,14 @@ void getSignedStatesDirectoryForNodeTest() { assertEquals( getAbsolutePath("./data/saved/com.swirlds.foobar/1234"), - getSignedStatesDirectoryForNode("com.swirlds.foobar", new NodeId(false, 1234)), + getSignedStatesDirectoryForNode("com.swirlds.foobar", new NodeId(1234)), "unexpected saved state file"); Settings.getInstance().getState().savedStateDirectory = "foo/bar/baz"; assertEquals( getAbsolutePath("./foo/bar/baz/com.swirlds.barfoo/4321"), - getSignedStatesDirectoryForNode("com.swirlds.barfoo", new NodeId(false, 4321)), + getSignedStatesDirectoryForNode("com.swirlds.barfoo", new NodeId(4321)), "unexpected saved state file"); Settings.getInstance().getState().savedStateDirectory = "data/saved"; @@ -225,14 +225,14 @@ void getSignedStatesDirectoryForSwirldTest() { assertEquals( getAbsolutePath("./data/saved/com.swirlds.foobar/1234/mySwirld"), - getSignedStatesDirectoryForSwirld("com.swirlds.foobar", new NodeId(false, 1234), "mySwirld"), + getSignedStatesDirectoryForSwirld("com.swirlds.foobar", new NodeId(1234), "mySwirld"), "unexpected saved state file"); Settings.getInstance().getState().savedStateDirectory = "foo/bar/baz"; assertEquals( getAbsolutePath("./foo/bar/baz/com.swirlds.barfoo/4321/myOtherSwirld"), - getSignedStatesDirectoryForSwirld("com.swirlds.barfoo", new NodeId(false, 4321), "myOtherSwirld"), + getSignedStatesDirectoryForSwirld("com.swirlds.barfoo", new NodeId(4321), "myOtherSwirld"), "unexpected saved state file"); Settings.getInstance().getState().savedStateDirectory = "data/saved"; @@ -245,14 +245,14 @@ void getSignedStateDirectoryTest() { assertEquals( getAbsolutePath("./data/saved/com.swirlds.foobar/1234/mySwirld/1337"), - getSignedStateDirectory("com.swirlds.foobar", new NodeId(false, 1234), "mySwirld", 1337), + getSignedStateDirectory("com.swirlds.foobar", new NodeId(1234), "mySwirld", 1337), "unexpected saved state file"); Settings.getInstance().getState().savedStateDirectory = "foo/bar/baz"; assertEquals( getAbsolutePath("./foo/bar/baz/com.swirlds.barfoo/4321/myOtherSwirld/42"), - getSignedStateDirectory("com.swirlds.barfoo", new NodeId(false, 4321), "myOtherSwirld", 42), + getSignedStateDirectory("com.swirlds.barfoo", new NodeId(4321), "myOtherSwirld", 42), "unexpected saved state file"); Settings.getInstance().getState().savedStateDirectory = "data/saved"; diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SyncManagerTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SyncManagerTest.java index df21b1fc6d7e..cece765e6a06 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SyncManagerTest.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/SyncManagerTest.java @@ -52,7 +52,7 @@ @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class SyncManagerTest { private static final long ID = 0L; - private static final NodeId OTHER_ID = new NodeId(false, 1L); + private static final NodeId OTHER_ID = new NodeId(1L); /** * A helper class that contains dummy data to feed into SyncManager lambdas. @@ -70,11 +70,11 @@ private static class SyncManagerTestData { public DummyEventQueue eventQueue; public SyncManagerTestData() { - this(new NodeId(false, ID), spy(SwirldStateManager.class)); + this(new NodeId(ID), spy(SwirldStateManager.class)); } public SyncManagerTestData(final SwirldStateManager swirldStateManager) { - this(new NodeId(false, ID), swirldStateManager); + this(new NodeId(ID), swirldStateManager); } public SyncManagerTestData(final NodeId nodeId) { @@ -118,7 +118,7 @@ public EventCreationRuleResponse shouldCreateEvent(BaseEvent selfParent, BaseEve eventQueue, connectionGraph, nodeId, - new EventCreationRules(List.of(nodeId, startUpEventFrozenManager, freezeManager)), + new EventCreationRules(List.of(startUpEventFrozenManager, freezeManager)), criticalQuorum, hashgraph.getAddressBook(), new FallenBehindManagerImpl( @@ -156,8 +156,8 @@ void basicTest() { assertNull(test.syncManager.getNeededForFallenBehind()); // neighbors 0 and 1 report fallen behind - test.syncManager.reportFallenBehind(new NodeId(false, neighbors[0])); - test.syncManager.reportFallenBehind(new NodeId(false, neighbors[1])); + test.syncManager.reportFallenBehind(new NodeId(neighbors[0])); + test.syncManager.reportFallenBehind(new NodeId(neighbors[1])); // we still dont have enough reports that we have fallen behind, we need more than [fallenBehindThreshold] of // the neighbors @@ -165,7 +165,7 @@ void basicTest() { // add more reports for (int i = 2; i < 10; i++) { - test.syncManager.reportFallenBehind(new NodeId(false, neighbors[i])); + test.syncManager.reportFallenBehind(new NodeId(neighbors[i])); } // we are still missing 1 report @@ -181,7 +181,7 @@ void basicTest() { } // add the report that will go over the [fallenBehindThreshold] - test.syncManager.reportFallenBehind(new NodeId(false, neighbors[10])); + test.syncManager.reportFallenBehind(new NodeId(neighbors[10])); // we should now say we have fallen behind assertTrue(test.syncManager.hasFallenBehind()); @@ -274,31 +274,19 @@ void shouldCreateEventTest() { "if neither node is part of the superMinority in the latest round, don't create an event"); // If the other node is in the critical quorum then an event should be created. - test.hashgraph.isInCriticalQuorum.put(OTHER_ID.getId(), true); + test.hashgraph.isInCriticalQuorum.put(OTHER_ID.id(), true); assertTrue(test.syncManager.shouldCreateEvent(OTHER_ID, false, 0, 0)); - test.hashgraph.isInCriticalQuorum.put(OTHER_ID.getId(), false); + test.hashgraph.isInCriticalQuorum.put(OTHER_ID.id(), false); assertFalse( test.syncManager.shouldCreateEvent(OTHER_ID, false, 0, 0), "if neither node is part of the superMinority in the latest round, don't create an event"); // If both are in the critical quorum then an event should be created. test.hashgraph.isInCriticalQuorum.put(ID, true); - test.hashgraph.isInCriticalQuorum.put(OTHER_ID.getId(), true); + test.hashgraph.isInCriticalQuorum.put(OTHER_ID.id(), true); assertTrue(test.syncManager.shouldCreateEvent(OTHER_ID, false, 0, 0)); } - /** - * A mirror node should not create events - */ - @Test - @Order(6) - void shouldCreateEventTestMirrorNode() { - final SyncManagerTestData test = new SyncManagerTestData(new NodeId(true, ID)); - resetTestSettings(); - test.hashgraph.isInCriticalQuorum.put(ID, true); - assertFalse(test.syncManager.shouldCreateEvent(OTHER_ID, false, 0, 0), "mirror node cannot create events"); - } - /** * If there any frozen transaction events then do not create any new events. */ @@ -352,7 +340,7 @@ void shouldCreateEventThrottled() { final int eventsRead = 0; final int eventsWritten = 0; - final NodeId mainNodeId = new NodeId(false, ID); + final NodeId mainNodeId = new NodeId(ID); final SyncManagerTestData test = new SyncManagerTestData(mainNodeId); test.hashgraph.isInCriticalQuorum.put(ID, true); diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/TestUtils.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/TestUtils.java index f20d9c63a708..8f7a972824b1 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/TestUtils.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/TestUtils.java @@ -64,7 +64,7 @@ static EventImpl createTestEvent(final int creatorId, final int otherId) { null); CryptographyHolder.get().digestSync(e.getBaseEventHashedData()); - e.estimateTime(NodeId.createMain(creatorId), startTime.getEpochSecond(), 0); + e.estimateTime(new NodeId(creatorId), startTime.getEpochSecond(), 0); return e; } } diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/components/state/StateManagementComponentTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/components/state/StateManagementComponentTests.java index 8a7f39210780..4afd26d64304 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/components/state/StateManagementComponentTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/components/state/StateManagementComponentTests.java @@ -71,7 +71,7 @@ class StateManagementComponentTests { private static final String MAIN = "main"; private static final String SWIRLD = "swirld123"; - private static final NodeId NODE_ID = new NodeId(false, 0L); + private static final NodeId NODE_ID = new NodeId(0L); private static final int NUM_NODES = 4; private final int roundsToKeepForSigning = 5; private final TestPrioritySystemTransactionConsumer systemTransactionConsumer = @@ -440,7 +440,7 @@ private void testSelfIss( null, 3L, issStateSignatureTransaction(signedState, 3L, otherHash)); assertEquals(signedState.getRound(), issConsumer.getIssRound(), "Incorrect round reported to iss consumer"); - assertEquals(NODE_ID.getId(), issConsumer.getIssNodeId(), "ISS should have been reported as self ISS"); + assertEquals(NODE_ID.id(), issConsumer.getIssNodeId(), "ISS should have been reported as self ISS"); assertEquals( IssNotification.IssType.SELF_ISS, issConsumer.getIssType(), diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/AbstractEventHandlerTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/AbstractEventHandlerTests.java index 55e16a6a415e..008fa62011a5 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/AbstractEventHandlerTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/AbstractEventHandlerTests.java @@ -55,7 +55,7 @@ public abstract class AbstractEventHandlerTests { protected Random random; protected void setup() { - selfId = new NodeId(false, 0L); + selfId = new NodeId(0L); metrics = new NoOpMetrics(); ssStats = mock(SwirldStateMetrics.class); consensusMetrics = mock(ConsensusMetrics.class); diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/ConsensusRoundHandlerTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/ConsensusRoundHandlerTests.java index aa48d38a541c..ee01e1bb7f2a 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/ConsensusRoundHandlerTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/eventhandling/ConsensusRoundHandlerTests.java @@ -115,7 +115,7 @@ void queueNotDrainedOnReconnect() { consensusRoundHandler = new ConsensusRoundHandler( platformContext, getStaticThreadManager(), - selfId.getId(), + selfId.id(), settingsProvider, swirldStateManager, consensusHandlingMetrics, @@ -207,7 +207,7 @@ private void initConsensusHandler(final SwirldState swirldState) { consensusRoundHandler = new ConsensusRoundHandler( platformContext, getStaticThreadManager(), - selfId.getId(), + selfId.id(), settingsProvider, swirldStateManager, consensusHandlingMetrics, diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/heartbeat/HeartbeatProtocolTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/heartbeat/HeartbeatProtocolTests.java index 4e230c15401d..7312cdf04162 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/heartbeat/HeartbeatProtocolTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/heartbeat/HeartbeatProtocolTests.java @@ -52,7 +52,7 @@ class HeartbeatProtocolTests { @BeforeEach void setup() { - peerId = new NodeId(false, 1); + peerId = new NodeId(1); heartbeatPeriod = Duration.ofMillis(1000); networkMetrics = mock(NetworkMetrics.class); time = new FakeTime(); diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java index 57cc04bc537d..532833aea18e 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/ReconnectProtocolTests.java @@ -53,7 +53,7 @@ */ public class ReconnectProtocolTests { - private static final NodeId PEER_ID = new NodeId(false, 1L); + private static final NodeId PEER_ID = new NodeId(1L); private static Stream initiateParams() { return Stream.of( @@ -121,7 +121,7 @@ void shouldInitiateTest(final InitiateParams params) { when(reconnectController.acquireLearnerPermit()).thenReturn(params.getsPermit); final List neighborsForReconnect = LongStream.range(0L, 10L) - .filter(id -> id != PEER_ID.getId() || params.isReconnectNeighbor) + .filter(id -> id != PEER_ID.id() || params.isReconnectNeighbor) .boxed() .toList(); @@ -232,9 +232,9 @@ void testTeacherThrottleReleased() { reconnectSettings.minimumTimeBetweenReconnects = Duration.ZERO; final ReconnectThrottle reconnectThrottle = new ReconnectThrottle(reconnectSettings); - final NodeId node0 = new NodeId(false, 0L); - final NodeId node1 = new NodeId(false, 1L); - final NodeId node2 = new NodeId(false, 2L); + final NodeId node0 = new NodeId(0L); + final NodeId node1 = new NodeId(1L); + final NodeId node2 = new NodeId(2L); final ReconnectProtocol peer1 = new ReconnectProtocol( getStaticThreadManager(), node1, @@ -294,7 +294,7 @@ void abortedLearner() { final ReconnectProtocol protocol = new ReconnectProtocol( getStaticThreadManager(), - new NodeId(false, 0), + new NodeId(0), mock(ReconnectThrottle.class), () -> null, 100, @@ -334,7 +334,7 @@ void abortedTeacher() { final ReconnectProtocol protocol = new ReconnectProtocol( getStaticThreadManager(), - new NodeId(false, 0), + new NodeId(0), reconnectThrottle, () -> reservedSignedState, 100, @@ -366,7 +366,7 @@ void teacherHasNoSignedState() { final ReconnectProtocol protocol = new ReconnectProtocol( getStaticThreadManager(), - new NodeId(false, 0), + new NodeId(0), reconnectThrottle, ReservedSignedState::createNullReservation, 100, diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocolTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocolTests.java index bf8356947c12..02965aef4b0d 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocolTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectProtocolTests.java @@ -53,7 +53,7 @@ */ public class EmergencyReconnectProtocolTests { - private static final NodeId PEER_ID = new NodeId(false, 1L); + private static final NodeId PEER_ID = new NodeId(1L); private static Stream initiateParams() { return Stream.of( @@ -208,6 +208,6 @@ void testTeacherThrottleReleased() { () -> protocol.runProtocol(throwingConnection), "expected an exception to be thrown"); - assertTrue(teacherThrottle.initiateReconnect(PEER_ID.getId()), "Teacher throttle should be released"); + assertTrue(teacherThrottle.initiateReconnect(PEER_ID.id()), "Teacher throttle should be released"); } } diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTests.java index 57152fa48c16..b795dc7255f8 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/reconnect/emergency/EmergencyReconnectTests.java @@ -81,8 +81,8 @@ public class EmergencyReconnectTests { private static final Future trueFuture = mock(Future.class); private final RandomSignedStateGenerator signedStateGenerator = new RandomSignedStateGenerator(); - private final NodeId learnerId = new NodeId(false, 0L); - private final NodeId teacherId = new NodeId(false, 1L); + private final NodeId learnerId = new NodeId(0L); + private final NodeId teacherId = new NodeId(1L); private final ReconnectThrottle reconnectThrottle = mock(ReconnectThrottle.class); private final SignedStateManager signedStateManager = mock(SignedStateManager.class); private final ParallelExecutor executor = new CachedPoolParallelExecutor(getStaticThreadManager(), "test-executor"); diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/recovery/RecoveryTestUtils.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/recovery/RecoveryTestUtils.java index ac9846bfd7c7..420bde58b87d 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/recovery/RecoveryTestUtils.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/recovery/RecoveryTestUtils.java @@ -183,7 +183,7 @@ public static void writeRandomEventStream( final EventStreamManager eventEventStreamManager = new EventStreamManager<>( TestPlatformContextBuilder.create().build(), getStaticThreadManager(), - new NodeId(false, 0), + new NodeId(0L), x -> randomSignature(random), "test", true, diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerImplTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerImplTests.java index f98e71403ce9..da20c34dea91 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerImplTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/SwirldStateManagerImplTests.java @@ -49,7 +49,7 @@ void setup() { swirldStateManagerImpl = new SwirldStateManagerImpl( TestPlatformContextBuilder.create().build(), addressBook, - new NodeId(false, 0L), + new NodeId(0L), mock(PreConsensusSystemTransactionManager.class), mock(PostConsensusSystemTransactionManager.class), mock(SwirldStateMetrics.class), diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/TransactionHandlerTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/TransactionHandlerTest.java index 04baf7a06dcb..ae52becd6a61 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/TransactionHandlerTest.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/state/TransactionHandlerTest.java @@ -48,7 +48,7 @@ class TransactionHandlerTest { () -> new NullPointerException("intentionally thrown"), () -> new RuntimeException("intentionally thrown")); - private final NodeId selfId = new NodeId(false, 0L); + private final NodeId selfId = new NodeId(0L); private final State state = mock(State.class); private final SwirldState swirldState = mock(SwirldState.class); diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/sync/protocol/SyncProtocolTests.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/sync/protocol/SyncProtocolTests.java index 45f63d3e0a78..ad82d693ca5a 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/sync/protocol/SyncProtocolTests.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/sync/protocol/SyncProtocolTests.java @@ -63,7 +63,7 @@ class SyncProtocolTests { @BeforeEach void setup() { - peerId = new NodeId(false, 1); + peerId = new NodeId(1); shadowGraphSynchronizer = mock(ShadowGraphSynchronizer.class); fallenBehindManager = mock(FallenBehindManager.class); permitProvider = new SyncPermitProvider(2); @@ -218,7 +218,7 @@ void noReasonToInitiate() { // peer 6 isn't needed for fallen behind final SyncProtocol protocol = new SyncProtocol( - new NodeId(false, 6), + new NodeId(6), shadowGraphSynchronizer, fallenBehindManager, permitProvider, @@ -261,7 +261,7 @@ void initiateForFallenBehind() { void initiateForCriticalQuorum() { // peer 6 isn't needed for fallen behind, but it *is* in critical quorum (by default) final SyncProtocol protocol = new SyncProtocol( - new NodeId(false, 6), + new NodeId(6), shadowGraphSynchronizer, fallenBehindManager, permitProvider, diff --git a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/util/HashLoggerTest.java b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/util/HashLoggerTest.java index 3729d6d7292d..4934d80eecb4 100644 --- a/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/util/HashLoggerTest.java +++ b/platform-sdk/swirlds-platform-core/src/test/java/com/swirlds/platform/util/HashLoggerTest.java @@ -54,7 +54,7 @@ public class HashLoggerTest { @BeforeEach public void setUp() { mockLogger = mock(Logger.class); - hashLogger = new HashLogger(getStaticThreadManager(), NodeId.createMain(123), mockLogger); + hashLogger = new HashLogger(getStaticThreadManager(), new NodeId(123), mockLogger); logged = new ArrayList<>(); doAnswer(invocation -> { @@ -113,7 +113,7 @@ public void loggingWithGapsAddsExtraWarning() { public void noLoggingWhenDisabled() { Settings.getInstance().getState().enableHashStreamLogging = false; - hashLogger = new HashLogger(getStaticThreadManager(), NodeId.createMain(123), mockLogger); + hashLogger = new HashLogger(getStaticThreadManager(), new NodeId(123), mockLogger); hashLogger.logHashes(createSignedState(1)); assertThat(logged).isEmpty(); assertThat(hashLogger.queue()).isNullOrEmpty(); @@ -124,7 +124,7 @@ public void noLoggingWhenDisabled() { @Test public void loggerWithDefaultConstructorWorks() { assertDoesNotThrow(() -> { - hashLogger = new HashLogger(getStaticThreadManager(), NodeId.createMain(123)); + hashLogger = new HashLogger(getStaticThreadManager(), new NodeId(123)); hashLogger.logHashes(createSignedState(1)); flush(); }); diff --git a/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/main/java/com/swirlds/common/test/stream/StreamObjectWorker.java b/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/main/java/com/swirlds/common/test/stream/StreamObjectWorker.java index 86212e30e149..42ae9decab0c 100644 --- a/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/main/java/com/swirlds/common/test/stream/StreamObjectWorker.java +++ b/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/main/java/com/swirlds/common/test/stream/StreamObjectWorker.java @@ -30,7 +30,6 @@ import com.swirlds.common.stream.RunningHashCalculatorForStream; import com.swirlds.common.stream.Signer; import com.swirlds.common.stream.internal.TimestampStreamFileWriter; -import com.swirlds.common.system.NodeId; import java.io.IOException; import java.security.NoSuchAlgorithmException; import java.time.Instant; @@ -44,7 +43,6 @@ * sends objects to LinkedObjectStream objects for calculating RunningHash and serializing to disk */ public class StreamObjectWorker { - public static final NodeId NODE_ID = new NodeId(false, 0); /** receives objects from runningHashCalculator, then passes to writeConsumer */ private final QueueThreadObjectStream writeQueueThread; diff --git a/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/EventStreamManagerTest.java b/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/EventStreamManagerTest.java index 07301e25dcea..3cbde3d890c4 100644 --- a/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/EventStreamManagerTest.java +++ b/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/EventStreamManagerTest.java @@ -39,7 +39,7 @@ import org.junit.jupiter.params.provider.ValueSource; class EventStreamManagerTest { - private static final NodeId selfId = new NodeId(false, 0); + private static final NodeId selfId = new NodeId(0); private static final String nodeName = "node0"; private static final String eventsLogDir = "eventStream/"; private static final long eventsLogPeriod = 5; diff --git a/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/TestStreamManager.java b/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/TestStreamManager.java index b9d83d187c01..2ba75869972f 100644 --- a/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/TestStreamManager.java +++ b/platform-sdk/swirlds-unit-tests/common/swirlds-common-test/src/test/java/com/swirlds/common/test/stream/TestStreamManager.java @@ -26,7 +26,6 @@ import com.swirlds.common.stream.QueueThreadObjectStream; import com.swirlds.common.stream.QueueThreadObjectStreamConfiguration; import com.swirlds.common.stream.RunningHashCalculatorForStream; -import com.swirlds.common.system.NodeId; import java.util.List; import java.util.concurrent.CountDownLatch; import org.apache.logging.log4j.LogManager; @@ -39,7 +38,6 @@ */ public class TestStreamManager { private static final Logger logger = LogManager.getLogger(TestStreamManager.class); - private static final NodeId NODE_ID = new NodeId(false, 0); /** * receives {@link ObjectForTestStream}s then passes to hashQueueThread */ diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/chatter/SimulatedChatterFactories.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/chatter/SimulatedChatterFactories.java index 05bb2905b6a9..54f269755848 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/chatter/SimulatedChatterFactories.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/chatter/SimulatedChatterFactories.java @@ -72,7 +72,7 @@ public SimulatedChatter build( chatterConfig, (nodeId, ping) -> {}, new DefaultMetrics( - NodeId.createMain(selfId), + new NodeId(selfId), registry, Executors.newSingleThreadScheduledExecutor(), new DefaultMetricsFactory(), diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/consensus/TestIntake.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/consensus/TestIntake.java index 8864920fb726..7623fb13cb51 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/consensus/TestIntake.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/consensus/TestIntake.java @@ -110,7 +110,7 @@ public TestIntake( final EventObserverDispatcher dispatcher = new EventObserverDispatcher(new ShadowGraphEventObserver(shadowGraph), this); intake = new EventIntake( - NodeId.createMain(0), // only used for logging + new NodeId(0L), // only used for logging linker, this::getConsensus, ab, diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/simulated/SimpleSimulatedGossip.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/simulated/SimpleSimulatedGossip.java index ac0b0c011a8d..a8035f67bc6e 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/simulated/SimpleSimulatedGossip.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/main/java/com/swirlds/platform/test/simulated/SimpleSimulatedGossip.java @@ -79,7 +79,7 @@ public void setNode(final SimulatedEventCreationNode node) { */ public void gossipEvent(final GossipEvent event) { for (int i = 0; i < numNodes; i++) { - if (nodes[i].getNodeId().getId() != event.getHashedData().getCreatorId()) { + if (nodes[i].getNodeId().id() != event.getHashedData().getCreatorId()) { final Duration delay = latency.getLatency(event.getHashedData().getCreatorId(), i); queues.get(i).add(new Payload(event, time.now().plus(delay))); } diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/SocketConnectionTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/SocketConnectionTests.java index 6e95b58c837c..7967b4d07031 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/SocketConnectionTests.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/SocketConnectionTests.java @@ -50,8 +50,9 @@ class SocketConnectionTests { - private NodeId selfId; - private NodeId otherId; + private NodeId selfId = new NodeId(0L); + ; + private NodeId otherId = new NodeId(1L); private SwirldsPlatform platform; private Socket socket; private SyncInputStream dis; @@ -68,8 +69,6 @@ private void initConnection(final boolean isOutbound) { @BeforeEach void newMocks() { - selfId = mock(NodeId.class); - otherId = mock(NodeId.class); platform = mock(SwirldsPlatform.class, withSettings().withoutAnnotations()); socket = mock(Socket.class); dis = mock(SyncInputStream.class); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/ChatterSyncTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/ChatterSyncTest.java index 396537b4bcf2..128c89da89a3 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/ChatterSyncTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/ChatterSyncTest.java @@ -39,7 +39,7 @@ import org.mockito.Mockito; class ChatterSyncTest { - private static final NodeId PEER_ID = new NodeId(false, 1L); + private static final NodeId PEER_ID = new NodeId(1L); final CommunicationState state = new CommunicationState(); final ShadowGraphSynchronizer synchronizer = Mockito.mock(ShadowGraphSynchronizer.class); final Connection connection = Mockito.mock(Connection.class); @@ -89,7 +89,7 @@ void fallenBehindCheck() { Assertions.assertTrue( chatterSync.shouldAccept(), "if the peer has not reported us as fallen behind, we should sync"); - when(fallenBehindManager.getNeededForFallenBehind()).thenReturn(List.of(0L, PEER_ID.getId())); + when(fallenBehindManager.getNeededForFallenBehind()).thenReturn(List.of(0L, PEER_ID.id())); Assertions.assertTrue( chatterSync.shouldInitiate(), "if the peer has not reported us as fallen behind, we should sync"); Assertions.assertTrue( diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/protocol/heartbeat/PingChecker.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/protocol/heartbeat/PingChecker.java index 6ab7260dcd9a..66df4c0bfafa 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/protocol/heartbeat/PingChecker.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/chatter/protocol/heartbeat/PingChecker.java @@ -39,7 +39,7 @@ public void setExpectedPing(final Duration expectedPing) { public void checkPing(final NodeId nodeId, final long pingNanos) { numUpdates++; - Assertions.assertTrue(nodeId.equalsMain(expectedPeerId)); + Assertions.assertTrue(nodeId.id() == expectedPeerId); Assertions.assertEquals(expectedPing.toNanos(), pingNanos); } diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventCreatorTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventCreatorTests.java index 066c0c91dbb1..3dfa7b63f5b5 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventCreatorTests.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventCreatorTests.java @@ -69,7 +69,7 @@ @DisplayName("Event Creator Tests") class EventCreatorTests { - private static final NodeId selfId = new NodeId(false, 1234); + private static final NodeId selfId = new NodeId(1234); private static final Signer noOpSigner = (bytes) -> new Signature(SignatureType.RSA, new byte[SignatureType.RSA.signatureLength()]); private static final GraphGenerations defaultGenerations = new Generations( @@ -345,7 +345,7 @@ void verifyEventDataTest() { final EventImpl selfParentImpl = EventMocks.mockEvent(selfParent); final Map recentEvents = new HashMap<>(); - recentEvents.put(selfId.getId(), selfParentImpl); + recentEvents.put(selfId.id(), selfParentImpl); recentEvents.put(1L, otherParent); final AccessibleEventCreator eventCreator = new AccessibleEventCreator( @@ -364,7 +364,7 @@ void verifyEventDataTest() { assertEquals(1, events.size(), "expected an event to have been created"); final EventImpl event = events.remove(); - assertEquals(selfId.getId(), event.getCreatorId(), "expected id to match self ID"); + assertEquals(selfId.id(), event.getCreatorId(), "expected id to match self ID"); assertTrue( event.getTimeCreated().isAfter(prevEventTime.plusNanos(previousTransactions.length - 1)), "expected timestamp to be greater than previous timestamp"); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventIntakeTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventIntakeTest.java index 204cac111f5c..d0f3e06b74f4 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventIntakeTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventIntakeTest.java @@ -61,7 +61,7 @@ void test() { final ShadowGraph shadowGraph = mock(ShadowGraph.class); final EventIntake intake = new EventIntake( - NodeId.createMain(0), + new NodeId(0L), mock(EventLinker.class), () -> consensus, addressBook, diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventMapperTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventMapperTest.java index 62a56f238c19..62a9f24dbd74 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventMapperTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventMapperTest.java @@ -45,7 +45,7 @@ class EventMapperTest { @DisplayName("DataInDataOutTest") void dataInDataOutTest() { - final EventMapper mapper = new EventMapper(new NoOpMetrics(), NodeId.createMain(0)); + final EventMapper mapper = new EventMapper(new NoOpMetrics(), new NodeId(0)); final long nodeId1 = 1; final long nodeId2 = 2; @@ -86,7 +86,7 @@ void dataInDataOutTest() { @Tag(TestComponentTags.PLATFORM) @DisplayName("Orphaned Event Test") void orphanedEventTest() { - final EventMapper mapper = new EventMapper(new NoOpMetrics(), NodeId.createMain(0)); + final EventMapper mapper = new EventMapper(new NoOpMetrics(), new NodeId(0)); // With no events in the mapper there will be no descendants for (int i = 0; i < 4; i++) { diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventTaskCreatorTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventTaskCreatorTest.java index 34097a425995..00542d3fe596 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventTaskCreatorTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/components/EventTaskCreatorTest.java @@ -72,7 +72,7 @@ void newMocks() { address = mock(Address.class); when(addressBook.getAddress(Mockito.anyLong())).thenReturn(address); when(addressBook.copy()).thenReturn(addressBook); - selfId = NodeId.createMain(1); + selfId = new NodeId(1); eventIntakeMetrics = mock(EventIntakeMetrics.class); eventQueueThread = mock(BlockingQueue.class); setting = mock(SettingsProvider.class); @@ -169,7 +169,7 @@ void testSyncDone_ShouldCreateEvent() throws InterruptedException { when(syncManager.shouldCreateEvent(any())).thenReturn(true); SyncResult syncResult = mock(SyncResult.class); - when(syncResult.getOtherId()).thenReturn(mock(NodeId.class)); + when(syncResult.getOtherId()).thenReturn(new NodeId(2)); taskCreator.syncDone(syncResult); @@ -185,7 +185,7 @@ void testSyncDoneRandomEvent() throws InterruptedException { when(setting.getRandomEventProbability()).thenReturn(1); SyncResult syncResult = mock(SyncResult.class); - when(syncResult.getOtherId()).thenReturn(mock(NodeId.class)); + when(syncResult.getOtherId()).thenReturn(new NodeId(2)); taskCreator.syncDone(syncResult); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/creation/EventCreationSimulationTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/creation/EventCreationSimulationTest.java index 0d4194254a60..b1ba14dfb40c 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/creation/EventCreationSimulationTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/creation/EventCreationSimulationTest.java @@ -110,7 +110,7 @@ void simulateEventCreation(final EventCreationSimulationParams params) { time, addressBook, List.of(gossip::gossipEvent, consensus::addEvent), - NodeId.createMain(i), + new NodeId(i), h -> consensus.getShadowGraph().getEvent(h), params.superMajority() || i > params.numNodes() / 2); nodes.add(node); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/intake/OrphanEventsIntakeTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/intake/OrphanEventsIntakeTest.java index 58c0ed6f0413..427719ecb7ae 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/intake/OrphanEventsIntakeTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/event/intake/OrphanEventsIntakeTest.java @@ -96,7 +96,7 @@ public Intake(final long generatorSeed, final long randomSeed, final int numNode new ParentFinder(linkedEventMap::get), 100_000); intake = new EventIntake( - NodeId.createMain(0), + new NodeId(0L), orphanBuffer, () -> consensus, generator.getAddressBook(), diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/eventflow/EventFlowTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/eventflow/EventFlowTests.java index cbda1db04c8d..c9f771312ef4 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/eventflow/EventFlowTests.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/eventflow/EventFlowTests.java @@ -101,7 +101,7 @@ class EventFlowTests { protected static final long selfId = 0L; private static final int THROTTLE_TRANSACTION_QUEUE_SIZE = 100_000; - private final NodeId selfNodeId = new NodeId(false, selfId); + private final NodeId selfNodeId = new NodeId(selfId); private final SettingsProvider settingsProvider = mock(SettingsProvider.class); protected AddressBook addressBook; diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/FakeConnection.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/FakeConnection.java index 07d6abc93d79..a9c0d52e4c30 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/FakeConnection.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/FakeConnection.java @@ -29,7 +29,7 @@ public class FakeConnection implements Connection { private final NodeId peerId; public FakeConnection() { - this(NodeId.createMain(0), NodeId.createMain(1)); + this(new NodeId(0L), new NodeId(1)); } public FakeConnection(final NodeId selfId, final NodeId peerId) { diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionCreatorTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionCreatorTest.java index 1d1577b78e8c..58317c0fa762 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionCreatorTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionCreatorTest.java @@ -68,8 +68,8 @@ void createConnectionTest() throws IOException, ConstructableRegistryException { .setHashStrategy(RandomAddressBookGenerator.HashStrategy.FAKE_HASH) .setSequentialIds(true) .build(); - final NodeId thisNode = NodeId.createMain(r.nextInt(10)); - final NodeId otherNode = NodeId.createMain(r.nextInt(10)); + final NodeId thisNode = new NodeId(r.nextInt(10)); + final NodeId otherNode = new NodeId(r.nextInt(10)); final AtomicBoolean connected = new AtomicBoolean(true); final Socket socket = mock(Socket.class); @@ -164,8 +164,8 @@ void mismatchedVersionTest() throws IOException, ConstructableRegistryException .setHashStrategy(RandomAddressBookGenerator.HashStrategy.FAKE_HASH) .setSequentialIds(true) .build(); - final NodeId thisNode = NodeId.createMain(r.nextInt(10)); - final NodeId otherNode = NodeId.createMain(r.nextInt(10)); + final NodeId thisNode = new NodeId(r.nextInt(10)); + final NodeId otherNode = new NodeId(r.nextInt(10)); final AtomicBoolean connected = new AtomicBoolean(true); final Socket socket = mock(Socket.class); @@ -223,8 +223,8 @@ void mismatchedVersionIgnoredTest() throws IOException, ConstructableRegistryExc .setHashStrategy(RandomAddressBookGenerator.HashStrategy.FAKE_HASH) .setSequentialIds(true) .build(); - final NodeId thisNode = NodeId.createMain(r.nextInt(10)); - final NodeId otherNode = NodeId.createMain(r.nextInt(10)); + final NodeId thisNode = new NodeId(r.nextInt(10)); + final NodeId otherNode = new NodeId(r.nextInt(10)); final AtomicBoolean connected = new AtomicBoolean(true); final Socket socket = mock(Socket.class); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionManagerTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionManagerTest.java index e10abaca78e1..b625f6f34f48 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionManagerTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/OutboundConnectionManagerTest.java @@ -40,7 +40,8 @@ class OutboundConnectionManagerTest { @Test void createConnectionTest() { - final NodeId nodeId = NodeId.createMain(0); + final NodeId nodeId = new NodeId(0L); + ; final Connection connection1 = new FakeConnection(); final Connection connection2 = new FakeConnection(); final OutboundConnectionCreator creator = mock(OutboundConnectionCreator.class); @@ -73,7 +74,7 @@ void createConnectionTest() { @Test void concurrencyTest() throws InterruptedException { final int numThreads = 10; - final NodeId nodeId = NodeId.createMain(0); + final NodeId nodeId = new NodeId(0L); final OutboundConnectionCreator creator = mock(OutboundConnectionCreator.class); final Connection connection = new FakeConnection(); final CountDownLatch waitingForConnection = new CountDownLatch(1); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/StaticConnectionManagersTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/StaticConnectionManagersTest.java index 527c610cdd06..b88700891592 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/StaticConnectionManagersTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/StaticConnectionManagersTest.java @@ -52,7 +52,7 @@ private static List topologicalVariations() { @MethodSource("topologicalVariations") void test(final int numNodes, final int numNeighbors) throws Exception { final Random r = RandomUtils.getRandomPrintSeed(); - final NodeId selfId = NodeId.createMain(r.nextInt(numNodes)); + final NodeId selfId = new NodeId(r.nextInt(numNodes)); Mockito.when(connectionCreator.createConnection(Mockito.any())).thenAnswer(inv -> { final NodeId peerId = inv.getArgument(0, NodeId.class); return new FakeConnection(selfId, peerId); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/TopologyTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/TopologyTest.java index 77568daa83f5..bd4f7b4fcd3f 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/TopologyTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/TopologyTest.java @@ -113,16 +113,15 @@ void testRandomGraphs(final int numNodes, final int numNeighbors, final long see @ParameterizedTest @MethodSource("fullyConnected") void testFullyConnectedUnidirectionalTopology(final int numNodes, final int numNeighbors, final long ignoredSeed) { - final NodeId negativeId = NodeId.createMain(-1); - final NodeId outOfBoundsId = NodeId.createMain(numNodes); + final NodeId outOfBoundsId = new NodeId(numNodes); for (int thisNode = 0; thisNode < numNodes; thisNode++) { - final NodeId thisNodeId = NodeId.createMain(thisNode); + final NodeId thisNodeId = new NodeId(thisNode); final NetworkTopology topology = new StaticTopology(thisNodeId, numNodes, numNeighbors); final List neighbors = topology.getNeighbors(); final List expected = IntStream.range(0, numNodes) .filter(i -> i != thisNodeId.getIdAsInt()) - .mapToObj(NodeId::createMain) + .mapToObj(NodeId::new) .toList(); assertEquals(expected, neighbors, "all should be neighbors except me"); for (final NodeId neighbor : neighbors) { @@ -132,7 +131,6 @@ void testFullyConnectedUnidirectionalTopology(final int numNodes, final int numN assertFalse(topology.shouldConnectTo(thisNodeId), "I should not connect to myself"); assertFalse(topology.shouldConnectToMe(thisNodeId), "I should not connect to myself"); - assertFalse(topology.shouldConnectToMe(negativeId), "negative values should return to false"); assertFalse(topology.shouldConnectToMe(outOfBoundsId), "values >=numNodes should return to false"); testRandomGraphWithSets(topology.getConnectionGraph(), numNodes, numNeighbors); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/handshake/HandshakeTests.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/handshake/HandshakeTests.java index 94e56b41d694..4b3c392bbc52 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/handshake/HandshakeTests.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/handshake/HandshakeTests.java @@ -44,7 +44,7 @@ void versionHandshakeTests() throws IOException, ConstructableRegistryException final ProtocolRunnable handshakeThrows = new VersionCompareHandshake(ourVersion); final ProtocolRunnable handshakeLogs = new VersionCompareHandshake(ourVersion, false); final Pair connections = - ConnectionFactory.createLocalConnections(NodeId.createMain(0), NodeId.createMain(1)); + ConnectionFactory.createLocalConnections(new NodeId(0L), new NodeId(1)); final Connection myConnection = connections.getLeft(); final Connection theirConnection = connections.getRight(); final ConstructableRegistry registry = ConstructableRegistry.getInstance(); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/ChatterNetworkTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/ChatterNetworkTest.java index 535c300daba9..c6fa6ed8a026 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/ChatterNetworkTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/ChatterNetworkTest.java @@ -78,7 +78,7 @@ void transmitMessages() final ChatterNetworkTester peer2 = new ChatterNetworkTester(numberOfMessages, parallelExecutor, true); final Pair connections = - ConnectionFactory.createLocalConnections(NodeId.createMain(0), NodeId.createMain(1)); + ConnectionFactory.createLocalConnections(new NodeId(0L), new NodeId(1)); final Future future1 = executor.submit(peer1.getProtocolRunnable(connections.getLeft())); final Future future2 = executor.submit(peer2.getProtocolRunnable(connections.getRight())); diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorMultithreadedTest.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorMultithreadedTest.java index 4d4f86084460..a86b4857e127 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorMultithreadedTest.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorMultithreadedTest.java @@ -47,7 +47,7 @@ void runProtocol() throws Exception { @Test void keepalive() throws Exception { final Pair connections = - ConnectionFactory.createLocalConnections(NodeId.createMain(0), NodeId.createMain(1)); + ConnectionFactory.createLocalConnections(new NodeId(0L), new NodeId(1)); final NegotiatorPair pair = new NegotiatorPair( new TestProtocol().setShouldInitiate(false), Pair.of( diff --git a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorPair.java b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorPair.java index a50439ae53fe..1e2ae75d2e7c 100644 --- a/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorPair.java +++ b/platform-sdk/swirlds-unit-tests/core/swirlds-platform-test/src/test/java/com/swirlds/platform/test/network/communication/multithreaded/NegotiatorPair.java @@ -39,7 +39,7 @@ public NegotiatorPair(final TestProtocol protocol, final Pair