changes to support couchdb 3.1.1

Signed-off-by: Indranil Majumder <indranil.majumder@navis.com>
This commit is contained in:
Indranil Majumder 2021-09-16 15:26:28 +05:30 committed by denyeart
parent 5860027ac8
commit 7a727eb69a
6 changed files with 29 additions and 11 deletions

5
off_chain_data/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
addAssets.json
mychannel__lifecycle.log
mychannel_basic.log
nextblock.txt
wallet/

View file

@ -38,7 +38,7 @@ The configuration for the listener is stored in the `config.json` file:
"channelid": "mychannel",
"use_couchdb":true,
"create_history_log":true,
"couchdb_address": "http://localhost:5990"
"couchdb_address": "http://admin:password@localhost:5990"
}
```
@ -48,7 +48,7 @@ The configuration for the listener is stored in the `config.json` file:
CouchDB. If set to false, only a local log of events will be stored.
`create_history_log:` If true, a local log file will be created with all of the
block changes.
`couchdb_address:` is the local address for an off chain CouchDB database.
`couchdb_address:` is the local address for an off chain CouchDB database with username and password.
### Create an instance of CouchDB
@ -56,7 +56,7 @@ If you set the "use_couchdb" option to true in `config.json`, you can run the
following command start a local instance of CouchDB using docker:
```
docker run --publish 5990:5984 --detach --name offchaindb couchdb:2.3.1
docker run -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password --publish 5990:5984 --detach --name offchaindb couchdb:3.1.1
docker start offchaindb
```

View file

@ -86,7 +86,7 @@ exports.processBlockEvent = async function (channelname, block, use_couchdb, nan
for (var record in rwSet) {
// ignore lscc events
if (rwSet[record].namespace != 'lscc') {
if (rwSet[record].namespace != '_lifecycle') {
// create object to store properties
const writeObject = new Object();
writeObject.blocknumber = blockNumber;
@ -159,6 +159,7 @@ async function writeValuesToCouchDBP(nano, channelname, writeObject) {
keyvalue.value
)
) {
// insert or update value by key - this emulates world state behavior
await couchdbutil.writeToCouchDB(
nano,

View file

@ -3,5 +3,5 @@
"channelid": "mychannel",
"use_couchdb":true,
"create_history_log":true,
"couchdb_address": "http://localhost:5990"
"couchdb_address": "http://admin:password@localhost:5990"
}

View file

@ -37,7 +37,7 @@ exports.writeToCouchDB = async function (nano, dbname, key, value) {
try {
await this.createDatabaseIfNotExists(nano, dbname);
} catch (error) {
console.log("Error creating the database-"+error)
}
const db = nano.use(dbname);
@ -82,7 +82,7 @@ exports.deleteRecord = async function (nano, dbname, key) {
try {
await this.createDatabaseIfNotExists(nano, dbname);
} catch (error) {
console.log("Error creating the database-"+error)
}
const db = nano.use(dbname);

View file

@ -11,7 +11,19 @@ starttime=$(date +%s)
# launch network; create channel and join peer to channel
pushd ../test-network
./network.sh down
# Fixes the issue of <sh: cd: line 1: can't cd to /data: No such file or directory> when running busybox in network down command on windows git bash
case "$(uname -s)" in
CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo 'Running on MS Windows'
export MSYS_NO_PATHCONV=1
./network.sh down
unset MSYS_NO_PATHCONV
;;
*)
./network.sh down
;;
esac
./network.sh up createChannel -ca -s couchdb
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go/ -ccl go