2017-09-24 4 views
0

J'essaye d'écrire une application avec hyper-ledger et je cherchais un moyen de communiquer avec le code-chaîne d'un autre code-chaîne. Est-ce possible dans hyper-ledger?Est-ce qu'un chaincode peut interagir avec un autre chaincode?

Je sais qu'il est possible dans etherum de communiquer avec d'autres contrats intelligents mais est le même possible dans hyperledger. Je n'ai pas trouvé de liens connexes liés à la même chose. Toute suggestion sur la façon d'aborder cela sera vraiment utile.

J'ai vérifié Writing Your First Application, mais je ne pouvais pas trouver l'explication appropriée pour le même.

Répondre

1

Chaincode pourrait interagir avec d'autres chaincode au moyen de tirer parti existant API de ChaincodeStubInterface, par exemple:

// InvokeChaincode locally calls the specified chaincode `Invoke` using the 
// same transaction context; that is, chaincode calling chaincode doesn't 
// create a new transaction message. 
// If the called chaincode is on the same channel, it simply adds the called 
// chaincode read set and write set to the calling transaction. 
// If the called chaincode is on a different channel, 
// only the Response is returned to the calling chaincode; any PutState calls 
// from the called chaincode will not have any effect on the ledger; that is, 
// the called chaincode on a different channel will not have its read set 
// and write set applied to the transaction. Only the calling chaincode's 
// read set and write set will be applied to the transaction. Effectively 
// the called chaincode on a different channel is a `Query`, which does not 
// participate in state validation checks in subsequent commit phase. 
// If `channel` is empty, the caller's channel is assumed. 
InvokeChaincode(chaincodeName string, args [][]byte, channel string) pb.Response 

Voici un exemple de la façon dont vous pouvez l'utiliser:

response := stub.InvokeChaincode(chaincodeName, chainCodeArgs, channelName) 

de pairs du cours devrait avoir des droits et chaincode installé.