-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-8525] Refactor scc chaincode invocation
This change extracts invocation request creation for qscc, cscc and lscc to their own funcs and files. Change-Id: I8f2f78df19b5ecb48b2c70cb31b9b31acb4c548b Signed-off-by: Troy Ronda <troy@troyronda.com>
- Loading branch information
Showing
13 changed files
with
322 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package channel | ||
|
||
import ( | ||
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/fab" | ||
) | ||
|
||
const ( | ||
cscc = "cscc" | ||
csccConfigBlock = "GetConfigBlock" | ||
) | ||
|
||
func createConfigBlockInvokeRequest(channelID string) fab.ChaincodeInvokeRequest { | ||
cir := fab.ChaincodeInvokeRequest{ | ||
ChaincodeID: cscc, | ||
Fcn: csccConfigBlock, | ||
Args: [][]byte{[]byte(channelID)}, | ||
} | ||
return cir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package channel | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/fab" | ||
) | ||
|
||
const ( | ||
qscc = "qscc" | ||
qsccTransactionByID = "GetTransactionByID" | ||
qsccChannelInfo = "GetChainInfo" | ||
qsccBlockByHash = "GetBlockByHash" | ||
qsccBlockByNumber = "GetBlockByNumber" | ||
) | ||
|
||
func createTransactionByIDInvokeRequest(channelID string, transactionID fab.TransactionID) fab.ChaincodeInvokeRequest { | ||
var args [][]byte | ||
args = append(args, []byte(channelID)) | ||
args = append(args, []byte(transactionID)) | ||
|
||
cir := fab.ChaincodeInvokeRequest{ | ||
ChaincodeID: qscc, | ||
Fcn: qsccTransactionByID, | ||
Args: args, | ||
} | ||
return cir | ||
} | ||
|
||
func createChannelInfoInvokeRequest(channelID string) fab.ChaincodeInvokeRequest { | ||
var args [][]byte | ||
args = append(args, []byte(channelID)) | ||
|
||
cir := fab.ChaincodeInvokeRequest{ | ||
ChaincodeID: qscc, | ||
Fcn: qsccChannelInfo, | ||
Args: args, | ||
} | ||
return cir | ||
} | ||
|
||
func createBlockByHashInvokeRequest(channelID string, blockHash []byte) fab.ChaincodeInvokeRequest { | ||
|
||
var args [][]byte | ||
args = append(args, []byte(channelID)) | ||
args = append(args, blockHash) | ||
|
||
cir := fab.ChaincodeInvokeRequest{ | ||
ChaincodeID: qscc, | ||
Fcn: qsccBlockByHash, | ||
Args: args, | ||
} | ||
return cir | ||
} | ||
|
||
func createBlockByNumberInvokeRequest(channelID string, blockNumber int) fab.ChaincodeInvokeRequest { | ||
|
||
var args [][]byte | ||
args = append(args, []byte(channelID)) | ||
args = append(args, []byte(strconv.Itoa(blockNumber))) | ||
|
||
cir := fab.ChaincodeInvokeRequest{ | ||
ChaincodeID: qscc, | ||
Fcn: qsccBlockByNumber, | ||
Args: args, | ||
} | ||
return cir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.