fabric v1.0 区块数据结构:
详细结构
Fabric 打开blockfile
-
1.docker exec -it peer节点名 bash , 比如:sudo docker exec -it peer0.org3.wisedu.com bash
-
2.cd /var/hyperledger/production/ledgersData/chains/chains/mychannel
-
3.注:里面的文件比如blockfile_000000可以删除: rm blockfile_000000
-
4.将blockfile拷贝出来:
#exit
#sudo docker cp 31bf8b2e6374:/var/hyperledger/production/ledgersData/chains/chains/mychannel/blockfile_000000 /home/shirly/projects
其中,b81a1d1d8064是对应peer0.org3.wisedu.com的容器ID,可根据root@31bf8b2e6374:获得
那么是不是可以先把blockfile文件拷贝出来进行修改,将/var/hyperledger/production/ledgersData/chains/chains/mychannel目录下的blockfile删除,将修改过后的拷进去达到修改区块的目的
区块结构(JSON)
{
header: {
number: '37',
previous_hash:'b57d891702819c0e62dd7d405743b0663d19e49365d43c6420f281b43492e78d',
data_hash:'c730c7f832a24f9906e5224205182a66f25ef92b766c02aba60e23293883361f'
},
data: {
data: [{
signature:<Buffer 30 45 02 21 00 90 e3 37 85 e3 16 05 4f 34 79 cc d3 b6 75 42 1e 08 b8 34 c9 62 cd ae bb 66 b8 45 e0 9c c2 c9 41 02 20 6d 34 cb 6a 2f 04 cb 6f 2a e9 cb ... >,
payload: {
header: {
channel_header: {
type: 3,
version: 1,
timestamp: '2019-12-27T02: 30: 35.321Z',
channel_id: 'mychannel',
tx_id:'cbd9e30878c5a9c6887d67596e6cd0a2cb30c253ef32e7dceb4440b4d0ec3b9d',
epoch: '0',
extension: <Buffer 12 06 12 04 6d 79 63 63>,
typeString: 'ENDORSER_TRANSACTION'
},
signature_header: {
creator: {
Mspid: 'Org1MSP',
IdBytes:'-----BEGIN CERTIFICATE-----\nMIICKTCCAdCgAwIBAgIQWv/vCt79Gp31mVsZBLDTBzAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS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QQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMQ8wDQYDVQQLEwZjbGllbnQxHzAdBgNVBAMMFkFkbWluQG9y\nZzEuZXhhbXBsZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATFYP5wn0Nr\n9NXpCXbqDiNa53r9RXcO0qcIgZhj9apQIn1ZOqdj4E7UQ/Yv9J8nOJMfFCwfU6VU\nNJ0B5DI7R/jro00wSzAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADArBgNV\nHSMEJDAigCAfNb1MjsB1bCjo4uzb2roawarG0SSzApS1Qp8u50YO5DAKBggqhkjO\nPQQDAgNHADBEAiBofjUeoqz1oTNc5yeE7R7/5incME4/aQJX8U7Ym8oHMgIgdor2\n40bkUNJmhFdeB2kXoLHGrD9F+bRzN+6zoerkApg=\n-----END CERTIFICATE-----\n'
},
nonce:<Buffer d5 8e 36 01 34 a9 21 61 fb c2 90 5d 85 fd 55 4d 09 4e 49 d0 0b cb 18 74>
},
payload: {
chaincode_proposal_payload: {
input: {
chaincode_spec: {
type: 1,
typeString: 'GOLANG',
input: {
args: [
<Buffer 69 6e 73 65 72 74>,
<Buffer 7b 22 62 69 7a 54 79 70 65 22 3a 22 48 59 22 2c 22 62 69 7a 55 55 49 44 22 3a 22 36 33 39 39 65 32 35 66 2d 32 61 64 31 2d 34 66 37 63 2d 38 30 63 63 ... >
],
decorations: {}
},
chaincode_id: {
path: '',
name: 'mycc',
version: ''
},
timeout: 0
}
}
},
action: {
proposal_response_payload: {
proposal_hash:'50180bdb986b6b4488a54528e9f002221109ea1f6bb87847783cf4bdabeb2037',
extension: {
results:{
data_model: 0,
ns_rwset: [{
namespace: 'lscc',
rwset: {
reads: [{
key: 'mycc',
version: {
block_num: '1',
tx_num: '0'
}
}],
range_queries_info: [],
writes: [],
metadata_writes: []
},
collection_hashed_rwset: []
},
{
namespace: 'mycc',
rwset: {
reads: [],
range_queries_info: [],
writes: [{
key: '8543b514-1fa8-49f6-a610-cd44d4d5a318',
is_delete: false,
value:'{
"bizType": "HY",
"bizUUID": "6399e25f-2ad1-4f7c-80cc-6ba720f312b9",
"count": 5,
"fillPerson": "许褚",
"requestID": "89c06e39-403b-430d-9bac-caab738c1aeb",
"requestTime": "2019-12-27 10:30:24",
"reviewOpinion": "从许攸,袭乌巢",
"reviewPass": "通过",
"reviewer": "曹操",
"submissionTim": "提交审核时间",
"toGzwTime": "上报时间",
"blockTimeTamp": "2019-12-27 10:30:35:320",
"tx_id": "cbd9e30878c5a9c6887d67596e6cd0a2cb30c253ef32e7dceb4440b4d0ec3b9d"
}'
}],
metadata_writes: []
},
collection_hashed_rwset: []
}]
},
events: {
chaincode_id: '',
tx_id: '',
event_name: '',
payload: <Buffer >
},
response: {
status: 200,
message: 'insert finished successfully',
payload:'8543b514-1fa8-49f6-a610-cd44d4d5a318: {
"bizType": "HY",
"bizUUID": "6399e25f-2ad1-4f7c-80cc-6ba720f312b9",
"count": 5,
"fillPerson": "许褚",
"requestID": "89c06e39-403b-430d-9bac-caab738c1aeb",
"requestTime": "2019-12-27 10:30:24",
"reviewOpinion": "从许攸,袭乌巢",
"reviewPass": "通过",
"reviewer": "曹操",
"submissionTim": "提交审核时间",
"toGzwTime": "上报时间",
"blockTimeTamp": "2019-12-27 10:30:35:320",
"tx_id": "cbd9e30878c5a9c6887d67596e6cd0a2cb30c253ef32e7dceb4440b4d0ec3b9d"
}'
},
chaincode_id: {
path: '',
name: 'mycc',
version: '1.0'
}
}
},
endorsements: [{
endorser: {
Mspid: 'Org1MSP',
IdBytes:'-----BEGIN CERTIFICATE-----\nMIICKTCCAc+gAwIBAgIRALSEbL20/qyKuufJLYD1EH0wCgYIKoZIzj0EAwIwczEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMTkxMjI3MDExODAwWhcNMjkxMjI0MDExODAw\nWjBqMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN\nU2FuIEZyYW5jaXNjbzENMAsGA1UECxMEcGVlcjEfMB0GA1UEAxMWcGVlcjAub3Jn\nMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABArT+vAEGJ/5\nOS0ntKWOJS9krod8flniyops3SqN3vFhGfRzmDq5dxARMnCTjT16g9I4Jo4QyFAo\nUAfXu1Zv93qjTTBLMA4GA1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1Ud\nIwQkMCKAIB81vUyOwHVsKOji7NvauhrBqsbRJLMClLVCny7nRg7kMAoGCCqGSM49\nBAMCA0gAMEUCIQDWlXWhXOkwlANMLmkAB8REFYyqmKQz9UKe3z3VmjOQ+AIgWPq/\nDZgErjIfq7KT5XWVCfvsxbJRWjD3o3aw0TE291A=\n-----END CERTIFICATE-----\n'
},
signature:<Buffer 30 45 02 21 00 a8 80 cc 94 22 54 68 bc 10 e3 c1 87 45 d7 33 5a da c6 88 a4 49 a7 71 57 7a 71 1c 87 b6 1f 93 1b 02 20 6a 21 3f db 23 6a 36 c4 a4 b5 93 ... >
}]
}
}
}]
}
}
}]
},
metadata: {
metadata: [
{
value: '\n\u0000',
signatures: [{
signature_header: {
creator: {
Mspid: 'OrdererMSP',
IdBytes:'-----BEGIN CERTIFICATE-----\nMIICCzCCAbKgAwIBAgIQU4Xlp67Edi3tdBugbUNo9TAKBggqhkjOPQQDAjBpMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEUMBIGA1UEChMLZXhhbXBsZS5jb20xFzAVBgNVBAMTDmNhLmV4YW1w\nbGUuY29tMB4XDTE5MTIyNzAxMTgwMFoXDTI5MTIyNDAxMTgwMFowWDELMAkGA1UE\nBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz\nY28xHDAaBgNVBAMTE29yZGVyZXIuZXhhbXBsZS5jb20wWTATBgcqhkjOPQIBBggq\nhkjOPQMBBwNCAATdnI0rfvsU27XRhbPEp81yTiBpjiP4kLTHtAuXPc58RHHM2zYX\n4oBC+UeOsreh2pibd/J1qJ0gnSlxL8ZmtdKTo00wSzAOBgNVHQ8BAf8EBAMCB4Aw\nDAYDVR0TAQH/BAIwADArBgNVHSMEJDAigCBcNzwBMeyKcdPqnBdYhDyqMKUAYA6W\nUcitApPVWMMjEzAKBggqhkjOPQQDAgNHADBEAiBQegfrUuFYAHqDla+DJlSMHqiW\nQoI8q1Dv8t39c72tOQIgDpg9AbEPgz7s+8HUW+ahlZcYnRsRg1HM3WtElcMRlVM=\n-----END CERTIFICATE-----\n'
},
nonce:<Buffer c6 2b cd eb f6 98 a1 e7 36 94 d6 01 3c 8f e1 54 3b e4 e8 54 67 5d f9 77>
},
signature:<Buffer 30 45 02 21 00 9b e9 af 68 06 b8 88 d4 0a df 64 91 dc 6d 9f f7 57 0d 37 c0 28 7e d6 5d 1a 0e aa 57 ad 99 4e e4 02 20 63 44 04 f9 8e 83 f3 44 95 1f a3 ... >
}]
},
{
value: {
index: '0'
},
signatures: []
},
[0]
]
}
}
来源:oschina
链接:https://my.oschina.net/u/4409444/blog/3235123