diff --git a/smart-contract/hyperledger-fabric/v2/java/build.gradle.kts b/smart-contract/hyperledger-fabric/v2/java/build.gradle.kts index 140d57d..90a42f1 100644 --- a/smart-contract/hyperledger-fabric/v2/java/build.gradle.kts +++ b/smart-contract/hyperledger-fabric/v2/java/build.gradle.kts @@ -18,6 +18,7 @@ plugins { application id("com.github.johnrengelman.shadow") version "7.1.2" id("com.diffplug.spotless") version "6.19.0" + id("io.freefair.lombok") version "8.6" } // java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } } diff --git a/smart-contract/hyperledger-fabric/v2/java/gradle.properties b/smart-contract/hyperledger-fabric/v2/java/gradle.properties index a07d4e8..7dc39e1 100644 --- a/smart-contract/hyperledger-fabric/v2/java/gradle.properties +++ b/smart-contract/hyperledger-fabric/v2/java/gradle.properties @@ -1,2 +1,2 @@ openJMLVersion = 0.17.0-alpha-15 -withoutOpenJML = false \ No newline at end of file +withoutOpenJML = true \ No newline at end of file diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/NotFoundException.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/NotFoundException.java index 7afab25..b0051db 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/NotFoundException.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/NotFoundException.java @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: Apache-2.0 */ package hu.bme.mit.ftsrg.chaincode.tpcc.api; -public final class NotFoundException extends Exception { +import lombok.experimental.StandardException; - NotFoundException(String message) { - super(message); - } -} +@StandardException +public final class NotFoundException extends Exception {} diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCBusinessAPI.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCBusinessAPI.java index 83b14dc..ae329c1 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCBusinessAPI.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCBusinessAPI.java @@ -7,7 +7,6 @@ import hu.bme.mit.ftsrg.chaincode.tpcc.data.extra.*; import hu.bme.mit.ftsrg.chaincode.tpcc.data.input.*; import hu.bme.mit.ftsrg.chaincode.tpcc.data.output.*; -import hu.bme.mit.ftsrg.chaincode.tpcc.middleware.TPCCContext; import hu.bme.mit.ftsrg.chaincode.tpcc.util.JSON; import hu.bme.mit.ftsrg.hypernate.Registry; import hu.bme.mit.ftsrg.hypernate.context.ContextWithRegistry; diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/TPCCContext.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContext.java similarity index 88% rename from smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/TPCCContext.java rename to smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContext.java index 77a55e8..dbeba0c 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/TPCCContext.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContext.java @@ -1,11 +1,14 @@ /* SPDX-License-Identifier: Apache-2.0 */ -package hu.bme.mit.ftsrg.chaincode.tpcc.middleware; +package hu.bme.mit.ftsrg.chaincode.tpcc.api; import hu.bme.mit.ftsrg.hypernate.context.ContextWithRegistry; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.List; + +import hu.bme.mit.ftsrg.hypernate.middleware.LoggingStubMiddleware; +import hu.bme.mit.ftsrg.hypernate.middleware.WriteBackCachedChaincodeStubMiddleware; import org.hyperledger.fabric.shim.ChaincodeStub; /** Context specialized for the TPC-C chaincode implementation. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContractAPI.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContractAPI.java index babc9fb..29f27fa 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContractAPI.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContractAPI.java @@ -5,7 +5,6 @@ import hu.bme.mit.ftsrg.chaincode.MethodLogger; import hu.bme.mit.ftsrg.chaincode.tpcc.data.entity.*; import hu.bme.mit.ftsrg.chaincode.tpcc.data.input.*; -import hu.bme.mit.ftsrg.chaincode.tpcc.middleware.TPCCContext; import hu.bme.mit.ftsrg.chaincode.tpcc.util.JSON; import hu.bme.mit.ftsrg.hypernate.entity.EntityExistsException; import hu.bme.mit.ftsrg.hypernate.entity.EntityNotFoundException; diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Customer.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Customer.java index 23bb3a9..69908f0 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Customer.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Customer.java @@ -8,9 +8,9 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the CUSTOMER table. */ +@DataType @EqualsAndHashCode -@DataType() -public class Customer implements Entity { +public final class Customer implements Entity { /** The customer ID. Primary key. */ @KeyPart diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/District.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/District.java index d85e4bf..d902a72 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/District.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/District.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the DISTRICT table. */ +@DataType @EqualsAndHashCode -@DataType() public final class District implements Entity { /** The district ID. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/History.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/History.java index f28867f..a3aae0b 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/History.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/History.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the HISTORY table. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class History implements Entity { /** The customer ID. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Item.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Item.java index 0f306ec..72a63d7 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Item.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Item.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the ITEM table. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class Item implements Entity { /** The ID of the item. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/NewOrder.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/NewOrder.java index 3685406..ed943f5 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/NewOrder.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/NewOrder.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the NEW-ORDER table. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class NewOrder implements Entity { /** The order ID. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Order.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Order.java index 1088726..98f73fc 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Order.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Order.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the ORDER table. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class Order implements Entity { /** The order ID. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/OrderLine.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/OrderLine.java index 2df7189..a8ebfa1 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/OrderLine.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/OrderLine.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the ORDER-LINE table. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class OrderLine implements Entity { /** The order ID associated with the order line. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Stock.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Stock.java index d20f424..bf94373 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Stock.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Stock.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the STOCK table. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class Stock implements Entity { /** The ID of the item associated with the stock. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Warehouse.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Warehouse.java index 935db78..5fcf800 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Warehouse.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Warehouse.java @@ -8,8 +8,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Essentially, the WAREHOUSE table. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public class Warehouse implements Entity { /** The warehouse ID. Primary key. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/DeliveredOrder.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/DeliveredOrder.java index 0c73764..c2dcd04 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/DeliveredOrder.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/DeliveredOrder.java @@ -7,8 +7,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Class to encapsulate the delivered field's data of a {@link DeliveryOutput}. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class DeliveredOrder { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/ItemsData.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/ItemsData.java index 6e4ee9a..ea49603 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/ItemsData.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/ItemsData.java @@ -7,8 +7,8 @@ import org.hyperledger.fabric.contract.annotation.Property; /** Class to encapsulate the items field's data of a {@link NewOrderOutput}. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class ItemsData { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/OrderLineData.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/OrderLineData.java index c8c6c8c..5c65a33 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/OrderLineData.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/OrderLineData.java @@ -10,8 +10,8 @@ /** * Class to encapsulate the order_lines field's data of a {@link OrderStatusOutput}. */ -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class OrderLineData { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/DeliveryInput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/DeliveryInput.java index f76c27e..1e8462f 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/DeliveryInput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/DeliveryInput.java @@ -1,13 +1,12 @@ /* SPDX-License-Identifier: Apache-2.0 */ package hu.bme.mit.ftsrg.chaincode.tpcc.data.input; -import hu.bme.mit.ftsrg.chaincode.tpcc.middleware.TPCCContext; import lombok.EqualsAndHashCode; import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class DeliveryInput { /** The warehouse ID. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/NewOrderInput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/NewOrderInput.java index 01207a3..7c3db84 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/NewOrderInput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/NewOrderInput.java @@ -5,8 +5,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class NewOrderInput { /** The warehouse ID. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/OrderStatusInput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/OrderStatusInput.java index 703f158..4178e0e 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/OrderStatusInput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/OrderStatusInput.java @@ -5,8 +5,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class OrderStatusInput { /** The warehouse ID. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/PaymentInput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/PaymentInput.java index d3fb771..062292c 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/PaymentInput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/PaymentInput.java @@ -5,8 +5,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class PaymentInput { /** The warehouse ID. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/StockLevelInput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/StockLevelInput.java index 68a1037..d8b7ec4 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/StockLevelInput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/StockLevelInput.java @@ -5,8 +5,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class StockLevelInput { /** The warehouse ID. */ diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/DeliveryOutput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/DeliveryOutput.java index 002230d..6936e51 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/DeliveryOutput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/DeliveryOutput.java @@ -7,8 +7,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class DeliveryOutput { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/NewOrderOutput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/NewOrderOutput.java index d06196b..58091cd 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/NewOrderOutput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/NewOrderOutput.java @@ -11,8 +11,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class NewOrderOutput { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/OrderStatusOutput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/OrderStatusOutput.java index eeb05fa..ce852df 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/OrderStatusOutput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/OrderStatusOutput.java @@ -9,8 +9,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class OrderStatusOutput { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/PaymentOutput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/PaymentOutput.java index 2beae18..8fa7b8a 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/PaymentOutput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/PaymentOutput.java @@ -9,8 +9,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class PaymentOutput { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/StockLevelOutput.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/StockLevelOutput.java index c698f18..8eb184a 100644 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/StockLevelOutput.java +++ b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/StockLevelOutput.java @@ -6,8 +6,8 @@ import org.hyperledger.fabric.contract.annotation.DataType; import org.hyperledger.fabric.contract.annotation.Property; -@EqualsAndHashCode @DataType +@EqualsAndHashCode public final class StockLevelOutput { @Property(schema = {"minimum", "0"}) diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/LoggingStubMiddleware.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/LoggingStubMiddleware.java deleted file mode 100644 index 70fac07..0000000 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/LoggingStubMiddleware.java +++ /dev/null @@ -1,56 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -package hu.bme.mit.ftsrg.chaincode.tpcc.middleware; - -import hu.bme.mit.ftsrg.hypernate.middleware.ChaincodeStubMiddlewareBase; -import java.util.Arrays; -import org.hyperledger.fabric.shim.ChaincodeStub; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.event.Level; - -/** - * Stub middleware that simply logs all {@link ChaincodeStub#getState(String)}, {@link - * ChaincodeStub#putState(String, byte[])}, and {@link ChaincodeStub#delState(String)} calls. - * - * @see ChaincodeStubMiddlewareBase - */ -public class LoggingStubMiddleware extends ChaincodeStubMiddlewareBase { - - private static final Logger logger = LoggerFactory.getLogger(LoggingStubMiddleware.class); - private final Level logLevel; - - public LoggingStubMiddleware(final ChaincodeStub next) { - this(next, Level.INFO); - } - - public LoggingStubMiddleware(final ChaincodeStub next, final Level logLevel) { - super(next); - this.logLevel = logLevel; - } - - @Override - public byte[] getState(final String key) { - logger.atLevel(this.logLevel).log("Getting state for key '{}'", key); - final byte[] value = this.nextLayer.getState(key); - logger - .atLevel(this.logLevel) - .log("Got state for key '{}'; value = '{}'", key, Arrays.toString(value)); - return value; - } - - @Override - public void putState(final String key, final byte[] value) { - logger - .atLevel(this.logLevel) - .log("Setting state for key '{}' to have value '{}'", key, Arrays.toString(value)); - this.nextLayer.putState(key, value); - logger.atLevel(this.logLevel).log("Done setting state for key '{}'", key); - } - - @Override - public void delState(final String key) { - logger.atLevel(this.logLevel).log("Deleting state for key '{}'", key); - this.nextLayer.delState(key); - logger.atLevel(this.logLevel).log("Done deleting state for key '{}'", key); - } -} diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/UpdateThrottledChaincodeStubMiddleware.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/UpdateThrottledChaincodeStubMiddleware.java deleted file mode 100644 index b8a7149..0000000 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/UpdateThrottledChaincodeStubMiddleware.java +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -package hu.bme.mit.ftsrg.chaincode.tpcc.middleware; - -import hu.bme.mit.ftsrg.hypernate.middleware.ChaincodeStubMiddlewareBase; -import org.hyperledger.fabric.shim.ChaincodeStub; - -/** - * Stub middleware that only sends {@link ChaincodeStub#putState(String, byte[])} calls once the - * transaction is finished. - * - * @see ChaincodeStubMiddlewareBase - */ -public final class UpdateThrottledChaincodeStubMiddleware extends ChaincodeStubMiddlewareBase { - - public UpdateThrottledChaincodeStubMiddleware(ChaincodeStub nextLayer) { - super(nextLayer); - } - - /* TODO implement ? */ -} diff --git a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/WriteBackCachedChaincodeStubMiddleware.java b/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/WriteBackCachedChaincodeStubMiddleware.java deleted file mode 100644 index c609c15..0000000 --- a/smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/middleware/WriteBackCachedChaincodeStubMiddleware.java +++ /dev/null @@ -1,152 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -package hu.bme.mit.ftsrg.chaincode.tpcc.middleware; - -import hu.bme.mit.ftsrg.hypernate.middleware.ChaincodeStubMiddlewareBase; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import org.hyperledger.fabric.shim.ChaincodeStub; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Stub middleware that caches reads in a local state. - * - * @see ChaincodeStubMiddlewareBase - */ -public final class WriteBackCachedChaincodeStubMiddleware extends ChaincodeStubMiddlewareBase { - - private static final Logger logger = - LoggerFactory.getLogger(WriteBackCachedChaincodeStubMiddleware.class); - - private final Map cache = new HashMap<>(); - - WriteBackCachedChaincodeStubMiddleware(final ChaincodeStub next) { - super(next); - } - - @Override - public byte[] getState(final String key) { - CachedItem cached = cache.get(key); - - // New read, add to cache - if (cached == null) { - logger.debug("Cache miss for key={} while reading; getting from next layer & caching", key); - final byte[] value = this.nextLayer.getState(key); - cached = new CachedItem(key, value); - cache.put(key, cached); - } - - // Already marked for deletion - if (cached.isToDelete()) { - logger.debug("Value at key={} marked for deletion; returning null", key); - return null; - } - - logger.debug("Returning value of cached item at key={}", key); - return cached.getValue(); - } - - @Override - public void putState(final String key, final byte[] value) { - CachedItem cached = cache.get(key); - - // Blind write! - if (cached == null) { - logger.debug( - "Cache miss for key={} while writing; creating new cache entry with null value", key); - cached = new CachedItem(key, null); // Initial value set later - cache.put(key, cached); - } - - if (cached.isToDelete()) { - logger.error("Entry at key={} already deleted; cannot update", key); - throw new RuntimeException("Ledger entry " + key + " is already marked for deletion"); - } - - logger.debug( - "Setting value for cache item with key={} to a {}-long byte array", key, value.length); - cached.setValue(value); // Sets the dirty flag if needed - } - - @Override - public void delState(final String key) { - CachedItem cached = cache.get(key); - - // Blind delete! - if (cached == null) { - logger.debug( - "Cache miss for key={} while deleting; creating new cache entry with null value", key); - cached = new CachedItem(key, null); - cache.put(key, cached); - } - - logger.debug("Deleting value from cache with key={}", key); - cached.delete(); - } - - public void dispose() { - for (final Map.Entry entry : cache.entrySet()) { - final CachedItem item = entry.getValue(); - - if (item == null || !item.isDirty() || item.getValue() == null) { - continue; - } - - if (item.isToDelete()) { - this.nextLayer.delState(item.getKey()); - } else { - this.nextLayer.putState(item.getKey(), item.getValue()); - } - } - } - - private static final class CachedItem { - - private final String key; - private byte[] value; - private boolean toDelete = false; - private boolean dirty = false; - - CachedItem(final String key, final byte[] value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return this.key; - } - - public byte[] getValue() { - return this.value; - } - - public void setValue(final byte[] value) { - if (Arrays.equals(this.value, value)) { - return; - } - - this.value = value; - this.dirty = true; - } - - public boolean isDirty() { - return this.dirty; - } - - public boolean isToDelete() { - return this.toDelete; - } - - public void delete() { - if (!this.toDelete) { - this.toDelete = true; - this.dirty = true; - } - } - - public boolean hasValue() { - return this.value != null; - } - } -}