mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-18 07:55:10 +00:00
- switch to ClientConnInterface - use command type alias for map of commands - add error return to command functions and handle in app.go - inline formatJSON function in getAllAssets.go - replace most panics with error returns - remove error wrapping in listen.go and further down the line - use strconv.ParseUint instead of ParseFloat - use WithCancelCause in transact.go to grab and propagate error from go routine - unmarshal and return []Asset in atb.GetAllAssets - switch to rand package - remove dependency to protobuf reflect package - switch to sync.OnceValues for caching parser - fixed typo in events sample connect.go Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
40 lines
858 B
Go
40 lines
858 B
Go
package parser
|
|
|
|
import (
|
|
"github.com/hyperledger/fabric-protos-go-apiv2/common"
|
|
)
|
|
|
|
type Transaction struct {
|
|
payload *payload
|
|
}
|
|
|
|
func newTransaction(payload *payload) *Transaction {
|
|
return &Transaction{payload}
|
|
}
|
|
|
|
func (t *Transaction) ChannelHeader() (*common.ChannelHeader, error) {
|
|
return t.payload.channelHeader()
|
|
}
|
|
|
|
func (t *Transaction) NamespaceReadWriteSets() ([]*NamespaceReadWriteSet, error) {
|
|
endorserTransaction, err := t.payload.endorserTransaction()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
txReadWriteSets, err := endorserTransaction.readWriteSets()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
result := []*NamespaceReadWriteSet{}
|
|
for _, readWriteSet := range txReadWriteSets {
|
|
result = append(result, readWriteSet.namespaceReadWriteSets()...)
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
func (t *Transaction) IsValid() bool {
|
|
return t.payload.isValid()
|
|
}
|