-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FAB-1140 Ledger History Database framework
This is an initial check-in that will 1) create the history database in couchDB if it does not exist. 2) add the history commit to the LEDGER Commit if history is enabled 3) stores the history in the history database The History functionality is not enabled unless both couchDB and History are enabled in the config. Note that tests will be added to validate the writes and the actual data written to the database in future changes. The tests to validate history is not possible until the query APIs are put in place in future changes. Change-Id: Id207007ab5faae957c1e05234e441566a116ea33 Signed-off-by: Mari Wade <mariwade@us.ibm.com>
- Loading branch information
Showing
7 changed files
with
277 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright IBM Corp. 2016 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package history | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" | ||
"github.com/hyperledger/fabric/core/ledger/util/couchdb" | ||
) | ||
|
||
//Complex setup to test the use of couch in ledger | ||
type testEnvHistoryCouchDB struct { | ||
couchDBAddress string | ||
couchDatabaseName string | ||
couchUsername string | ||
couchPassword string | ||
} | ||
|
||
func newTestEnvHistoryCouchDB(t testing.TB, dbName string) *testEnvHistoryCouchDB { | ||
|
||
couchDBDef := ledgerconfig.GetCouchDBDefinition() | ||
|
||
return &testEnvHistoryCouchDB{ | ||
couchDBAddress: couchDBDef.URL, | ||
couchDatabaseName: dbName, | ||
couchUsername: couchDBDef.Username, | ||
couchPassword: couchDBDef.Password, | ||
} | ||
} | ||
|
||
func (env *testEnvHistoryCouchDB) cleanup() { | ||
|
||
//create a new connection | ||
couchDB, err := couchdb.CreateConnectionDefinition(env.couchDBAddress, env.couchDatabaseName, env.couchUsername, env.couchPassword) | ||
if err == nil { | ||
//drop the test database if it already existed | ||
couchDB.DropDatabase() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.