Skip to content

Commit

Permalink
add docs for new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
inotnako committed May 13, 2020
1 parent c279a03 commit 83baaac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/chaincode/tw_waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"github.com/s7techlab/hlf-sdk-go/api"
)

// TxWaitBuilder function signature for plugable setter on Do options
type TxWaitBuilder func(cfg *api.DoOptions) (api.TxWaiter, error)

// WithTxWaiter - add option for set custom tx waiter
func WithTxWaiter(builder TxWaitBuilder) api.DoOption {
return func(cfg *api.DoOptions) (err error) {
cfg.TxWaiter, err = builder(cfg)
Expand Down
3 changes: 3 additions & 0 deletions client/chaincode/txwaiter/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/s7techlab/hlf-sdk-go/util"
)

// All - need use on invoke flow for check transaction codes for each organizations from endorsement policy
// txwaiter.All will be made to subscribe tx for each of the peer organizations from the endorsement policy
func All(cfg *api.DoOptions) (api.TxWaiter, error) {
mspIds, err := util.GetMSPFromPolicy(cfg.DiscoveryChaincode.Policy)
if err != nil {
Expand Down Expand Up @@ -48,6 +50,7 @@ func (w *allMspWaiter) setErr() {
w.onceSet.Do(func() { w.hasErr = true })
}

// Wait - implementation of api.TxWaiter interface
func (w *allMspWaiter) Wait(ctx context.Context, channel string, txid api.ChaincodeTx) error {
var (
wg = new(sync.WaitGroup)
Expand Down
3 changes: 3 additions & 0 deletions client/chaincode/txwaiter/self.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/s7techlab/hlf-sdk-go/api"
)

// Self - default tx waiter and used on invoke flow
// txwaiter.Self make subscribe tx on one peer endorser organization
func Self(cfg *api.DoOptions) (api.TxWaiter, error) {
return &selfPeerWaiter{
pool: cfg.Pool,
Expand All @@ -21,6 +23,7 @@ type selfPeerWaiter struct {
identity msp.SigningIdentity
}

// Wait - implementation of api.TxWaiter interface
func (w *selfPeerWaiter) Wait(ctx context.Context, channel string, txid api.ChaincodeTx) error {
mspID := w.identity.GetMSPIdentifier()
deliver, err := w.pool.DeliverClient(mspID, w.identity)
Expand Down

0 comments on commit 83baaac

Please sign in to comment.