mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
changes to support couchdb 3.1.1
Signed-off-by: Indranil Majumder <indranil.majumder@navis.com>
This commit is contained in:
parent
5860027ac8
commit
7a727eb69a
6 changed files with 29 additions and 11 deletions
5
off_chain_data/.gitignore
vendored
Normal file
5
off_chain_data/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
addAssets.json
|
||||||
|
mychannel__lifecycle.log
|
||||||
|
mychannel_basic.log
|
||||||
|
nextblock.txt
|
||||||
|
wallet/
|
||||||
|
|
@ -38,7 +38,7 @@ The configuration for the listener is stored in the `config.json` file:
|
||||||
"channelid": "mychannel",
|
"channelid": "mychannel",
|
||||||
"use_couchdb":true,
|
"use_couchdb":true,
|
||||||
"create_history_log":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.
|
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
|
`create_history_log:` If true, a local log file will be created with all of the
|
||||||
block changes.
|
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
|
### 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:
|
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
|
docker start offchaindb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ exports.processBlockEvent = async function (channelname, block, use_couchdb, nan
|
||||||
for (var record in rwSet) {
|
for (var record in rwSet) {
|
||||||
|
|
||||||
// ignore lscc events
|
// ignore lscc events
|
||||||
if (rwSet[record].namespace != 'lscc') {
|
if (rwSet[record].namespace != '_lifecycle') {
|
||||||
// create object to store properties
|
// create object to store properties
|
||||||
const writeObject = new Object();
|
const writeObject = new Object();
|
||||||
writeObject.blocknumber = blockNumber;
|
writeObject.blocknumber = blockNumber;
|
||||||
|
|
@ -108,7 +108,7 @@ exports.processBlockEvent = async function (channelname, block, use_couchdb, nan
|
||||||
try {
|
try {
|
||||||
await writeValuesToCouchDBP(nano, channelname, writeObject);
|
await writeValuesToCouchDBP(nano, channelname, writeObject);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,14 +136,14 @@ async function writeValuesToCouchDBP(nano, channelname, writeObject) {
|
||||||
const historydbname = channelname + '_' + writeObject.chaincodeid + '_history';
|
const historydbname = channelname + '_' + writeObject.chaincodeid + '_history';
|
||||||
// set values to the array of values received
|
// set values to the array of values received
|
||||||
const values = writeObject.values;
|
const values = writeObject.values;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var sequence in values) {
|
for (var sequence in values) {
|
||||||
let keyvalue =
|
let keyvalue =
|
||||||
values[
|
values[
|
||||||
sequence
|
sequence
|
||||||
];
|
];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
keyvalue.is_delete ==
|
keyvalue.is_delete ==
|
||||||
true
|
true
|
||||||
|
|
@ -159,6 +159,7 @@ async function writeValuesToCouchDBP(nano, channelname, writeObject) {
|
||||||
keyvalue.value
|
keyvalue.value
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// insert or update value by key - this emulates world state behavior
|
// insert or update value by key - this emulates world state behavior
|
||||||
await couchdbutil.writeToCouchDB(
|
await couchdbutil.writeToCouchDB(
|
||||||
nano,
|
nano,
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@
|
||||||
"channelid": "mychannel",
|
"channelid": "mychannel",
|
||||||
"use_couchdb":true,
|
"use_couchdb":true,
|
||||||
"create_history_log":true,
|
"create_history_log":true,
|
||||||
"couchdb_address": "http://localhost:5990"
|
"couchdb_address": "http://admin:password@localhost:5990"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ exports.writeToCouchDB = async function (nano, dbname, key, value) {
|
||||||
try {
|
try {
|
||||||
await this.createDatabaseIfNotExists(nano, dbname);
|
await this.createDatabaseIfNotExists(nano, dbname);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("Error creating the database-"+error)
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = nano.use(dbname);
|
const db = nano.use(dbname);
|
||||||
|
|
@ -82,7 +82,7 @@ exports.deleteRecord = async function (nano, dbname, key) {
|
||||||
try {
|
try {
|
||||||
await this.createDatabaseIfNotExists(nano, dbname);
|
await this.createDatabaseIfNotExists(nano, dbname);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("Error creating the database-"+error)
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = nano.use(dbname);
|
const db = nano.use(dbname);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,19 @@ starttime=$(date +%s)
|
||||||
|
|
||||||
# launch network; create channel and join peer to channel
|
# launch network; create channel and join peer to channel
|
||||||
pushd ../test-network
|
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 up createChannel -ca -s couchdb
|
||||||
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go/ -ccl go
|
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go/ -ccl go
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue