summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2019-07-09 12:44:30 -0400
committerFranklin Wei <git@fwei.tk>2019-07-09 12:44:30 -0400
commit9ed3f5dae9a60adbce6090a46e9556924b33c3fc (patch)
treed01437799a56473e6a8e41ccf51f7700f9e20e8c
parentae71ebea42932f70b15b4a3bf28cdb3739c07971 (diff)
downloaddcr-9ed3f5dae9a60adbce6090a46e9556924b33c3fc.zip
dcr-9ed3f5dae9a60adbce6090a46e9556924b33c3fc.tar.gz
dcr-9ed3f5dae9a60adbce6090a46e9556924b33c3fc.tar.bz2
dcr-9ed3f5dae9a60adbce6090a46e9556924b33c3fc.tar.xz
Some more work on IOMT. Also migrate to CouchDB.
-rw-r--r--java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/FabricIOMT.java4
-rw-r--r--java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMT.java16
-rw-r--r--java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMTLeaf.java5
-rw-r--r--java-chaincode/docker-compose.yaml22
4 files changed, 38 insertions, 9 deletions
diff --git a/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/FabricIOMT.java b/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/FabricIOMT.java
index d7ea9c4..9915028 100644
--- a/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/FabricIOMT.java
+++ b/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/FabricIOMT.java
@@ -243,9 +243,11 @@ public class FabricIOMT extends IOMT {
leaf.toString());
}
- public IOMTLeaf findLeaf(int virtIdx, Integer outPhysIdx) {
+ public IOMTLeaf findLeafByVirtualIndex(int virtIdx, Integer outPhysIdx) {
// TODO: couchdb query
+ //chaincodeStub.getQueryResult();
+
return new IOMTLeaf();
}
} \ No newline at end of file
diff --git a/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMT.java b/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMT.java
index 59f4baf..3974971 100644
--- a/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMT.java
+++ b/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMT.java
@@ -155,7 +155,7 @@ public abstract class IOMT {
/**
* Look up a leaf's value (a 3-tuple of index, nextIndex, and value) by its PHYSICAL
- * index--not its virtual index. Use findLeaf if you want that.
+ * index--not its virtual index. Use findLeafByVirtualIndex if you want that.
* @param leaf_id
* @return
*/
@@ -195,7 +195,9 @@ public abstract class IOMT {
* @param leaf new leaf value (a 3-tuple)
*/
public void updatePhysLeaf(int physIdx, IOMTLeaf leaf) {
+ setLeafValue(physIdx, leaf);
+ updateLeafNode(physIdx, leaf.hash());
}
static private int bintreeParent(int idx)
@@ -206,18 +208,22 @@ public abstract class IOMT {
/**
/* Convenience functions. */
- public void updateLeafIdx(int leafIdx, int newIdx) {
+ public void updateLeafFull(int physIdx, IOMTLeaf newLeaf) {
+
+ }
+
+ public void updateLeafIdx(int physIdx, int newIdx) {
}
- public void updateLeafNextIdx(int leafIdx, int newNextIdx) {
+ public void updateLeafNextIdx(int virtIdx, int newNextIdx) {
}
- public void updateLeafVal(int leafIdx, String hash) {
+ public void updateLeafVal(int virtIdx, String hash) {
}
// to be implemented on CouchDB
- abstract public IOMTLeaf findLeaf(int virtIdx, Integer outPhysLeafIdx);
+ abstract public IOMTLeaf findLeafByVirtualIndex(int virtIdx, Integer outPhysLeafIdx);
}
diff --git a/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMTLeaf.java b/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMTLeaf.java
index 33c26be..6214486 100644
--- a/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMTLeaf.java
+++ b/java-chaincode/dcrchaincode/src/main/java/tk/fwei/dcr/IOMTLeaf.java
@@ -1,5 +1,7 @@
package tk.fwei.dcr;
+import org.apache.commons.lang3.StringUtils;
+
public class IOMTLeaf {
private String val;
@@ -31,7 +33,8 @@ public class IOMTLeaf {
public String hash() {
// TODO
- return IOMT.ZERO_HASH;
+ return StringUtils.repeat('1', IOMT.HASH_LEN);
+ //return IOMT.ZERO_HASH;
}
public IOMTLeaf(int idx, int nextIdx, String val) {
diff --git a/java-chaincode/docker-compose.yaml b/java-chaincode/docker-compose.yaml
index fbeba3b..c7dc093 100644
--- a/java-chaincode/docker-compose.yaml
+++ b/java-chaincode/docker-compose.yaml
@@ -40,6 +40,13 @@ services:
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.org1.mydomain.com:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=java-chaincode_basic
+ - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
+ - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
+ # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
+ # provide the credentials for ledger to connect to CouchDB. The username and password must
+ # match the username and password set for the associated CouchDB.
+ - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
+ - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start --logging-level=debug
ports:
@@ -50,8 +57,19 @@ services:
- ./crypto-config/peerOrganizations/org1.mydomain.com/peers/peer0.org1.mydomain.com/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.mydomain.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
- depends_on:
- - orderer.mydomain.com
+ networks:
+ - basic
+
+ couchdb:
+ container_name: couchdb
+ image: hyperledger/fabric-couchdb
+ # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
+ # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
+ environment:
+ - COUCHDB_USER=
+ - COUCHDB_PASSWORD=
+ ports:
+ - 5984:5984
networks:
- basic