2017-07-12 1 views
0

J'ai une interface qui représente ce que je veux faire avec une blockchain.Hyperledger Fabric générique mettre et obtenir

public interface IBlockChain { 

    /** 
    * Put data on the blockchain 
    * 
    * @param key the key being used to put the data on the blockchain 
    * @param data the data being put on the blockchain 
    */ 
    public boolean put(String key, Map<String, Object> data); 

    /** 
    * Get data from the blockchain 
    * 
    * @param key the key being queried 
    * @return 
    */ 
    public List<Record> get(String key); 

    /** 
    * Get all data from the blockchain 
    * @return 
    */ 
    public List<Record> all(); 
} 

J'ai une implémentation de travail pour Multichain. Mais j'aimerais maintenant commencer une implémentation pour d'autres technologies de blockchain. Comment procéder dans Hyperledger Fabric v1.0? Puis-je simplement ajouter des données brutes? Ou ai-je toujours besoin d'appeler des morceaux de code-chaîne pour créer un objet pour moi?

+0

Vous devez appeler Smart Contract (chaincode) que vous avez instancié dans votre Blockchain. Dans votre cas, vous auriez un Hyper Blockger Fabric Blockchain. Ensuite, il y a un SDK (https://github.com/hyperledger/fabric-sdk-node) qui aide à l'appeler. Je ne sais pas si j'ai bien compris votre question. Pourriez-vous donner plus d'informations? – Urko

Répondre

1

Vous auriez besoin d'écrire un chaincode pour mettre et obtenir les données. Les fonctions de chaincode correspondantes sont:

PutState(key string, value []byte) error 
GetState(key string) ([]byte, error) 

Il y a un tutoriel pour chaincode Hyperledger Fabric v1.0:

https://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html 

Ensuite, votre client peut appeler le chaincode et soumettre la transaction. Il y a un Hyperledger Fabric Node.js SDK tutorial qui peut vous aider à mieux comprendre.