diff --git a/platform/fabric/core/generic/transaction/manager.go b/platform/fabric/core/generic/transaction/manager.go index a962572c7..24bc55252 100644 --- a/platform/fabric/core/generic/transaction/manager.go +++ b/platform/fabric/core/generic/transaction/manager.go @@ -17,7 +17,7 @@ import ( ) type Factory interface { - NewTransaction(channel string, nonce []byte, creator []byte, txid string) (driver.Transaction, error) + NewTransaction(channel string, nonce []byte, creator []byte, txid string, rawRequest []byte) (driver.Transaction, error) } type Manager struct { @@ -44,12 +44,12 @@ func (m *Manager) NewProposalResponseFromBytes(raw []byte) (driver.ProposalRespo return NewProposalResponseFromBytes(raw) } -func (m *Manager) NewTransaction(transactionType driver.TransactionType, creator view2.Identity, nonce []byte, txid string, channel string) (driver.Transaction, error) { +func (m *Manager) NewTransaction(transactionType driver.TransactionType, creator view2.Identity, nonce []byte, txid string, channel string, rawRequest []byte) (driver.Transaction, error) { factory, ok := m.factories[transactionType] if !ok { return nil, errors.Errorf("transaction tyep [%d] not recognized", transactionType) } - tx, err := factory.NewTransaction(channel, nonce, creator, txid) + tx, err := factory.NewTransaction(channel, nonce, creator, txid, rawRequest) if err != nil { return nil, err } @@ -66,7 +66,7 @@ func (m *Manager) NewTransactionFromBytes(channel string, raw []byte) (driver.Tr if !ok { return nil, errors.Errorf("transaction tyep [%d] not recognized", txRaw.Type) } - tx, err := factory.NewTransaction(channel, nil, nil, "") + tx, err := factory.NewTransaction(channel, nil, nil, "", nil) if err != nil { return nil, err } @@ -86,7 +86,7 @@ func (m *Manager) NewTransactionFromEnvelopeBytes(channel string, raw []byte) (d if !ok { return nil, errors.Errorf("transaction tyep [%d] not recognized", cht) } - tx, err := factory.NewTransaction(channel, nil, nil, "") + tx, err := factory.NewTransaction(channel, nil, nil, "", nil) if err != nil { return nil, err } @@ -110,7 +110,7 @@ func NewEndorserTransactionFactory(sp view.ServiceProvider, fns driver.FabricNet return &EndorserTransactionFactory{sp: sp, fns: fns} } -func (e *EndorserTransactionFactory) NewTransaction(channel string, nonce []byte, creator []byte, txid string) (driver.Transaction, error) { +func (e *EndorserTransactionFactory) NewTransaction(channel string, nonce []byte, creator []byte, txid string, rawRequest []byte) (driver.Transaction, error) { ch, err := e.fns.Channel(channel) if err != nil { return nil, err diff --git a/platform/fabric/driver/transaction.go b/platform/fabric/driver/transaction.go index 6ed582ccb..e2ff69c27 100644 --- a/platform/fabric/driver/transaction.go +++ b/platform/fabric/driver/transaction.go @@ -66,7 +66,7 @@ type TransactionManager interface { ComputeTxID(id *TxID) string NewEnvelope() Envelope NewProposalResponseFromBytes(raw []byte) (ProposalResponse, error) - NewTransaction(transactionType TransactionType, creator view.Identity, nonce []byte, txid string, channel string) (Transaction, error) + NewTransaction(transactionType TransactionType, creator view.Identity, nonce []byte, txid string, channel string, rawRequest []byte) (Transaction, error) NewTransactionFromBytes(channel string, raw []byte) (Transaction, error) NewTransactionFromEnvelopeBytes(channel string, raw []byte) (Transaction, error) } diff --git a/platform/fabric/services/endorser/builder.go b/platform/fabric/services/endorser/builder.go index e71b5f1f3..f32056f57 100644 --- a/platform/fabric/services/endorser/builder.go +++ b/platform/fabric/services/endorser/builder.go @@ -49,6 +49,7 @@ func (t *Builder) NewTransaction(opts ...fabric.TransactionOption) (*Transaction fabricOptions.Nonce, nil, false, + fabricOptions.RawRequest, &fabricOptions.TransactionType, ) } @@ -83,10 +84,10 @@ func (t *Builder) NewTransactionWithIdentity(id view.Identity) (*Transaction, er } func (t *Builder) newTransaction(creator []byte, network, channel string, nonce, raw []byte, envelope bool) (*Transaction, error) { - return t.newTransactionWithType(creator, network, channel, nonce, raw, envelope, nil) + return t.newTransactionWithType(creator, network, channel, nonce, raw, envelope, nil, nil) } -func (t *Builder) newTransactionWithType(creator []byte, network, channel string, nonce, raw []byte, envelope bool, tType *fabric.TransactionType) (*Transaction, error) { +func (t *Builder) newTransactionWithType(creator []byte, network, channel string, nonce, raw []byte, envelope bool, rawRequest []byte, tType *fabric.TransactionType) (*Transaction, error) { logger.Debugf("NewTransaction [%s,%s,%s]", view.Identity(creator).UniqueID(), channel, hash.Hashable(raw).String()) defer logger.Debugf("NewTransaction...done.") @@ -106,6 +107,9 @@ func (t *Builder) newTransactionWithType(creator []byte, network, channel string if tType != nil { options = append(options, fabric.WithTransactionType(*tType)) } + if rawRequest != nil { + options = append(options, fabric.WithRawRequest(rawRequest)) + } var fabricTransaction *fabric.Transaction var err error diff --git a/platform/fabric/transaction.go b/platform/fabric/transaction.go index bc8b4a8d5..2a0dbab13 100644 --- a/platform/fabric/transaction.go +++ b/platform/fabric/transaction.go @@ -25,6 +25,7 @@ type TransactionOptions struct { Nonce []byte TxID string Channel string + RawRequest []byte TransactionType TransactionType } @@ -70,6 +71,13 @@ func WithTxID(txid string) TransactionOption { } } +func WithRawRequest(rawRequest []byte) TransactionOption { + return func(o *TransactionOptions) error { + o.RawRequest = rawRequest + return nil + } +} + func WithTransactionType(tt TransactionType) TransactionOption { return func(o *TransactionOptions) error { o.TransactionType = tt @@ -369,13 +377,7 @@ func (t *TransactionManager) NewTransaction(opts ...TransactionOption) (*Transac return nil, err } - tx, err := t.fns.fns.TransactionManager().NewTransaction( - driver.TransactionType(options.TransactionType), - options.Creator, - options.Nonce, - options.TxID, - ch.Name(), - ) + tx, err := t.fns.fns.TransactionManager().NewTransaction(driver.TransactionType(options.TransactionType), options.Creator, options.Nonce, options.TxID, ch.Name(), options.RawRequest) if err != nil { return nil, err }