Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend- Improper updation of Txn Count and Chaincodes list #411

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/persistence/fabric/CRUDService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,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 @@ -330,8 +330,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