-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed a few issues on Dynamic Address Book (#14316)
Signed-off-by: Iris Simon <[email protected]>
- Loading branch information
Showing
23 changed files
with
282 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...book-service/src/main/java/com/hedera/node/app/service/addressbook/AddressBookHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.node.app.service.addressbook; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static java.util.Spliterator.DISTINCT; | ||
|
||
import com.hedera.hapi.node.state.common.EntityNumber; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.util.Spliterators; | ||
import java.util.stream.StreamSupport; | ||
|
||
/** | ||
* Utility class that provides static methods and constants to facilitate the Address Book Services functions. | ||
*/ | ||
public class AddressBookHelper { | ||
public static final String NODES_KEY = "NODES"; | ||
|
||
/** | ||
* Get the next Node ID number from the reaReadableNodeStore | ||
* @param nodeStore | ||
* @return nextNodeId | ||
*/ | ||
public static long getNextNodeID(@NonNull final ReadableNodeStore nodeStore) { | ||
requireNonNull(nodeStore); | ||
final long maxNodeId = StreamSupport.stream( | ||
Spliterators.spliterator(nodeStore.keys(), nodeStore.sizeOfState(), DISTINCT), false) | ||
.mapToLong(EntityNumber::number) | ||
.max() | ||
.orElse(-1L); | ||
return maxNodeId + 1; | ||
} | ||
} |
Oops, something went wrong.