Skip to content

Commit

Permalink
enforce unique transaction hash
Browse files Browse the repository at this point in the history
  • Loading branch information
unwriter committed Oct 21, 2018
1 parent aa27a1a commit caee3a3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,13 @@ var block = {
o[keys[i]] = 1;
console.time("Index:" + keys[i])
try {
console.log(o)
await db.collection(collectionName).createIndex(o)
console.log("* Created index for ", keys[i])
if (keys[i] === "tx.h") {
await db.collection(collectionName).createIndex(o, { unique: true })
console.log('* Created unique index for ', keys[i])
} else {
await db.collection(collectionName).createIndex(o)
console.log('* Created index for ', keys[i])
}
} catch (e) {
console.log(e)
process.exit()
Expand Down

0 comments on commit caee3a3

Please sign in to comment.