From 6c54cc679c4f9d407acabcebe2eab2070d751c6d Mon Sep 17 00:00:00 2001 From: djmil Date: Tue, 28 Nov 2023 23:44:36 +0100 Subject: [PATCH] moar logs --- .../contracts/GameProposalContract.java | 4 +-- .../contracts/GameResultContract.java | 4 +++ .../cordacheckers/gamestate/CommitTrx.java | 34 +++++++++++-------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameProposalContract.java b/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameProposalContract.java index 0d64da5..9179dec 100644 --- a/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameProposalContract.java +++ b/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameProposalContract.java @@ -19,7 +19,7 @@ public class GameProposalContract implements net.corda.v5.ledger.utxo.Contract { requireThat(trx.getCommands().size() == 1, GameCommand.REQUIRE_SINGLE_COMMAND); final GameCommand command = getSingleCommand(trx, GameCommand.class); - log.info("GameProposalContract.verify() " +command); + log.info("GameProposalContract.verify() " +command.getAction()); switch (command.getAction()) { case GAME_PROPOSAL_CREATE: @@ -42,7 +42,7 @@ public class GameProposalContract implements net.corda.v5.ledger.utxo.Contract { throw new GameCommand.ActionException(); } - log.info("GameProposalContract.verify() " +command + " [OK]"); + log.info("GameProposalContract.verify() " +command.getAction() + " [OK]"); } } diff --git a/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameResultContract.java b/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameResultContract.java index d328633..16e15f6 100644 --- a/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameResultContract.java +++ b/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameResultContract.java @@ -19,6 +19,8 @@ public class GameResultContract implements net.corda.v5.ledger.utxo.Contract { requireThat(trx.getCommands().size() == 1, GameCommand.REQUIRE_SINGLE_COMMAND); final GameCommand command = getSingleCommand(trx, GameCommand.class); + log.info("GameResultContract.verify() " +command.getAction()); + switch (command.getAction()) { case SURRENDER: command.validateSurrender(trx); @@ -35,6 +37,8 @@ public class GameResultContract implements net.corda.v5.ledger.utxo.Contract { default: throw new GameCommand.ActionException(); } + + log.info("GameResultContract.verify() " +command.getAction() + " [OK]"); } } diff --git a/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrx.java b/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrx.java index 9640917..0e0f357 100644 --- a/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrx.java +++ b/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/CommitTrx.java @@ -53,23 +53,29 @@ public class CommitTrx implements SubFlow { public SecureHash call() { log.info("GameState commit started"); - /* - * Calls the Corda provided finalise() function which gather signatures from the counterparty, - * notarises the transaction and persists the transaction to each party's vault. - */ + try { + /* + * Calls the Corda provided finalise() function which gather signatures from the counterparty, + * notarises the transaction and persists the transaction to each party's vault. + */ - List sessionsList = (this.custodyName != null) - ? Arrays.asList(flowMessaging.initiateFlow(this.counterpartyName), flowMessaging.initiateFlow(this.custodyName)) - : Arrays.asList(flowMessaging.initiateFlow(this.counterpartyName)); + List sessionsList = (this.custodyName != null) + ? Arrays.asList(flowMessaging.initiateFlow(this.counterpartyName), flowMessaging.initiateFlow(this.custodyName)) + : Arrays.asList(flowMessaging.initiateFlow(this.counterpartyName)); - System.out.println("sessionsList size " + sessionsList.size()); + System.out.println("sessionsList size " + sessionsList.size()); - final SecureHash trxId = ledgerService - .finalize(this.utxTrxCandidate, sessionsList) - .getTransaction() - .getId(); + final SecureHash trxId = ledgerService + .finalize(this.utxTrxCandidate, sessionsList) + .getTransaction() + .getId(); - log.info("GameState commit " +trxId); - return trxId; + log.info("GameState commit " +trxId); + return trxId; + + } catch (Exception e) { + log.warn("GameState finality failed", e); + throw e; + } } }