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

修复blockhash生成问题 #136

Closed
wants to merge 5 commits into from

Conversation

daring5920
Copy link

No description provided.

@daring5920 daring5920 closed this Jul 10, 2020
@daring5920 daring5920 reopened this Jul 10, 2020
this.key('PreviousHash').octstr(),
this.key('DataHash').octstr()
);
});
logger.info('generateBlockHash', header.number.toString());
const output = headerAsn.encode(
{
Number: header.number.toString(),
Number: parseInt(header.number),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on your patch, I did some changes in my local. With the following patch, current block hash of each block gets identical with the previous hash of the next block. Your thought?

diff --git a/app/platform/fabric/utils/FabricUtils.js b/app/platform/fabric/utils/FabricUtils.js
index 664e115..e7e7f94 100644
--- a/app/platform/fabric/utils/FabricUtils.js
+++ b/app/platform/fabric/utils/FabricUtils.js
@@ -134,7 +134,7 @@ async function generateDir() {
 async function generateBlockHash(header) {
        const headerAsn = asn.define('headerAsn', function() {
                this.seq().obj(
-                       this.key('Number').octstr(),
+                       this.key('Number').int(),
                        this.key('PreviousHash').octstr(),
                        this.key('DataHash').octstr()
                );
@@ -142,9 +142,9 @@ async function generateBlockHash(header) {
        logger.info('generateBlockHash', header.number.toString());
        const output = headerAsn.encode(
                {
-                       Number: header.number.toString(),
-                       PreviousHash: header.previous_hash.toString('hex'),
-                       DataHash: header.data_hash.toString('hex')
+                       Number: parseInt(header.number.low),
+                       PreviousHash: header.previous_hash,
+                       DataHash: header.data_hash
                },
                'der'
        );

{clientJson.version}
 
{'Fabric Compatibility: '} {Version.map(v => v)}
{'Deaking Compatibility: '} {Version.map(v => v)}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change included by mistake?

Copy link
Contributor

@nekia nekia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for giving us important pointing out. I left some comments. Please have a look. And could you correct the error in DCO check?

@nekia
Copy link
Contributor

nekia commented Jul 11, 2020

The following steps will be help for you to fix the error in DCO check.
https://github.com/hyperledger/blockchain-explorer/pull/136/checks?check_run_id=856621937

@sonarcloud
Copy link

sonarcloud bot commented Jul 13, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants