MCPcopy
hub / github.com/hyperledger/fabric / createHeader

Function createHeader

integration/pvtdata/pvtdata_test.go:1220–1244  ·  view source on GitHub ↗
(txType cb.HeaderType, channelID string, creator []byte)

Source from the content-addressed store, hash-verified

1218}
1219
1220func createHeader(txType cb.HeaderType, channelID string, creator []byte) (*cb.Header, error) {
1221 nonce, err := crypto.GetRandomNonce()
1222 if err != nil {
1223 return nil, err
1224 }
1225 chdr := &cb.ChannelHeader{
1226 Type: int32(txType),
1227 ChannelId: channelID,
1228 TxId: protoutil.ComputeTxID(nonce, creator),
1229 Epoch: 0,
1230 Timestamp: timestamppb.Now(),
1231 }
1232 chdrBytes := protoutil.MarshalOrPanic(chdr)
1233
1234 shdr := &cb.SignatureHeader{
1235 Creator: creator,
1236 Nonce: nonce,
1237 }
1238 shdrBytes := protoutil.MarshalOrPanic(shdr)
1239 header := &cb.Header{
1240 ChannelHeader: chdrBytes,
1241 SignatureHeader: shdrBytes,
1242 }
1243 return header, nil
1244}
1245
1246// verify collection names and pvtdataMap match expectedKVWritesMap
1247func assertPrivateDataAsExpected(pvtdataMap map[uint64]*rwset.TxPvtReadWriteSet, expectedKVWritesMap map[string]map[string][]byte) {

Callers 1

createDeliverEnvelopeFunction · 0.85

Calls 4

GetRandomNonceFunction · 0.92
ComputeTxIDFunction · 0.92
MarshalOrPanicFunction · 0.92
NowMethod · 0.65

Tested by

no test coverage detected