forked from TrueCloudLab/neoneo-go
storage: drop BadgerDB support, close #2130
This commit is contained in:
parent
fdf80dbdc5
commit
fb4b87bb96
18 changed files with 16 additions and 225 deletions
|
@ -51,7 +51,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "./chains/mainnet"
|
DataDirectoryPath: "./chains/mainnet"
|
||||||
|
@ -61,8 +61,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/mainnet.bolt"
|
# FilePath: "./chains/mainnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/mainnet.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 10333
|
NodePort: 10333
|
||||||
|
|
|
@ -32,7 +32,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "/chains/four"
|
DataDirectoryPath: "/chains/four"
|
||||||
|
@ -42,8 +42,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/privnet.bolt"
|
# FilePath: "./chains/privnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/four.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20336
|
NodePort: 20336
|
||||||
|
|
|
@ -32,7 +32,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "/chains/one"
|
DataDirectoryPath: "/chains/one"
|
||||||
|
@ -42,8 +42,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/privnet.bolt"
|
# FilePath: "./chains/privnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/one.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20333
|
NodePort: 20333
|
||||||
|
|
|
@ -26,7 +26,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "/chains/single"
|
DataDirectoryPath: "/chains/single"
|
||||||
|
@ -36,8 +36,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/privnet.bolt"
|
# FilePath: "./chains/privnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/single.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20333
|
NodePort: 20333
|
||||||
|
|
|
@ -32,7 +32,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "/chains/three"
|
DataDirectoryPath: "/chains/three"
|
||||||
|
@ -42,8 +42,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/privnet.bolt"
|
# FilePath: "./chains/privnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/three.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20335
|
NodePort: 20335
|
||||||
|
|
|
@ -32,7 +32,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "/chains/two"
|
DataDirectoryPath: "/chains/two"
|
||||||
|
@ -42,8 +42,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/privnet.bolt"
|
# FilePath: "./chains/privnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/two.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20334
|
NodePort: 20334
|
||||||
|
|
|
@ -32,7 +32,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "./chains/privnet"
|
DataDirectoryPath: "./chains/privnet"
|
||||||
|
@ -42,8 +42,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/privnet.bolt"
|
# FilePath: "./chains/privnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/privnet.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20332
|
NodePort: 20332
|
||||||
|
|
|
@ -51,7 +51,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "leveldb" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
LevelDBOptions:
|
LevelDBOptions:
|
||||||
DataDirectoryPath: "./chains/testnet"
|
DataDirectoryPath: "./chains/testnet"
|
||||||
|
@ -61,8 +61,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/testnet.bolt"
|
# FilePath: "./chains/testnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/testnet.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20333
|
NodePort: 20333
|
||||||
|
|
|
@ -25,7 +25,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "inmemory" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "inmemory" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
# LevelDBOptions:
|
# LevelDBOptions:
|
||||||
# DataDirectoryPath: "./chains/unit_testnet"
|
# DataDirectoryPath: "./chains/unit_testnet"
|
||||||
|
@ -35,8 +35,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/unit_testnet.bolt"
|
# FilePath: "./chains/unit_testnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/unit_testnet.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 0
|
NodePort: 0
|
||||||
|
|
|
@ -34,7 +34,7 @@ ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
# LogPath: "./log/neogo.log"
|
# LogPath: "./log/neogo.log"
|
||||||
DBConfiguration:
|
DBConfiguration:
|
||||||
Type: "inmemory" #other options: 'inmemory','redis','boltdb', 'badgerdb'.
|
Type: "inmemory" #other options: 'inmemory','redis','boltdb'
|
||||||
# DB type options. Uncomment those you need in case you want to switch DB type.
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
# LevelDBOptions:
|
# LevelDBOptions:
|
||||||
# DataDirectoryPath: "./chains/unit_testnet"
|
# DataDirectoryPath: "./chains/unit_testnet"
|
||||||
|
@ -44,8 +44,6 @@ ApplicationConfiguration:
|
||||||
# DB: 0
|
# DB: 0
|
||||||
# BoltDBOptions:
|
# BoltDBOptions:
|
||||||
# FilePath: "./chains/unit_testnet.bolt"
|
# FilePath: "./chains/unit_testnet.bolt"
|
||||||
# BadgerDBOptions:
|
|
||||||
# BadgerDir: "./chains/unit_testnet.badger"
|
|
||||||
# Uncomment in order to set up custom address for node.
|
# Uncomment in order to set up custom address for node.
|
||||||
# Address: 127.0.0.1
|
# Address: 127.0.0.1
|
||||||
NodePort: 20333
|
NodePort: 20333
|
||||||
|
|
|
@ -53,16 +53,13 @@ DBConfiguration:
|
||||||
DB: 0
|
DB: 0
|
||||||
BoltDBOptions:
|
BoltDBOptions:
|
||||||
FilePath: ./chains/privnet.bolt
|
FilePath: ./chains/privnet.bolt
|
||||||
BadgerDBOptions:
|
|
||||||
BadgerDir: ./chains/privnet.badger
|
|
||||||
```
|
```
|
||||||
where:
|
where:
|
||||||
- `Type` is the database type (string value). Supported types: `levelDB`,
|
- `Type` is the database type (string value). Supported types: `levelDB`,
|
||||||
`redisDB`, `boltDB`, `badgerDB`.
|
`redisDB`, `boltDB`
|
||||||
- `LevelDBOptions` are settings for LevelDB.
|
- `LevelDBOptions` are settings for LevelDB.
|
||||||
- `RedisDBOptions` are options for RedisDB.
|
- `RedisDBOptions` are options for RedisDB.
|
||||||
- `BoltDBOptions` configures BoltDB.
|
- `BoltDBOptions` configures BoltDB.
|
||||||
- `BadgerDBOptions` are options for BadgerDB.
|
|
||||||
|
|
||||||
Only options for the specified database type will be used.
|
Only options for the specified database type will be used.
|
||||||
|
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -6,7 +6,6 @@ require (
|
||||||
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db
|
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db
|
||||||
github.com/alicebob/miniredis/v2 v2.15.1
|
github.com/alicebob/miniredis/v2 v2.15.1
|
||||||
github.com/btcsuite/btcd v0.22.0-beta
|
github.com/btcsuite/btcd v0.22.0-beta
|
||||||
github.com/dgraph-io/badger/v2 v2.0.3
|
|
||||||
github.com/go-redis/redis v6.15.9+incompatible
|
github.com/go-redis/redis v6.15.9+incompatible
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/hashicorp/golang-lru v0.5.4
|
github.com/hashicorp/golang-lru v0.5.4
|
||||||
|
|
6
go.sum
6
go.sum
|
@ -5,9 +5,7 @@ github.com/CityOfZion/neo-go v0.62.1-pre.0.20191114145240-e740fbe708f8/go.mod h1
|
||||||
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191209120015-fccb0085941e/go.mod h1:0enZl0az8xA6PVkwzEOwPWVJGqlt/GO4hA4kmQ5Xzig=
|
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191209120015-fccb0085941e/go.mod h1:0enZl0az8xA6PVkwzEOwPWVJGqlt/GO4hA4kmQ5Xzig=
|
||||||
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191212173117-32ac01130d4c/go.mod h1:JtlHfeqLywZLswKIKFnAp+yzezY4Dji9qlfQKB2OD/I=
|
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191212173117-32ac01130d4c/go.mod h1:JtlHfeqLywZLswKIKFnAp+yzezY4Dji9qlfQKB2OD/I=
|
||||||
github.com/CityOfZion/neo-go v0.71.1-pre.0.20200129171427-f773ec69fb84/go.mod h1:FLI526IrRWHmcsO+mHsCbj64pJZhwQFTLJZu+A4PGOA=
|
github.com/CityOfZion/neo-go v0.71.1-pre.0.20200129171427-f773ec69fb84/go.mod h1:FLI526IrRWHmcsO+mHsCbj64pJZhwQFTLJZu+A4PGOA=
|
||||||
github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM=
|
|
||||||
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
|
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
|
||||||
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
|
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA=
|
github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA=
|
||||||
github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig=
|
github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig=
|
||||||
|
@ -76,13 +74,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||||
github.com/dgraph-io/badger/v2 v2.0.3 h1:inzdf6VF/NZ+tJ8RwwYMjJMvsOALTHYdozn0qSl6XJI=
|
|
||||||
github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM=
|
github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM=
|
||||||
github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3 h1:MQLRM35Pp0yAyBYksjbj1nZI/w6eyRY/mWoM1sFf4kU=
|
|
||||||
github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
|
||||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
|
||||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
|
|
@ -1,155 +0,0 @@
|
||||||
package storage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/dgraph-io/badger/v2"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util/slice"
|
|
||||||
)
|
|
||||||
|
|
||||||
// BadgerDBOptions configuration for BadgerDB.
|
|
||||||
type BadgerDBOptions struct {
|
|
||||||
Dir string `yaml:"BadgerDir"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// BadgerDBStore is the official storage implementation for storing and retrieving
|
|
||||||
// blockchain data.
|
|
||||||
type BadgerDBStore struct {
|
|
||||||
db *badger.DB
|
|
||||||
}
|
|
||||||
|
|
||||||
// BadgerDBBatch is a wrapper around badger.WriteBatch, compatible with Batch interface.
|
|
||||||
type BadgerDBBatch struct {
|
|
||||||
batch *badger.WriteBatch
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete implements the Batch interface.
|
|
||||||
func (b *BadgerDBBatch) Delete(key []byte) {
|
|
||||||
err := b.batch.Delete(key)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put implements the Batch interface.
|
|
||||||
func (b *BadgerDBBatch) Put(key, value []byte) {
|
|
||||||
keycopy := slice.Copy(key)
|
|
||||||
valuecopy := slice.Copy(value)
|
|
||||||
err := b.batch.Set(keycopy, valuecopy)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewBadgerDBStore returns a new BadgerDBStore object that will
|
|
||||||
// initialize the database found at the given path.
|
|
||||||
func NewBadgerDBStore(cfg BadgerDBOptions) (*BadgerDBStore, error) {
|
|
||||||
// BadgerDB isn't able to make nested directories
|
|
||||||
err := os.MkdirAll(cfg.Dir, os.ModePerm)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
opts := badger.DefaultOptions(cfg.Dir) // should be exposed via BadgerDBOptions if anything needed
|
|
||||||
|
|
||||||
db, err := badger.Open(opts)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &BadgerDBStore{
|
|
||||||
db: db,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Batch implements the Batch interface and returns a badgerdb
|
|
||||||
// compatible Batch.
|
|
||||||
func (b *BadgerDBStore) Batch() Batch {
|
|
||||||
return &BadgerDBBatch{b.db.NewWriteBatch()}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete implements the Store interface.
|
|
||||||
func (b *BadgerDBStore) Delete(key []byte) error {
|
|
||||||
return b.db.Update(func(txn *badger.Txn) error {
|
|
||||||
return txn.Delete(key)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get implements the Store interface.
|
|
||||||
func (b *BadgerDBStore) Get(key []byte) ([]byte, error) {
|
|
||||||
var val []byte
|
|
||||||
err := b.db.View(func(txn *badger.Txn) error {
|
|
||||||
item, err := txn.Get(key)
|
|
||||||
if err == badger.ErrKeyNotFound {
|
|
||||||
return ErrKeyNotFound
|
|
||||||
}
|
|
||||||
val, err = item.ValueCopy(nil)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
return val, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put implements the Store interface.
|
|
||||||
func (b *BadgerDBStore) Put(key, value []byte) error {
|
|
||||||
return b.db.Update(func(txn *badger.Txn) error {
|
|
||||||
err := txn.Set(key, value)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutBatch implements the Store interface.
|
|
||||||
func (b *BadgerDBStore) PutBatch(batch Batch) error {
|
|
||||||
defer batch.(*BadgerDBBatch).batch.Cancel()
|
|
||||||
return batch.(*BadgerDBBatch).batch.Flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutChangeSet implements the Store interface.
|
|
||||||
func (b *BadgerDBStore) PutChangeSet(puts map[string][]byte, dels map[string]bool) error {
|
|
||||||
return b.db.Update(func(txn *badger.Txn) error {
|
|
||||||
for k, v := range puts {
|
|
||||||
err := txn.Set([]byte(k), v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for k := range dels {
|
|
||||||
err := txn.Delete([]byte(k))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seek implements the Store interface.
|
|
||||||
func (b *BadgerDBStore) Seek(key []byte, f func(k, v []byte)) {
|
|
||||||
err := b.db.View(func(txn *badger.Txn) error {
|
|
||||||
it := txn.NewIterator(badger.IteratorOptions{
|
|
||||||
PrefetchValues: true,
|
|
||||||
PrefetchSize: 100,
|
|
||||||
Reverse: false,
|
|
||||||
AllVersions: false,
|
|
||||||
Prefix: key,
|
|
||||||
InternalAccess: false,
|
|
||||||
})
|
|
||||||
defer it.Close()
|
|
||||||
for it.Seek(key); it.ValidForPrefix(key); it.Next() {
|
|
||||||
item := it.Item()
|
|
||||||
k := item.Key()
|
|
||||||
v, err := item.ValueCopy(nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
f(k, v)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close releases all db resources.
|
|
||||||
func (b *BadgerDBStore) Close() error {
|
|
||||||
return b.db.Close()
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package storage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newBadgerDBForTesting(t testing.TB) Store {
|
|
||||||
bdbDir := t.TempDir()
|
|
||||||
dbConfig := DBConfiguration{
|
|
||||||
Type: "badgerdb",
|
|
||||||
BadgerDBOptions: BadgerDBOptions{
|
|
||||||
Dir: bdbDir,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
newBadgerStore, err := NewBadgerDBStore(dbConfig.BadgerDBOptions)
|
|
||||||
require.Nil(t, err, "NewBadgerDBStore error")
|
|
||||||
return newBadgerStore
|
|
||||||
}
|
|
|
@ -110,8 +110,6 @@ func NewStore(cfg DBConfiguration) (Store, error) {
|
||||||
store, err = NewRedisStore(cfg.RedisDBOptions)
|
store, err = NewRedisStore(cfg.RedisDBOptions)
|
||||||
case "boltdb":
|
case "boltdb":
|
||||||
store, err = NewBoltDBStore(cfg.BoltDBOptions)
|
store, err = NewBoltDBStore(cfg.BoltDBOptions)
|
||||||
case "badgerdb":
|
|
||||||
store, err = NewBadgerDBStore(cfg.BadgerDBOptions)
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown storage: %s", cfg.Type)
|
return nil, fmt.Errorf("unknown storage: %s", cfg.Type)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// DBConfiguration describes configuration for DB. Supported: 'levelDB', 'redisDB', 'boltDB', 'badgerDB'.
|
// DBConfiguration describes configuration for DB. Supported: 'levelDB', 'redisDB', 'boltDB'.
|
||||||
DBConfiguration struct {
|
DBConfiguration struct {
|
||||||
Type string `yaml:"Type"`
|
Type string `yaml:"Type"`
|
||||||
LevelDBOptions LevelDBOptions `yaml:"LevelDBOptions"`
|
LevelDBOptions LevelDBOptions `yaml:"LevelDBOptions"`
|
||||||
RedisDBOptions RedisDBOptions `yaml:"RedisDBOptions"`
|
RedisDBOptions RedisDBOptions `yaml:"RedisDBOptions"`
|
||||||
BoltDBOptions BoltDBOptions `yaml:"BoltDBOptions"`
|
BoltDBOptions BoltDBOptions `yaml:"BoltDBOptions"`
|
||||||
BadgerDBOptions BadgerDBOptions `yaml:"BadgerDBOptions"`
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -223,7 +223,6 @@ func TestAllDBs(t *testing.T) {
|
||||||
{"MemCached", newMemCachedStoreForTesting},
|
{"MemCached", newMemCachedStoreForTesting},
|
||||||
{"Memory", newMemoryStoreForTesting},
|
{"Memory", newMemoryStoreForTesting},
|
||||||
{"RedisDB", newRedisStoreForTesting},
|
{"RedisDB", newRedisStoreForTesting},
|
||||||
{"BadgerDB", newBadgerDBForTesting},
|
|
||||||
}
|
}
|
||||||
var tests = []dbTestFunction{testStoreClose, testStorePutAndGet,
|
var tests = []dbTestFunction{testStoreClose, testStorePutAndGet,
|
||||||
testStoreGetNonExistent, testStorePutBatch, testStoreSeek,
|
testStoreGetNonExistent, testStorePutBatch, testStoreSeek,
|
||||||
|
|
Loading…
Reference in a new issue