-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #681 from LimeChain/680-Store-grandpa-data
680: Persist and Fetch GRANDPA Data with Refactoring from Previous Class
- Loading branch information
Showing
13 changed files
with
211 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.limechain.storage; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
import java.math.BigInteger; | ||
|
||
@UtilityClass | ||
public class StateUtil { | ||
|
||
/** | ||
* Prepares a concatenated key by appending all suffixes to the base key. | ||
* This method builds a key string by appending the provided suffixes sequentially | ||
* to the base key using a {StringBuilder}. | ||
* | ||
* @param key the base(main) part of the key. | ||
* @param suffixes additional parts to be appended to the key. | ||
* @return the concatenated key as a single {String}. | ||
*/ | ||
private String prepareKey(String key, String... suffixes) { | ||
StringBuilder sb = new StringBuilder(key); | ||
for (String suffix : suffixes) { | ||
sb.append(suffix); | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
|
||
public String generateAuthorityKey(String authorityKey, BigInteger setId) { | ||
return prepareKey(authorityKey, setId.toString()); | ||
} | ||
|
||
public String generatePrevotesKey(String grandpaPrevotes, BigInteger roundNumber, BigInteger setId) { | ||
return prepareKey(grandpaPrevotes, roundNumber.toString(), setId.toString()); | ||
} | ||
|
||
public String generatePrecommitsKey(String precommitsKey, BigInteger roundNumber, BigInteger setId) { | ||
return prepareKey(precommitsKey, roundNumber.toString(), setId.toString()); | ||
} | ||
|
||
} |
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
Oops, something went wrong.