Skip to content

Commit

Permalink
[FAB-4207] Add chaincode proposal to Decorator
Browse files Browse the repository at this point in the history
This commit adds the chaincode proposal to the decorator

Change-Id: Ia4ff22c33b2c579db00daaf9a88777d3e7e5a4f3
Signed-off-by: yacovm <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Aug 13, 2017
1 parent 741c67c commit a73da04
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/endorser/endorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (e *Endorser) callChaincode(ctxt context.Context, chainID string, version s
// decorate the chaincode input
decorator := library.InitRegistry(library.Config{}).Lookup(library.DecoratorKey).(decoration.Decorator)
cis.ChaincodeSpec.Input.Decorations = make(map[string][]byte)
cis.ChaincodeSpec.Input = decorator.Decorate(cis.ChaincodeSpec.Input)
cis.ChaincodeSpec.Input = decorator.Decorate(prop, cis.ChaincodeSpec.Input)
cccid.ProposalDecorations = cis.ChaincodeSpec.Input.Decorations

res, ccevent, err = chaincode.ExecuteChaincode(ctxt, cccid, cis.ChaincodeSpec.Input.Args)
Expand Down
4 changes: 2 additions & 2 deletions core/handlers/decoration/decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "github.com/hyperledger/fabric/protos/peer"
// Decorator decorates a chaincode input
type Decorator interface {
// Decorate decorates a chaincode input by changing it
Decorate(input *peer.ChaincodeInput) *peer.ChaincodeInput
Decorate(proposal *peer.Proposal, input *peer.ChaincodeInput) *peer.ChaincodeInput
}

// NewDecorator creates a new decorator
Expand All @@ -23,6 +23,6 @@ type decorator struct {
}

// Decorate decorates a chaincode input by changing it
func (d *decorator) Decorate(input *peer.ChaincodeInput) *peer.ChaincodeInput {
func (d *decorator) Decorate(proposal *peer.Proposal, input *peer.ChaincodeInput) *peer.ChaincodeInput {
return input
}
2 changes: 1 addition & 1 deletion core/handlers/decoration/decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ func TestDecorator(t *testing.T) {
in := &peer.ChaincodeInput{
Args: [][]byte{{1, 2, 3}},
}
out := dec.Decorate(in)
out := dec.Decorate(nil, in)
assert.Equal(t, in, out)
}

0 comments on commit a73da04

Please sign in to comment.