代码拉取完成,页面将自动刷新
/*
Copyright IBM Corp. 2018 All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package endorser
import (
"github.com/hyperledger/fabric/core/handlers/endorsement/api/state"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/transientstore"
"github.com/hyperledger/fabric/protos/ledger/rwset"
"github.com/pkg/errors"
)
//go:generate mockery -dir . -name QueryCreator -case underscore -output mocks/
// QueryCreator creates new QueryExecutors
type QueryCreator interface {
NewQueryExecutor() (ledger.QueryExecutor, error)
}
// ChannelState defines state operations
type ChannelState struct {
transientstore.Store
QueryCreator
}
// FetchState fetches state
func (cs *ChannelState) FetchState() (endorsement.State, error) {
qe, err := cs.NewQueryExecutor()
if err != nil {
return nil, err
}
return &StateContext{
QueryExecutor: qe,
Store: cs.Store,
}, nil
}
// StateContext defines an execution context that interacts with the state
type StateContext struct {
transientstore.Store
ledger.QueryExecutor
}
// GetTransientByTXID returns the private data associated with this transaction ID.
func (sc *StateContext) GetTransientByTXID(txID string) ([]*rwset.TxPvtReadWriteSet, error) {
scanner, err := sc.Store.GetTxPvtRWSetByTxid(txID, nil)
if err != nil {
return nil, errors.WithStack(err)
}
defer scanner.Close()
var data []*rwset.TxPvtReadWriteSet
for {
res, err := scanner.NextWithConfig()
if err != nil {
return nil, errors.WithStack(err)
}
if res == nil {
break
}
if res.PvtSimulationResultsWithConfig == nil {
continue
}
data = append(data, res.PvtSimulationResultsWithConfig.PvtRwset)
}
return data, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。