Skip to content

Commit

Permalink
Adding data access functions
Browse files Browse the repository at this point in the history
TransactionProposal.GetBytes, deprecates ChainExtension.GetProposalBytes
and TransactionProposalResponse.GetPayload

Change-Id: Iffebe7328ca7388b58ab2758a8f592c643b5a96b
Signed-off-by: Karl Einholz <karl.einholz@securekey.com>
  • Loading branch information
Karl Einholz committed Mar 30, 2017
1 parent fe98dcb commit d36e7eb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions fabric-client/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type ChainExtension interface {
SignPayload(payload []byte) (*SignedEnvelope, error)
BroadcastEnvelope(envelope *SignedEnvelope) ([]*TransactionResponse, error)

// TODO: This should go somewhere else?
// TODO: This should go somewhere else - see TransactionProposal.GetBytes(). - deprecated
GetProposalBytes(tp *TransactionProposal) ([]byte, error)
}

Expand All @@ -109,6 +109,11 @@ type TransactionProposal struct {
proposal *pb.Proposal
}

// GetBytes returns the serialized bytes of this proposal
func (tp *TransactionProposal) GetBytes() ([]byte, error) {
return proto.Marshal(tp.signedProposal)
}

// TransactionProposalResponse ...
/**
* The TransactionProposalResponse result object returned from endorsers.
Expand All @@ -122,14 +127,22 @@ type TransactionProposalResponse struct {
proposalResponse *pb.ProposalResponse
}

// GetResponsePayload returns the response payload
// GetResponsePayload returns the response object payload
func (tpr *TransactionProposalResponse) GetResponsePayload() []byte {
if tpr == nil || tpr.proposalResponse == nil {
return nil
}
return tpr.proposalResponse.GetResponse().Payload
}

// GetPayload returns the response payload
func (tpr *TransactionProposalResponse) GetPayload() []byte {
if tpr == nil || tpr.proposalResponse == nil {
return nil
}
return tpr.proposalResponse.Payload
}

// The Transaction object created from an endorsed proposal
type Transaction struct {
proposal *TransactionProposal
Expand Down

0 comments on commit d36e7eb

Please sign in to comment.