Skip to content

Commit 89739d0

Browse files
blackyblackWarchant
authored andcommitted
Release 0.0.2 (#56)
* Add forkresolution and grpc methods for the forkresolution. * Cleanup * StreamUtils: add new function to read a single integer * Refactored write of the Int values according to previous Pull Request * Improve PoPtx database. * Add sonarqube task & add jacoco for coverage * Bump sonarqube version * Update gradle.yml * Fix Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Update pop rewarding (#5) * Add using the PoPTxDatabase in the PoPRewards algorithms * update PoPRewards test with using the PoPTxdatabase. Fix forkresolution. * Add new method SavePoPTransactionData into the IntegrationService * StreamUtils: swap parameter order from max/min to min/max (#2) * BitcoinStore: fix replace and erase (#6) * BitcoinStore: fix replace(); add erase() * tests: BitcoinStore: add coverage for erase() and replace() * Remove data field (#7) * Add using the PoPTxDatabase in the PoPRewards algorithms * update PoPRewards test with using the PoPTxdatabase. Fix forkresolution. * Add new method SavePoPTransactionData into the IntegrationService * Remove data field from VeriBlockTransaction class, fix tests. * remove temporary files from git * Fixes * Feature/veriblockstore fix replace erase (#10) * GenericBlockRepository: refactor to allow schema changes and working with stored block types directly; rename from GenericBlocksRepository * port VeriBlockBlockRepository to use GenericBlockRepository; add essential tests; rename from VeriBlockBlocksRepository * VeriBlockBlockRepository: add support for storing the block of proof * GenericBlockRepository: add support for id types other than String * BlockSQLSerializer: document the interface * VeriBlockStore: port to VeriBlockBlockRepository * BitcoinBlocksRepository: port to GenericBlockRepository; add tests * BitcoinStore: port to BitcoinBlockRepository * remove GenericBlocksRepository * SqliteBitcoinBlocksTableTest: port to BitcoinBlockRepository * remove BlockData * VeriBlockStore: fix replace(); add erase() * tests: VeriBlockStore: add coverage for erase() and replace() * Added interfaces for client wrappers (#8) * Added interfaces for client wrappers * Fixes for related projects after refactoring * Feature/fix setbitcoinheadchange (#12) * fix SetBitcoinHeadChange to match SetVeriBlockHeadChange * tests: add SetBitcoinHeadChange coverage * Feature/fix veriblock rewind (#13) * fix a typo * VeriBlockBlockchain: create correct rewind records and fix rewind() * tests: VeriBlockBlockchain: add rewind() coverage * Change: remove an excessive restriction that makes it impossible to store block creation records * Fix wrong package for new files from PR-10 (#11) * Add codecov to CI (#15) * Add codecov to CI Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Enable xml Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Fix Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Feature/fix bitcoin rewind (#14) * BitcoinBlockchain: create correct rewind records and fix rewind() * tests: BitcoinBlockchain: add rewind() coverage * Implement GetLastKnown*Blocks API (#19) * implement the getLastKnown*Blocks API * expose the getLastKnown*Blocks API via GRPC; update the GRPC bindings * *ProtoConverter: add the license header * add getLastKnown*Blocks API to IVeriBlockSecurity * Ensure that erase cannot split the blockchain into 2 disconnected parts (#20) * GenericBlockRepository: implement isInUse() * BitcoinStore: add a check that erasing a block must not split the blockchain into 2 disconnected parts * VeriBlockStore: add a check that erasing a block must not split the blockchain into 2 disconnected parts * GenericBlockRepository: clean up isInUse() * Feature/test remove payloads alt 34 (#21) * Cleanup * ATV and VTB generation helpers added * ATV and VTB Security service tests * Test for removePayloads * GenericBlockRepository: refactor to use try-with-resources (#22) * tests: BitcoinBlockRepository: add coverage for getAll(), clear(), isInUse() and getEndsWithId() (#23) * tests: VeriBlockBlockRepository: add coverage for getAll(), get(), clear() and getEndsWithId() using a trimmed hash (#24) * Add new calculatePopDifficultyForBlock method with rpc calls. (#18) * Add new calculatePopDifficultyForBlock method with rpc calls. Covered by tests * update popDifficulty algorithm * Fixes * get rid of references to DatatypeConverter (#27) * tests: VeriBlockSecurity: add getLastKnown*Blocks coverage (#26) * alt-integration-grpc-service: make the veriblock network configurable (#25) * ALT_60 Clean up duplicate code (#28) * ALT_60 Clean up duplicate code MerkleTree, VeriBlockAtv/Vtb (#29) * APL-61 allow disabling the block difficulty check (#32) * APL-61 allow disabling the block difficulty check * APL-61 small fix * APL-61 move validation function * AddPayloads: throw VerificationException instead of returning a boolean (#36) * implement blockchain bootstrapping, add tests (#30) * Alt 64 allow disabling block difficulty btc (#38) * ALT-64 allow disabling btc block difficulty check by setting the network name to "unknown" * configure bootstrap, fork resolution, pop rewards etc via the config file (#31) * implement setConfig() (#34) * handle the first bootstrap block correctly; add tests (#33) * handle the first bootstrap block correctly; add tests * rename check*Contextually to checkConnectivity; rebase * remove set*Config APIs superseded by setConfig() (#35) * remove set*Config APIs superseded by setConfig() * Better logging and network selection fix (#37) * Better logging and network selection fix * Better install script * Fixes (#40) * configure VBK and BTC network parameters (#42) * ALT-71 Getting conf(property file) outside of the jar. (#43) * Use jitpack to grab alt-integration-proto (#44) * Use jitpack to grab alt-integration-proto * Use alt-integration-proto-v2 * fix *Store.replace() to allow replacing a block referenced by another block(eg as the previous block) (#45) * ALT-77 Add logs if parsing config fails. (#47) * If sonar fails, do not fail the whole job * *Store.replace(): check that the old and new block hashes match (#48) * Trying to fix Jitpack publishing (#50) * Release v0.0.1 (#46) (#51) * Add forkresolution and grpc methods for the forkresolution. * Cleanup * StreamUtils: add new function to read a single integer * Refactored write of the Int values according to previous Pull Request * Improve PoPtx database. * Add sonarqube task & add jacoco for coverage * Bump sonarqube version * Update gradle.yml * Fix Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Update pop rewarding (#5) * Add using the PoPTxDatabase in the PoPRewards algorithms * update PoPRewards test with using the PoPTxdatabase. Fix forkresolution. * Add new method SavePoPTransactionData into the IntegrationService * StreamUtils: swap parameter order from max/min to min/max (#2) * BitcoinStore: fix replace and erase (#6) * BitcoinStore: fix replace(); add erase() * tests: BitcoinStore: add coverage for erase() and replace() * Remove data field (#7) * Add using the PoPTxDatabase in the PoPRewards algorithms * update PoPRewards test with using the PoPTxdatabase. Fix forkresolution. * Add new method SavePoPTransactionData into the IntegrationService * Remove data field from VeriBlockTransaction class, fix tests. * remove temporary files from git * Fixes * Feature/veriblockstore fix replace erase (#10) * GenericBlockRepository: refactor to allow schema changes and working with stored block types directly; rename from GenericBlocksRepository * port VeriBlockBlockRepository to use GenericBlockRepository; add essential tests; rename from VeriBlockBlocksRepository * VeriBlockBlockRepository: add support for storing the block of proof * GenericBlockRepository: add support for id types other than String * BlockSQLSerializer: document the interface * VeriBlockStore: port to VeriBlockBlockRepository * BitcoinBlocksRepository: port to GenericBlockRepository; add tests * BitcoinStore: port to BitcoinBlockRepository * remove GenericBlocksRepository * SqliteBitcoinBlocksTableTest: port to BitcoinBlockRepository * remove BlockData * VeriBlockStore: fix replace(); add erase() * tests: VeriBlockStore: add coverage for erase() and replace() * Added interfaces for client wrappers (#8) * Added interfaces for client wrappers * Fixes for related projects after refactoring * Feature/fix setbitcoinheadchange (#12) * fix SetBitcoinHeadChange to match SetVeriBlockHeadChange * tests: add SetBitcoinHeadChange coverage * Feature/fix veriblock rewind (#13) * fix a typo * VeriBlockBlockchain: create correct rewind records and fix rewind() * tests: VeriBlockBlockchain: add rewind() coverage * Change: remove an excessive restriction that makes it impossible to store block creation records * Fix wrong package for new files from PR-10 (#11) * Add codecov to CI (#15) * Add codecov to CI Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Enable xml Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Fix Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Feature/fix bitcoin rewind (#14) * BitcoinBlockchain: create correct rewind records and fix rewind() * tests: BitcoinBlockchain: add rewind() coverage * Implement GetLastKnown*Blocks API (#19) * implement the getLastKnown*Blocks API * expose the getLastKnown*Blocks API via GRPC; update the GRPC bindings * *ProtoConverter: add the license header * add getLastKnown*Blocks API to IVeriBlockSecurity * Ensure that erase cannot split the blockchain into 2 disconnected parts (#20) * GenericBlockRepository: implement isInUse() * BitcoinStore: add a check that erasing a block must not split the blockchain into 2 disconnected parts * VeriBlockStore: add a check that erasing a block must not split the blockchain into 2 disconnected parts * GenericBlockRepository: clean up isInUse() * Feature/test remove payloads alt 34 (#21) * Cleanup * ATV and VTB generation helpers added * ATV and VTB Security service tests * Test for removePayloads * GenericBlockRepository: refactor to use try-with-resources (#22) * tests: BitcoinBlockRepository: add coverage for getAll(), clear(), isInUse() and getEndsWithId() (#23) * tests: VeriBlockBlockRepository: add coverage for getAll(), get(), clear() and getEndsWithId() using a trimmed hash (#24) * Add new calculatePopDifficultyForBlock method with rpc calls. (#18) * Add new calculatePopDifficultyForBlock method with rpc calls. Covered by tests * update popDifficulty algorithm * Fixes * get rid of references to DatatypeConverter (#27) * tests: VeriBlockSecurity: add getLastKnown*Blocks coverage (#26) * alt-integration-grpc-service: make the veriblock network configurable (#25) * ALT_60 Clean up duplicate code (#28) * ALT_60 Clean up duplicate code MerkleTree, VeriBlockAtv/Vtb (#29) * APL-61 allow disabling the block difficulty check (#32) * APL-61 allow disabling the block difficulty check * APL-61 small fix * APL-61 move validation function * AddPayloads: throw VerificationException instead of returning a boolean (#36) * implement blockchain bootstrapping, add tests (#30) * Alt 64 allow disabling block difficulty btc (#38) * ALT-64 allow disabling btc block difficulty check by setting the network name to "unknown" * configure bootstrap, fork resolution, pop rewards etc via the config file (#31) * implement setConfig() (#34) * handle the first bootstrap block correctly; add tests (#33) * handle the first bootstrap block correctly; add tests * rename check*Contextually to checkConnectivity; rebase * remove set*Config APIs superseded by setConfig() (#35) * remove set*Config APIs superseded by setConfig() * Better logging and network selection fix (#37) * Better logging and network selection fix * Better install script * Fixes (#40) * configure VBK and BTC network parameters (#42) * ALT-71 Getting conf(property file) outside of the jar. (#43) * Use jitpack to grab alt-integration-proto (#44) * Use jitpack to grab alt-integration-proto * Use alt-integration-proto-v2 * fix *Store.replace() to allow replacing a block referenced by another block(eg as the previous block) (#45) * ALT-77 Add logs if parsing config fails. (#47) * If sonar fails, do not fail the whole job * Release v0.0.1 (#46) (#53) * Add forkresolution and grpc methods for the forkresolution. * Cleanup * StreamUtils: add new function to read a single integer * Refactored write of the Int values according to previous Pull Request * Improve PoPtx database. * Add sonarqube task & add jacoco for coverage * Bump sonarqube version * Update gradle.yml * Fix Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Update pop rewarding (#5) * Add using the PoPTxDatabase in the PoPRewards algorithms * update PoPRewards test with using the PoPTxdatabase. Fix forkresolution. * Add new method SavePoPTransactionData into the IntegrationService * StreamUtils: swap parameter order from max/min to min/max (#2) * BitcoinStore: fix replace and erase (#6) * BitcoinStore: fix replace(); add erase() * tests: BitcoinStore: add coverage for erase() and replace() * Remove data field (#7) * Add using the PoPTxDatabase in the PoPRewards algorithms * update PoPRewards test with using the PoPTxdatabase. Fix forkresolution. * Add new method SavePoPTransactionData into the IntegrationService * Remove data field from VeriBlockTransaction class, fix tests. * remove temporary files from git * Fixes * Feature/veriblockstore fix replace erase (#10) * GenericBlockRepository: refactor to allow schema changes and working with stored block types directly; rename from GenericBlocksRepository * port VeriBlockBlockRepository to use GenericBlockRepository; add essential tests; rename from VeriBlockBlocksRepository * VeriBlockBlockRepository: add support for storing the block of proof * GenericBlockRepository: add support for id types other than String * BlockSQLSerializer: document the interface * VeriBlockStore: port to VeriBlockBlockRepository * BitcoinBlocksRepository: port to GenericBlockRepository; add tests * BitcoinStore: port to BitcoinBlockRepository * remove GenericBlocksRepository * SqliteBitcoinBlocksTableTest: port to BitcoinBlockRepository * remove BlockData * VeriBlockStore: fix replace(); add erase() * tests: VeriBlockStore: add coverage for erase() and replace() * Added interfaces for client wrappers (#8) * Added interfaces for client wrappers * Fixes for related projects after refactoring * Feature/fix setbitcoinheadchange (#12) * fix SetBitcoinHeadChange to match SetVeriBlockHeadChange * tests: add SetBitcoinHeadChange coverage * Feature/fix veriblock rewind (#13) * fix a typo * VeriBlockBlockchain: create correct rewind records and fix rewind() * tests: VeriBlockBlockchain: add rewind() coverage * Change: remove an excessive restriction that makes it impossible to store block creation records * Fix wrong package for new files from PR-10 (#11) * Add codecov to CI (#15) * Add codecov to CI Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Enable xml Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Fix Signed-off-by: Bogdan Vaneev <warchantua@gmail.com> * Feature/fix bitcoin rewind (#14) * BitcoinBlockchain: create correct rewind records and fix rewind() * tests: BitcoinBlockchain: add rewind() coverage * Implement GetLastKnown*Blocks API (#19) * implement the getLastKnown*Blocks API * expose the getLastKnown*Blocks API via GRPC; update the GRPC bindings * *ProtoConverter: add the license header * add getLastKnown*Blocks API to IVeriBlockSecurity * Ensure that erase cannot split the blockchain into 2 disconnected parts (#20) * GenericBlockRepository: implement isInUse() * BitcoinStore: add a check that erasing a block must not split the blockchain into 2 disconnected parts * VeriBlockStore: add a check that erasing a block must not split the blockchain into 2 disconnected parts * GenericBlockRepository: clean up isInUse() * Feature/test remove payloads alt 34 (#21) * Cleanup * ATV and VTB generation helpers added * ATV and VTB Security service tests * Test for removePayloads * GenericBlockRepository: refactor to use try-with-resources (#22) * tests: BitcoinBlockRepository: add coverage for getAll(), clear(), isInUse() and getEndsWithId() (#23) * tests: VeriBlockBlockRepository: add coverage for getAll(), get(), clear() and getEndsWithId() using a trimmed hash (#24) * Add new calculatePopDifficultyForBlock method with rpc calls. (#18) * Add new calculatePopDifficultyForBlock method with rpc calls. Covered by tests * update popDifficulty algorithm * Fixes * get rid of references to DatatypeConverter (#27) * tests: VeriBlockSecurity: add getLastKnown*Blocks coverage (#26) * alt-integration-grpc-service: make the veriblock network configurable (#25) * ALT_60 Clean up duplicate code (#28) * ALT_60 Clean up duplicate code MerkleTree, VeriBlockAtv/Vtb (#29) * APL-61 allow disabling the block difficulty check (#32) * APL-61 allow disabling the block difficulty check * APL-61 small fix * APL-61 move validation function * AddPayloads: throw VerificationException instead of returning a boolean (#36) * implement blockchain bootstrapping, add tests (#30) * Alt 64 allow disabling block difficulty btc (#38) * ALT-64 allow disabling btc block difficulty check by setting the network name to "unknown" * configure bootstrap, fork resolution, pop rewards etc via the config file (#31) * implement setConfig() (#34) * handle the first bootstrap block correctly; add tests (#33) * handle the first bootstrap block correctly; add tests * rename check*Contextually to checkConnectivity; rebase * remove set*Config APIs superseded by setConfig() (#35) * remove set*Config APIs superseded by setConfig() * Better logging and network selection fix (#37) * Better logging and network selection fix * Better install script * Fixes (#40) * configure VBK and BTC network parameters (#42) * ALT-71 Getting conf(property file) outside of the jar. (#43) * Use jitpack to grab alt-integration-proto (#44) * Use jitpack to grab alt-integration-proto * Use alt-integration-proto-v2 * fix *Store.replace() to allow replacing a block referenced by another block(eg as the previous block) (#45) * ALT-77 Add logs if parsing config fails. (#47) * If sonar fails, do not fail the whole job
1 parent 9dab19e commit 89739d0

File tree

14 files changed

+114
-43
lines changed

14 files changed

+114
-43
lines changed

alt-integration-adapter-java/build.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ repositories {
77
maven { url 'https://jitpack.io' }
88
}
99

10-
version = '0.1.2'
11-
1210
dependencies {
1311
testImplementation 'junit:junit:4.12'
1412

alt-integration-grpc-client/build.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ repositories {
77
maven { url 'https://jitpack.io' }
88
}
99

10-
version = '0.1.2'
11-
1210
dependencies {
1311
testCompile 'junit:junit:4.12'
1412
compile group: 'io.grpc', name: 'grpc-netty-shaded', version: '1.23.0'

build.gradle

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515

1616
apply plugin: 'nebula.release'
1717

18-
version = '0.1.2'
18+
version = '0.0.2'
1919

2020
allprojects {
2121
repositories {
@@ -51,11 +51,6 @@ task printTCBuildNumber() {
5151
println "##teamcity[buildNumber \'${version}\']"
5252
}
5353

54-
task wrapper(type: Wrapper) {
55-
gradleVersion = '4.10.2'
56-
}
57-
58-
5954
sonarqube {
6055
properties {
6156
property "sonar.projectKey", "vbk:alt-integration"

core/build.gradle

+28-23
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@ plugins {
22
id "java"
33
id "idea"
44
id "java-library"
5-
id "maven-publish"
6-
id "com.jfrog.artifactory"
75
}
86

9-
version = '0.1.4'
10-
117
dependencies {
128
testImplementation 'junit:junit:4.12'
139
testCompile 'org.mockito:mockito-core:2.7.22'
1410

15-
1611
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60'
1712
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
1813

@@ -34,31 +29,41 @@ jar {
3429
}
3530
}
3631

32+
sourceSets {
33+
main {
34+
resources {
35+
srcDirs = ['conf']
36+
includes = ["**/*.properties"]
37+
}
3738

38-
artifactory {
39-
contextUrl = artifactory_url
40-
publish {
41-
repository {
42-
repoKey = artifactory_repoKey
43-
username = artifactory_user
44-
password = artifactory_password
45-
maven = true
39+
java {
40+
srcDirs += ['conf']
41+
}
42+
}
43+
}
44+
45+
sourceSets {
46+
main {
47+
resources {
48+
srcDirs = ['conf']
49+
includes = ["**/*.properties"]
4650
}
4751

48-
defaults {
49-
publications('mavenJava')
50-
publishArtifacts = true
52+
java {
53+
srcDirs += ['conf']
5154
}
5255
}
5356
}
5457

55-
publishing {
56-
publications {
57-
mavenJava(MavenPublication) {
58-
groupId 'veriblock'
59-
artifactId 'integrations-sdk'
60-
version this.version
61-
from components.java
58+
sourceSets {
59+
main {
60+
resources {
61+
srcDirs = ['conf']
62+
includes = ["**/*.properties"]
63+
}
64+
65+
java {
66+
srcDirs += ['conf']
6267
}
6368
}
6469
}

gradle/wrapper/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!gradle-wrapper.jar
2+
!gradle-wrapper.properties

gradle/wrapper/gradle-wrapper.jar

-561 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#Sat Aug 03 13:58:30 CEST 2019
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
1+
#Wed Nov 20 16:49:53 EET 2019
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists

gradlew

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env sh
22

3+
#
4+
# Copyright 2015 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
319
##############################################################################
420
##
521
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
2844
APP_BASE_NAME=`basename "$0"`
2945

3046
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
47+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
3248

3349
# Use the maximum available, or set MAX_FD != -1 to use that value.
3450
MAX_FD="maximum"
@@ -109,8 +125,8 @@ if $darwin; then
109125
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110126
fi
111127

112-
# For Cygwin, switch paths to Windows format before running java
113-
if $cygwin ; then
128+
# For Cygwin or MSYS, switch paths to Windows format before running java
129+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
114130
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115131
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116132
JAVACMD=`cygpath --unix "$JAVACMD"`

gradlew.bat

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
117
@if "%DEBUG%" == "" @echo off
218
@rem ##########################################################################
319
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
1430
set APP_HOME=%DIRNAME%
1531

1632
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17-
set DEFAULT_JVM_OPTS=
33+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
1834

1935
@rem Find java.exe
2036
if defined JAVA_HOME goto findJavaFromJavaHome

reference-lib/build.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ plugins {
44
id "java-library"
55
}
66

7-
version = '0.1.2'
8-
97
dependencies {
108
testImplementation 'junit:junit:4.12'
119
testImplementation 'org.mockito:mockito-core:2.7.22'
1210

13-
compile project(':core')
1411
compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.28.0'
12+
13+
compile project(':core')
1514
}
1615

1716
sourceSets {

reference-lib/src/main/java/org/veriblock/integrations/blockchain/store/BitcoinStore.java

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ public StoredBitcoinBlock erase(Sha256Hash hash) throws BlockStoreException, SQL
105105
}
106106

107107
public StoredBitcoinBlock replace(Sha256Hash hash, StoredBitcoinBlock storedBlock) throws BlockStoreException, SQLException {
108+
if (hash != null && storedBlock != null && !hash.equals(storedBlock.getHash())) {
109+
throw new BlockStoreException("The original and replacement block hashes must match");
110+
}
108111
StoredBitcoinBlock replaced = get(hash);
109112
bitcoinRepository.save(storedBlock);
110113
return replaced;

reference-lib/src/main/java/org/veriblock/integrations/blockchain/store/VeriBlockStore.java

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public StoredVeriBlockBlock erase(VBlakeHash hash) throws BlockStoreException, S
106106
}
107107

108108
public StoredVeriBlockBlock replace(VBlakeHash hash, StoredVeriBlockBlock storedBlock) throws BlockStoreException, SQLException {
109+
if (hash != null && storedBlock != null && !hash.equals(storedBlock.getHash())) {
110+
throw new BlockStoreException("The original and replacement block hashes must match");
111+
}
109112
StoredVeriBlockBlock replaced = get(hash);
110113
veriBlockRepository.save(storedBlock);
111114
return replaced;

reference-lib/src/test/java/org/veriblock/integrations/blockchain/store/BitcoinStoreTest.java

+18
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,22 @@ public void ReplaceNonexistentTest() throws SQLException, IOException {
258258
storedBlock = store.get(newBlock.getHash());
259259
Assert.assertEquals(newBlock, storedBlock);
260260
}
261+
262+
@Test
263+
public void replaceWithDifferentHashTest() throws SQLException, IOException {
264+
store.put(storedBlock1);
265+
266+
try {
267+
store.replace(storedBlock1.getHash(), storedBlock2);
268+
Assert.fail("Should throw a BlockStoreException");
269+
} catch (BlockStoreException e) {
270+
Assert.assertEquals(e.getMessage(), "The original and replacement block hashes must match");
271+
}
272+
273+
StoredBitcoinBlock storedBlock = store.get(storedBlock1.getHash());
274+
Assert.assertEquals(storedBlock, storedBlock1);
275+
276+
storedBlock = store.get(storedBlock2.getHash());
277+
Assert.assertEquals(storedBlock, null);
278+
}
261279
}

reference-lib/src/test/java/org/veriblock/integrations/blockchain/store/VeriBlockStoreTest.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void EraseCantSplitBlockchainTest() throws SQLException, IOException {
7070
Assert.assertEquals(store.erase(block2.getHash()), storedBlock2);
7171
Assert.assertEquals(store.erase(block1.getHash()), storedBlock1);
7272
}
73-
73+
7474
@Test
7575
public void nonexistingBlockStoreTest() throws SQLException, IOException {
7676
VBlakeHash hash = VBlakeHash.hash("123".getBytes());
@@ -265,4 +265,22 @@ public void ReplaceReferencedBlockTest() throws SQLException, IOException {
265265
StoredVeriBlockBlock storedBlock = store.get(storedBlock1.getHash());
266266
Assert.assertEquals(newBlock, storedBlock);
267267
}
268+
269+
@Test
270+
public void replaceWithDifferentHashTest() throws SQLException, IOException {
271+
store.put(storedBlock1);
272+
273+
try {
274+
store.replace(storedBlock1.getHash(), storedBlock2);
275+
Assert.fail("Should throw a BlockStoreException");
276+
} catch (BlockStoreException e) {
277+
Assert.assertEquals(e.getMessage(), "The original and replacement block hashes must match");
278+
}
279+
280+
StoredVeriBlockBlock storedBlock = store.get(storedBlock1.getHash());
281+
Assert.assertEquals(storedBlock, storedBlock1);
282+
283+
storedBlock = store.get(storedBlock2.getHash());
284+
Assert.assertEquals(storedBlock, null);
285+
}
268286
}

0 commit comments

Comments
 (0)