-
Notifications
You must be signed in to change notification settings - Fork 30
Extract #getIndexHash in HashableIndex interface [ECR-4064]. #1366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dmitry-timofeev
merged 25 commits into
exonum:master
from
dmitry-timofeev:add-hashable-index-ECR-4064
Jan 17, 2020
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6195976
WIP Add IndexProof
dmitry-timofeev 2751fe5
Make SignedMessage public:
dmitry-timofeev 1912ce4
Finish tests
dmitry-timofeev b23e0cc
Improve documentation on proofs
dmitry-timofeev 123b951
Implement proof constructors
dmitry-timofeev 13c4ed5
Todo/fixes
dmitry-timofeev c5d3408
Fix documentation
dmitry-timofeev d8db838
Reimplement Block#fromMessage
dmitry-timofeev 4260179
Fix checkstyle
dmitry-timofeev 6ed552a
Add jira ref
dmitry-timofeev eea3ce6
Add changelog entry
dmitry-timofeev 253a45a
Document the exception in case no index proof can be created.
dmitry-timofeev d47524e
Update to the new native spec
dmitry-timofeev 4a1d3ca
Document the initialization connection
dmitry-timofeev 1fa35e3
Merge remote-tracking branch 'main/master' into add-index-proof-ECR-4011
dmitry-timofeev 0e835cc
Enable the tests depending on the native
dmitry-timofeev d0c47f6
Fix checkstyle
dmitry-timofeev edd78a4
Empty to trigger CI
dmitry-timofeev 581bf98
Fix import
dmitry-timofeev d85adb2
Fix native methods names
dmitry-timofeev 6fa70f3
Merge branch 'master' into add-index-proof-ECR-4011
dmitry-timofeev 0f7aeb6
Extract #getIndexHash in HashableIndex interface [ECR-4064].
dmitry-timofeev 7abe5a5
Add CL entry
dmitry-timofeev 795d9df
s/must affect/affect/
dmitry-timofeev 4020af4
Merge remote-tracking branch 'main/master' into add-hashable-index-EC…
dmitry-timofeev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
46 changes: 46 additions & 0 deletions
46
...ava-binding/core/src/main/java/com/exonum/binding/core/storage/indices/HashableIndex.java
This file contains hidden or 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,46 @@ | ||
/* | ||
* Copyright 2020 The Exonum Team | ||
* | ||
* 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 | ||
* | ||
* https://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.exonum.binding.core.storage.indices; | ||
|
||
import com.exonum.binding.common.hash.HashCode; | ||
|
||
/** | ||
* A hashable index provides a cryptographic hash which represents the complete state of this index. | ||
* | ||
* <p>Hashable indexes enable efficient verification of their contents. Two indexes contain | ||
* the same values if their index hashes are equal. This property is used in the consensus | ||
* algorithm to compare the database state on different nodes. | ||
* | ||
* <p>Index hashes are also used in verifiable index views. Such views contain a subset | ||
* of index elements and a proof that jointly allow to restore the index hash. The computed | ||
* index hash allows to verify that the elements come from an index with a certain state. | ||
* | ||
* <p>Hashable indexes may participate in | ||
* <a href="https://docs.rs/exonum-merkledb/0.13.0-rc.2/exonum_merkledb/#state-aggregation">state hash aggregation</a>. | ||
* | ||
* @see <a href="https://docs.rs/exonum-merkledb/0.13.0-rc.2/exonum_merkledb/trait.ObjectHash.html">ObjectHash trait</a> | ||
*/ | ||
public interface HashableIndex extends StorageIndex { | ||
|
||
/** | ||
* Returns the index hash which represents the complete state of this index. | ||
* Any modifications to the stored entries affect the index hash. | ||
* | ||
* <p>How index hash is computed depends on the index data structure implementation. | ||
*/ | ||
HashCode getIndexHash(); | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -85,7 +85,8 @@ | |
* @param <V> the type of values in this map | ||
* @see View | ||
*/ | ||
public final class ProofMapIndexProxy<K, V> extends AbstractIndexProxy implements MapIndex<K, V> { | ||
public final class ProofMapIndexProxy<K, V> extends AbstractIndexProxy implements MapIndex<K, V>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we make the index factories and add the interfaces for each index type, those interfaces could extend HashableIndex, instead of implementation classes. |
||
HashableIndex { | ||
|
||
private final Serializer<K> keySerializer; | ||
private final CheckingSerializerDecorator<V> valueSerializer; | ||
|
@@ -381,12 +382,7 @@ private static MapProof decodeProofMessage(byte[] proofMessage) { | |
} | ||
} | ||
|
||
/** | ||
* Returns the index hash which represents the complete state of this map. | ||
* Any modifications to the stored entries affect the index hash. | ||
* | ||
* @throws IllegalStateException if this map is not valid | ||
*/ | ||
@Override | ||
public HashCode getIndexHash() { | ||
return HashCode.fromBytes(nativeGetIndexHash(getNativeHandle())); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other links are index-specific.