Skip to content

Commit

Permalink
Merge branch 'hyperledger-labs:main' into BE375-AddValidations
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchanaArige committed Apr 18, 2023
2 parents 735b314 + 4b46082 commit b4a8fda
Show file tree
Hide file tree
Showing 19 changed files with 251 additions and 89 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Expand Up @@ -25,8 +25,7 @@ RUN apk add --no-cache --virtual npm-deps python3 make g++ curl bash && \
rm -r /root/.cache

# install node-prune (https://github.com/tj/node-prune)
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin

RUN curl -sf https://gobinaries.com/tj/node-prune | sh
# install NPM dependencies
RUN npm install && npm run build && npm prune --production

Expand Down
14 changes: 14 additions & 0 deletions MAINTAINERS.md
Expand Up @@ -4,6 +4,20 @@
Maintainers
===========

You can find out who's contributed recently just by looking at GitHub's [contributors list](https://github.com/hyperledger-labs/blockchain-explorer/graphs/contributors). But there are a few more things you ought to know about who maintains this code, and how they do it:

Make sure you read our contributor guidelines so you understand how we work and how to collaborate effectively. This includes instructions about pull request and code review protocols, and it explains what we mean by calling someone a "maintainer" in this file.

Be aware that individual folders in the project may have more specific maintainers; if you see another MAINTAINERS.md in a subfolder, that governs the tree below it.

A lot of interactions with maintainers take place on Discord. You'll need [Linux Foundation credentials](https://identity.linuxfoundation.org/) to comment there; creating them is self-service. The project name you want, once in Discord, is "[blockchain-explorer](https://discord.com/channels/905194001349627914/1039606111654920255)". Most of the team hangs out there during their work day; look for #Blockchain-explorer.

**Who To Contact**
For ordinary questions, we suggest you contact [active contributors](https://github.com/hyperledger-labs/blockchain-explorer/graphs/contributors) generically, on Discord [#blockchain-explorer](https://discord.com/channels/905194001349627914/1039606111654920255). If that doesn't get someone's attention, feel free to contact the contributors individually.

Maintainers are busy and delegate many decisions to other trusted contributors. However, it is appropriate to contact them if you have a complex design decision or a controversial PR.


**Active Maintainers**

| Name | GitHub |
Expand Down
34 changes: 27 additions & 7 deletions app/persistence/fabric/CRUDService.ts
Expand Up @@ -82,31 +82,51 @@ export class CRUDService {
* @param {*} txid
* @param {*} from
* @param {*} to
* @param {*} page
* @param {*} size
* @param {*} orgs
* @returns
* @memberof CRUDService
*/
getTxList(
async getTxList(
network_name: any,
channel_genesis_hash: any,
blockNum: any,
txid: any,
from: any,
to: any,
orgs: string
orgs: string,
page: number,
size: number
) {
var countOfTxns: number;
let sqlTxList = ` select t.creator_msp_id,t.txhash,t.type,t.chaincodename,t.createdt,channel.name as channelName from transactions as t
inner join channel on t.channel_genesis_hash=channel.channel_genesis_hash and t.network_name = channel.network_name where t.blockid >= $1 and t.id >= $2 and
t.channel_genesis_hash = $3 and t.network_name = $4 and t.createdt between $5 and $6 `;
const values = [blockNum, txid, channel_genesis_hash, network_name, from, to];

const values = [blockNum, txid, channel_genesis_hash, network_name, from, to, page, size];
if (page == 1) {
let sqlTxCount: string;
const filterValues = [blockNum, txid, channel_genesis_hash, network_name, from, to];
sqlTxCount = ` select count(*) from transactions as t inner join channel on t.channel_genesis_hash=channel.channel_genesis_hash and t.network_name = channel.network_name
where t.blockid >= $1 and t.id >= $2 and t.channel_genesis_hash = $3 and t.network_name = $4 and t.createdt between $5 and $6 `
if (orgs && orgs.length > 0) {
sqlTxCount += ' and t.creator_msp_id = ANY($7)';
filterValues.push(orgs);
}
countOfTxns = await this.sql.getRowsCountBySQlQuery(sqlTxCount, filterValues)
}
if (orgs && orgs.length > 0) {
sqlTxList += ' and t.creator_msp_id = ANY($7)';
sqlTxList += ' and t.creator_msp_id = ANY($9)';
values.push(orgs);
}
sqlTxList += ' order by t.createdt desc';
sqlTxList += ' order by t.createdt desc LIMIT $8 OFFSET (($7 - 1) * $8)';
let txnsData = await this.sql.getRowsBySQlQuery(sqlTxList, values);
let response = {
txnsData: txnsData,
noOfpages: Math.ceil(countOfTxns / size)
}

return this.sql.getRowsBySQlQuery(sqlTxList, values);
return response;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/persistence/fabric/MetricService.ts
Expand Up @@ -27,7 +27,7 @@ export class MetricService {
*/
getChaincodeCount(network_name: any, channel_genesis_hash: any) {
return this.sql.getRowsBySQlCase(
'select count(1) c from chaincodes where channel_genesis_hash=$1 and network_name=$2 ',
'select count(DISTINCT name) c from chaincodes where channel_genesis_hash=$1 and network_name=$2 ',
[channel_genesis_hash, network_name]
);
}
Expand Down
24 changes: 24 additions & 0 deletions app/persistence/postgreSQL/PgService.ts
Expand Up @@ -562,4 +562,28 @@ export class PgService {
});
});
}

/**
*
*
* @param {*} sql
* @param {*} values
* @returns
* @memberof PgService
*/
getRowsCountBySQlQuery(sql, values): Promise<number> {
return new Promise((resolve, reject) => {
this.client.query(sql, values, (err, res) => {
if (err) {
reject(err);
return;
}
logger.debug(`the getRowsCountBySQlQuery ${res}`);
if (res) {
resolve(res.rows[0].count);
}
});
});
}

}
16 changes: 11 additions & 5 deletions app/platform/fabric/sync/SyncService.ts
Expand Up @@ -553,15 +553,19 @@ export class SyncServices {
}
let envelope_signature = txObj.signature;
if (envelope_signature !== undefined) {
envelope_signature = Buffer.from(envelope_signature).toString('hex');
envelope_signature = Buffer.from(
JSON.stringify(envelope_signature)
).toString('hex');
}
let payload_extension = txObj.payload.header.channel_header.extension;
if (payload_extension !== undefined) {
payload_extension = Buffer.from(payload_extension).toString('hex');
payload_extension = Buffer.from(JSON.stringify(payload_extension)).toString(
'hex'
);
}
let creator_nonce = txObj.payload.header.signature_header.nonce;
if (creator_nonce !== undefined) {
creator_nonce = Buffer.from(creator_nonce).toString('hex');
creator_nonce = Buffer.from(JSON.stringify(creator_nonce)).toString('hex');
}
/* eslint-disable */
const creator_id_bytes =
Expand Down Expand Up @@ -598,14 +602,16 @@ export class SyncServices {
for (const input of chaincode_proposal_input) {
inputs =
(inputs === '' ? inputs : `${inputs},`) +
Buffer.from(input).toString('hex');
Buffer.from(JSON.stringify(input)).toString('hex');
}
chaincode_proposal_input = inputs;
}
endorser_signature =
txObj.payload.data.actions[0].payload.action.endorsements[0].signature;
if (endorser_signature !== undefined) {
endorser_signature = Buffer.from(endorser_signature).toString('hex');
endorser_signature = Buffer.from(
JSON.stringify(endorser_signature)
).toString('hex');
}
payload_proposal_hash = txObj.payload.data.actions[0].payload.action.proposal_response_payload.proposal_hash.toString(
'hex'
Expand Down
19 changes: 14 additions & 5 deletions app/rest/dbroutes.ts
Expand Up @@ -124,9 +124,9 @@ export function dbroutes(router: Router, platform: Platform) {
* GET /txList/
* curl -i 'http://<host>:<port>/txList/<channel_genesis_hash>/<blocknum>/<txid>/<limitrows>/<offset>'
* Response:
* {'rows':[{'id':56,'channelname':'mychannel','blockid':24,
* {'rows':{"txnsData": [{'id':56,'channelname':'mychannel','blockid':24,
* 'txhash':'c42c4346f44259628e70d52c672d6717d36971a383f18f83b118aaff7f4349b8',
* 'createdt':'2018-03-09T19:40:59.000Z','chaincodename':'mycc'}]}
* 'createdt':'2018-03-09T19:40:59.000Z','chaincodename':'mycc'}], "noOfpages": 1}
*/
router.get(
'/txList/:channel_genesis_hash/:blocknum/:txid',
Expand All @@ -139,22 +139,31 @@ export function dbroutes(router: Router, platform: Platform) {
req.query.from as string,
req.query.to as string
);
const { page, size } = req.query;
if (isNaN(txid)) {
txid = 0;
}
if (channel_genesis_hash) {
const extReq = (req as unknown) as ExtRequest;
dbCrudService
let data = await dbCrudService
.getTxList(
extReq.network,
channel_genesis_hash,
blockNum,
txid,
from,
to,
orgs
orgs,
page,
size
)
.then(handleResult(req, res));
if (data) {
return res.send({
status: 200,
rows: data
});
}
return requtil.notFound(req, res);
} else {
return requtil.invalidRequest(req, res);
}
Expand Down
4 changes: 2 additions & 2 deletions client/package.json
Expand Up @@ -26,11 +26,11 @@
"nock": "^9.3.3",
"pg": "^7.4.1",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react": "^16.14.0",
"react-copy-to-clipboard": "^5.0.1",
"react-d3-graph": "^1.0.1",
"react-datepicker": "^1.6.0",
"react-dom": "^16.2.0",
"react-dom": "^16.14.0",
"react-event-timeline": "^1.5.4",
"react-fontawesome": "^1.6.1",
"react-js-pagination": "^3.0.1",
Expand Down
15 changes: 11 additions & 4 deletions client/src/components/Header/HeaderView.js
Expand Up @@ -74,11 +74,12 @@ const {
chaincodeList,
channels,
peerList,
transactionList
transactionList,
transactionListSearch
} = tableOperations;

const { currentChannelSelector } = chartSelectors;
const { channelsSelector } = tableSelectors;
const { channelsSelector, transactionListSearchPageParamSelector, transactionListSearchQuerySelector } = tableSelectors;
/* istanbul ignore next */
const styles = theme => {
const { type } = theme.palette;
Expand Down Expand Up @@ -458,6 +459,9 @@ export class HeaderView extends Component {
getPeerStatus,
getTransactionByOrg,
getTransactionList,
getTransactionListSearch,
transactionListSearchPageParam,
transactionListSearchQuery,
getTransactionPerHour,
getTransactionPerMin,
getBlockActivity
Expand All @@ -474,7 +478,7 @@ export class HeaderView extends Component {
getPeerList(currentChannel),
getPeerStatus(currentChannel),
getTransactionByOrg(currentChannel),
getTransactionList(currentChannel),
getTransactionListSearch(currentChannel,transactionListSearchQuery,transactionListSearchPageParam),
getTransactionPerHour(currentChannel),
getTransactionPerMin(currentChannel)
]);
Expand Down Expand Up @@ -687,7 +691,9 @@ const mapStateToProps = state => {
return {
currentChannel: currentChannelSelector(state),
channels: channelsSelector(state),
mode: modeSelector(state)
mode: modeSelector(state),
transactionListSearchPageParam: transactionListSearchPageParamSelector(state),
transactionListSearchQuery: transactionListSearchQuerySelector(state),
};
};

Expand All @@ -704,6 +710,7 @@ const mapDispatchToProps = {
getBlockActivity: blockActivity,
getTransactionByOrg: transactionByOrg,
getTransactionList: transactionList,
getTransactionListSearch:transactionListSearch,
getTransactionPerHour: transactionPerHour,
getTransactionPerMin: transactionPerMin,
logout: authOperations.logout
Expand Down

0 comments on commit b4a8fda

Please sign in to comment.