-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
[FAB-18508] ledger utility always outputs txNum #2724
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shimos for your contribution. Left you a comment.
@@ -498,13 +484,11 @@ func TestJSONArrayFileWriter(t *testing.T) { | |||
"value" : "green", | |||
"blockNum" : 472, | |||
"txNum" : 61 | |||
}, | |||
"snapshotrecord2" : {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an intentional entry that was chosen to represent a missing record. Unless there is a strong reason, I would prefer to keep it as is.
df24901
to
97d4df5
Compare
@manish-sethi Thank you for the review. I have revised the patch to keep the JSON structure. |
internal/ledger/compare.go
Outdated
Record1 *snapshotRecord `json:"snapshotrecord1,omitempty"` | ||
Record2 *snapshotRecord `json:"snapshotrecord2,omitempty"` | ||
Namespace string `json:"namespace,omitempty"` | ||
Key string `json:"key,omitempty"` | ||
Record1 interface{} `json:"snapshotrecord1,omitempty"` | ||
Record2 interface{} `json:"snapshotrecord2,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was better to use the concrete type, as before. On a second thought, as an alternate we could remove "omitempty" in the json annotation for Record1
and Record2
. That will force to print a nil object as null
in the final JSON -- which I feel would be even clearer than {}
.
Sorry for an additional round of change on this.
57defb8
to
b12bac5
Compare
This patch fixes a bug reported in FAB-18508, and makes the ledger troubleshooting utility output always the record "txNum". The bug occurred when the target transaction is the first transaction of a block (i.e. txNum == 0). This patch removes the `omitempty` attributes from all the members of a record. Note that this patch also changes the output when a key is missing in either snapshot. For a missing snapshot, 'null' will be output instead of an empty object ({}). Signed-off-by: Taku Shimosawa <taku.shimosawa.uf@hitachi.com>
@manish-sethi ok, so I have reverted to the first patch, and deleted 'omitempty' from |
Thanks @shimos for your contribution! |
Type of change
Description
This patch fixes a bug reported in FAB-18508, and makes the ledger troubleshooting utility output always the record "txNum".
Additional details
The bug occurred when the target transaction is the first transaction of a block (txNum == 0). This patch removes the
omitempty
attributes from all the members of a record.Note that this patch also changes the output when a key is missing in either snapshot. Instead of an empty object ({}) for the missing snapshot, the entire key (either "snapshotrecord1" or "snapshotrecord2") will be omitted.
(Refer to the changes in the test code)
Related issues
https://jira.hyperledger.org/projects/FAB/issues/FAB-18508