Skip to content

Commit

Permalink
Modify the code to fix the txn count and chaincode list
Browse files Browse the repository at this point in the history
Signed-off-by: ArchanaArige <nigam_archana@yahoo.co.in>
  • Loading branch information
ArchanaArige committed Jul 4, 2023
1 parent 6207479 commit f685645
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/persistence/fabric/CRUDService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export class CRUDService {
* @returns
* @memberof CRUDService
*/
async saveTransaction(network_name, transaction) {
async saveTransaction(network_name, transaction, chaincodeversion) {
const c = await this.sql.getRowByPkOne(
'select count(1) as c from transactions where blockid=$1 and txhash=$2 and channel_genesis_hash=$3 and network_name = $4 ',
[
Expand All @@ -325,8 +325,8 @@ export class CRUDService {
transaction.network_name = network_name;
await this.sql.saveRow('transactions', transaction);
await this.sql.updateBySql(
'update chaincodes set txcount =txcount+1 where channel_genesis_hash=$1 and network_name = $2 and name=$3',
[transaction.channel_genesis_hash, network_name, transaction.chaincodename]
'update chaincodes set txcount =txcount+1 where channel_genesis_hash=$1 and network_name = $2 and name=$3 and version=$4',
[transaction.channel_genesis_hash, network_name, transaction.chaincodename, chaincodeversion]
);
await this.sql.updateBySql(
'update channel set trans =trans+1 where channel_genesis_hash=$1 and network_name = $2 ',
Expand Down
2 changes: 1 addition & 1 deletion app/platform/fabric/gateway/FabricGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class FabricGateway {

async queryInstantiatedChaincodes(channelName) {
logger.info('queryInstantiatedChaincodes', channelName);
const network = await this.gateway.getNetwork(this.defaultChannelName);
const network = await this.gateway.getNetwork(channelName);
let contract = network.getContract('lscc');
let result = await contract.evaluateTransaction('GetChaincodes');
let resultJson = fabprotos.protos.ChaincodeQueryResponse.decode(result);
Expand Down
6 changes: 5 additions & 1 deletion app/platform/fabric/sync/SyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ export class SyncServices {
let chaincodeID;
let status;
let mspId = [];
let chaincodeversion: String;

this.convertFormatOfValue(
'value',
Expand Down Expand Up @@ -577,6 +578,9 @@ export class SyncServices {
chaincodeID = new Uint8Array(
txObj.payload.data.actions[0].payload.action.proposal_response_payload.extension
);
chaincodeversion =
txObj.payload.data.actions[0].payload.action.proposal_response_payload
.extension.chaincode_id.version;
status =
txObj.payload.data.actions[0].payload.action.proposal_response_payload
.extension.response.status;
Expand Down Expand Up @@ -689,7 +693,7 @@ export class SyncServices {

const res = await this.persistence
.getCrudService()
.saveTransaction(network_id, transaction_row);
.saveTransaction(network_id, transaction_row, chaincodeversion);
logger.debug('saveTransaction ', res);
}

Expand Down

0 comments on commit f685645

Please sign in to comment.