Skip to content

Commit 1b76b2b

Browse files
Expose TargetEndpoints for per-peer execution (#37)
1 parent 4a39f82 commit 1b76b2b

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

internal/rpc/shiroclient.go

+4
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ func (c *rpcShiroClient) Call(ctx context.Context, method string, configs ...typ
528528
req["params"].(map[string]interface{})["creator_msp_id"] = opt.Creator
529529
}
530530

531+
if len(opt.TargetEndpoints) > 0 {
532+
req["params"].(map[string]interface{})["target_endpoints"] = opt.TargetEndpoints
533+
}
534+
531535
res, err := c.reqres(ctx, req, opt)
532536
if err != nil {
533537
return nil, err

internal/types/types.go

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ type RequestOptions struct {
109109
Target *interface{}
110110
TimestampGenerator func(context.Context) string
111111
MspFilter []string
112+
TargetEndpoints []string
112113
MinEndorsers int
113114
Creator string
114115
DependentTxID string

shiroclient/configs.go

+8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ func WithMSPFilter(mspFilter []string) Config {
123123
})
124124
}
125125

126+
// WithTargetEndpoints allows specifying which exact peers will be used
127+
// to process the transaction. Specifcy a name or URL of the peer.
128+
func WithTargetEndpoints(nameOrURL []string) Config {
129+
return types.Opt(func(r *types.RequestOptions) {
130+
r.TargetEndpoints = append([]string(nil), nameOrURL...)
131+
})
132+
}
133+
126134
// WithMinEndorsers allows specifying the minimum number of endorsing
127135
// peers. Has no effect in mock mode.
128136
func WithMinEndorsers(minEndorsers int) Config {

0 commit comments

Comments
 (0)