Skip to content

Commit 5287b2b

Browse files
skletsundmitry-timofeev
authored andcommitted
Separate JNI implementation for ProofMap [ECR-3983] (#1299)
Separate JNI implementation for ProofMap into RawProofMap (no key hashing) and ProofMap (hashes keys). Java still relies on the previous implementation, and will migrate to the new ones in ECR-3850
1 parent 97595fe commit 5287b2b

6 files changed

Lines changed: 1000 additions & 17 deletions

File tree

exonum-java-binding/core/rust/src/storage/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ mod map_index;
2222
mod pair_iter;
2323
mod proof_list_index;
2424
mod proof_map_index;
25+
mod proof_map_index_next;
26+
mod raw_proof_map_index;
2527
mod temporarydb;
2628
mod value_set_index;
2729

@@ -35,5 +37,7 @@ pub use self::map_index::*;
3537
pub use self::pair_iter::PairIter;
3638
pub use self::proof_list_index::*;
3739
pub use self::proof_map_index::*;
40+
pub use self::proof_map_index_next::*;
41+
pub use self::raw_proof_map_index::*;
3842
pub use self::temporarydb::*;
3943
pub use self::value_set_index::*;

exonum-java-binding/core/rust/src/storage/proof_list_index.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,21 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use exonum_merkledb::{
16-
access::FromAccess, proof_list_index::ProofListIndexIter, Fork, IndexAddress, ListProof,
17-
ObjectHash, ProofListIndex, Snapshot,
15+
use exonum::merkledb::{
16+
access::FromAccess, proof_list_index::ProofListIndexIter, Fork, IndexAddress, ObjectHash,
17+
ProofListIndex, Snapshot,
1818
};
19-
use exonum_proto::ProtobufConvert;
2019
use jni::{
2120
objects::{JClass, JObject, JString},
2221
sys::{jboolean, jbyteArray, jint, jlong},
2322
JNIEnv,
2423
};
25-
use protobuf::Message;
2624

2725
use std::{panic, ptr};
2826

2927
use handle::{self, Handle};
3028
use storage::db::{Value, View, ViewRef};
3129
use utils;
32-
use JniResult;
3330

3431
type Index<T> = ProofListIndex<T, Value>;
3532

@@ -260,7 +257,7 @@ pub extern "system" fn Java_com_exonum_binding_core_storage_indices_ProofListInd
260257
IndexType::SnapshotIndex(ref list) => list.get_proof(index as u64),
261258
IndexType::ForkIndex(ref list) => list.get_proof(index as u64),
262259
};
263-
proof_to_bytes(&env, proof)
260+
utils::proto_to_java_bytes(&env, proof)
264261
});
265262
utils::unwrap_exc_or(&env, res, ptr::null_mut())
266263
}
@@ -280,7 +277,7 @@ pub extern "system" fn Java_com_exonum_binding_core_storage_indices_ProofListInd
280277
IndexType::SnapshotIndex(ref list) => list.get_range_proof(from as u64..to as u64),
281278
IndexType::ForkIndex(ref list) => list.get_range_proof(from as u64..to as u64),
282279
};
283-
proof_to_bytes(&env, proof)
280+
utils::proto_to_java_bytes(&env, proof)
284281
});
285282
utils::unwrap_exc_or(&env, res, ptr::null_mut())
286283
}
@@ -410,8 +407,3 @@ pub extern "system" fn Java_com_exonum_binding_core_storage_indices_ProofListInd
410407
) {
411408
handle::drop_handle::<ProofListIndexIter<Value>>(&env, iter_handle);
412409
}
413-
414-
// Serializes `ListProof` into protobuf format and converts to the Java bytes array.
415-
fn proof_to_bytes(env: &JNIEnv, proof: ListProof<Value>) -> JniResult<jbyteArray> {
416-
env.byte_array_from_slice(&proof.to_pb().write_to_bytes().unwrap())
417-
}

0 commit comments

Comments
 (0)