Upgrade to go 1.19 and rocksdb 7.5.3
This commit is contained in:
parent
84b931f42b
commit
1a476e58f0
10
README.md
10
README.md
@ -66,16 +66,6 @@ Check [this](https://github.com/trezor/blockbook/issues/89) or [this](https://gi
|
|||||||
|
|
||||||
Your coin's block/transaction data may not be compatible with `BitcoinParser` `ParseBlock`/`ParseTx`, which is used by default. In that case, implement your coin in a similar way we used in case of [zcash](https://github.com/trezor/blockbook/tree/master/bchain/coins/zec) and some other coins. The principle is not to parse the block/transaction data in Blockbook but instead to get parsed transactions as json from the backend.
|
Your coin's block/transaction data may not be compatible with `BitcoinParser` `ParseBlock`/`ParseTx`, which is used by default. In that case, implement your coin in a similar way we used in case of [zcash](https://github.com/trezor/blockbook/tree/master/bchain/coins/zec) and some other coins. The principle is not to parse the block/transaction data in Blockbook but instead to get parsed transactions as json from the backend.
|
||||||
|
|
||||||
#### Cannot build Blockbook using `go build` command
|
|
||||||
|
|
||||||
When building Blockbook I get error `not enough arguments in call to _Cfunc_rocksdb_approximate_sizes`.
|
|
||||||
|
|
||||||
RocksDB version 6.16.0 changed the API in a backwards incompatible way. It is necessary to build Blockbook with the `rocksdb_6_16` tag to fix the compatibility problem. The correct way to build Blockbook is:
|
|
||||||
|
|
||||||
```
|
|
||||||
go build -tags rocksdb_6_16
|
|
||||||
```
|
|
||||||
|
|
||||||
## Data storage in RocksDB
|
## Data storage in RocksDB
|
||||||
|
|
||||||
Blockbook stores data the key-value store RocksDB. Database format is described [here](/docs/rocksdb.md).
|
Blockbook stores data the key-value store RocksDB. Database format is described [here](/docs/rocksdb.md).
|
||||||
|
|||||||
@ -73,6 +73,7 @@ func init() {
|
|||||||
BlockChainFactories["Ethereum Testnet Ropsten"] = eth.NewEthereumRPC
|
BlockChainFactories["Ethereum Testnet Ropsten"] = eth.NewEthereumRPC
|
||||||
BlockChainFactories["Ethereum Testnet Ropsten Archive"] = eth.NewEthereumRPC
|
BlockChainFactories["Ethereum Testnet Ropsten Archive"] = eth.NewEthereumRPC
|
||||||
BlockChainFactories["Ethereum Testnet Goerli"] = eth.NewEthereumRPC
|
BlockChainFactories["Ethereum Testnet Goerli"] = eth.NewEthereumRPC
|
||||||
|
BlockChainFactories["Ethereum Testnet Goerli Archive"] = eth.NewEthereumRPC
|
||||||
BlockChainFactories["Bcash"] = bch.NewBCashRPC
|
BlockChainFactories["Bcash"] = bch.NewBCashRPC
|
||||||
BlockChainFactories["Bcash Testnet"] = bch.NewBCashRPC
|
BlockChainFactories["Bcash Testnet"] = bch.NewBCashRPC
|
||||||
BlockChainFactories["Bgold"] = btg.NewBGoldRPC
|
BlockChainFactories["Bgold"] = btg.NewBGoldRPC
|
||||||
|
|||||||
@ -8,15 +8,15 @@ RUN apt-get update && \
|
|||||||
apt-get upgrade -y && \
|
apt-get upgrade -y && \
|
||||||
apt-get install -y build-essential git wget pkg-config lxc-dev libzmq3-dev \
|
apt-get install -y build-essential git wget pkg-config lxc-dev libzmq3-dev \
|
||||||
libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev \
|
libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev \
|
||||||
liblz4-dev graphviz && \
|
libzstd-dev liblz4-dev graphviz && \
|
||||||
apt-get clean
|
apt-get clean
|
||||||
ARG GOLANG_VERSION
|
ARG GOLANG_VERSION
|
||||||
ENV GOLANG_VERSION=go1.17.1
|
ENV GOLANG_VERSION=go1.19
|
||||||
ENV ROCKSDB_VERSION=v6.22.1
|
ENV ROCKSDB_VERSION=v7.5.3
|
||||||
ENV GOPATH=/go
|
ENV GOPATH=/go
|
||||||
ENV PATH=$PATH:$GOPATH/bin
|
ENV PATH=$PATH:$GOPATH/bin
|
||||||
ENV CGO_CFLAGS="-I/opt/rocksdb/include"
|
ENV CGO_CFLAGS="-I/opt/rocksdb/include"
|
||||||
ENV CGO_LDFLAGS="-L/opt/rocksdb -ldl -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4"
|
ENV CGO_LDFLAGS="-L/opt/rocksdb -ldl -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"
|
||||||
ARG TCMALLOC
|
ARG TCMALLOC
|
||||||
|
|
||||||
RUN mkdir /build
|
RUN mkdir /build
|
||||||
|
|||||||
@ -10,12 +10,12 @@ ARGS ?=
|
|||||||
all: build tools
|
all: build tools
|
||||||
|
|
||||||
build: prepare-sources
|
build: prepare-sources
|
||||||
cd $(BLOCKBOOK_SRC) && go build -tags rocksdb_6_16 -o $(CURDIR)/blockbook -ldflags="-s -w $(LDFLAGS)" $(ARGS)
|
cd $(BLOCKBOOK_SRC) && go build -o $(CURDIR)/blockbook -ldflags="-s -w $(LDFLAGS)" $(ARGS)
|
||||||
cp $(CURDIR)/blockbook /out/blockbook
|
cp $(CURDIR)/blockbook /out/blockbook
|
||||||
chown $(PACKAGER) /out/blockbook
|
chown $(PACKAGER) /out/blockbook
|
||||||
|
|
||||||
build-debug: prepare-sources
|
build-debug: prepare-sources
|
||||||
cd $(BLOCKBOOK_SRC) && go build -tags rocksdb_6_16 -o $(CURDIR)/blockbook -ldflags="$(LDFLAGS)" $(ARGS)
|
cd $(BLOCKBOOK_SRC) && go build -o $(CURDIR)/blockbook -ldflags="$(LDFLAGS)" $(ARGS)
|
||||||
cp $(CURDIR)/blockbook /out/blockbook
|
cp $(CURDIR)/blockbook /out/blockbook
|
||||||
chown $(PACKAGER) /out/blockbook
|
chown $(PACKAGER) /out/blockbook
|
||||||
|
|
||||||
@ -24,13 +24,13 @@ tools:
|
|||||||
chown $(PACKAGER) /out/{ldb,sst_dump}
|
chown $(PACKAGER) /out/{ldb,sst_dump}
|
||||||
|
|
||||||
test: prepare-sources
|
test: prepare-sources
|
||||||
cd $(BLOCKBOOK_SRC) && go test -tags 'rocksdb_6_16 unittest' `go list ./... | grep -vP '^github.com/trezor/blockbook/(contrib|tests)'` $(ARGS)
|
cd $(BLOCKBOOK_SRC) && go test -tags 'unittest' `go list ./... | grep -vP '^github.com/trezor/blockbook/(contrib|tests)'` $(ARGS)
|
||||||
|
|
||||||
test-integration: prepare-sources
|
test-integration: prepare-sources
|
||||||
cd $(BLOCKBOOK_SRC) && go test -tags 'rocksdb_6_16 integration' `go list github.com/trezor/blockbook/tests/...` $(ARGS)
|
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` $(ARGS)
|
||||||
|
|
||||||
test-all: prepare-sources
|
test-all: prepare-sources
|
||||||
cd $(BLOCKBOOK_SRC) && go test -tags 'rocksdb_6_16 unittest integration' `go list ./... | grep -v '^github.com/trezor/blockbook/contrib'` $(ARGS)
|
cd $(BLOCKBOOK_SRC) && go test -tags 'unittest integration' `go list ./... | grep -v '^github.com/trezor/blockbook/contrib'` $(ARGS)
|
||||||
|
|
||||||
prepare-sources:
|
prepare-sources:
|
||||||
@ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1)
|
@ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1)
|
||||||
|
|||||||
@ -3,8 +3,8 @@ package db
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/trezor/blockbook/bchain"
|
"github.com/trezor/blockbook/bchain"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ func (d *RocksDB) InitBulkConnect() (*BulkConnect, error) {
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BulkConnect) storeTxAddresses(wb *gorocksdb.WriteBatch, all bool) (int, int, error) {
|
func (b *BulkConnect) storeTxAddresses(wb *grocksdb.WriteBatch, all bool) (int, int, error) {
|
||||||
var txm map[string]*TxAddresses
|
var txm map[string]*TxAddresses
|
||||||
var sp int
|
var sp int
|
||||||
if all {
|
if all {
|
||||||
@ -101,7 +101,7 @@ func (b *BulkConnect) storeTxAddresses(wb *gorocksdb.WriteBatch, all bool) (int,
|
|||||||
func (b *BulkConnect) parallelStoreTxAddresses(c chan error, all bool) {
|
func (b *BulkConnect) parallelStoreTxAddresses(c chan error, all bool) {
|
||||||
defer close(c)
|
defer close(c)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
count, sp, err := b.storeTxAddresses(wb, all)
|
count, sp, err := b.storeTxAddresses(wb, all)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -116,7 +116,7 @@ func (b *BulkConnect) parallelStoreTxAddresses(c chan error, all bool) {
|
|||||||
c <- nil
|
c <- nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BulkConnect) storeBalances(wb *gorocksdb.WriteBatch, all bool) (int, error) {
|
func (b *BulkConnect) storeBalances(wb *grocksdb.WriteBatch, all bool) (int, error) {
|
||||||
var bal map[string]*AddrBalance
|
var bal map[string]*AddrBalance
|
||||||
if all {
|
if all {
|
||||||
bal = b.balances
|
bal = b.balances
|
||||||
@ -141,7 +141,7 @@ func (b *BulkConnect) storeBalances(wb *gorocksdb.WriteBatch, all bool) (int, er
|
|||||||
func (b *BulkConnect) parallelStoreBalances(c chan error, all bool) {
|
func (b *BulkConnect) parallelStoreBalances(c chan error, all bool) {
|
||||||
defer close(c)
|
defer close(c)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
count, err := b.storeBalances(wb, all)
|
count, err := b.storeBalances(wb, all)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -156,7 +156,7 @@ func (b *BulkConnect) parallelStoreBalances(c chan error, all bool) {
|
|||||||
c <- nil
|
c <- nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BulkConnect) storeBulkAddresses(wb *gorocksdb.WriteBatch) error {
|
func (b *BulkConnect) storeBulkAddresses(wb *grocksdb.WriteBatch) error {
|
||||||
for _, ba := range b.bulkAddresses {
|
for _, ba := range b.bulkAddresses {
|
||||||
if err := b.d.storeAddresses(wb, ba.bi.Height, ba.addresses); err != nil {
|
if err := b.d.storeAddresses(wb, ba.bi.Height, ba.addresses); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -202,7 +202,7 @@ func (b *BulkConnect) connectBlockBitcoinType(block *bchain.Block, storeBlockTxs
|
|||||||
// open WriteBatch only if going to write
|
// open WriteBatch only if going to write
|
||||||
if sa || b.bulkAddressesCount > maxBulkAddresses || storeBlockTxs {
|
if sa || b.bulkAddressesCount > maxBulkAddresses || storeBlockTxs {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
bac := b.bulkAddressesCount
|
bac := b.bulkAddressesCount
|
||||||
if sa || b.bulkAddressesCount > maxBulkAddresses {
|
if sa || b.bulkAddressesCount > maxBulkAddresses {
|
||||||
@ -235,7 +235,7 @@ func (b *BulkConnect) connectBlockBitcoinType(block *bchain.Block, storeBlockTxs
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BulkConnect) storeAddressContracts(wb *gorocksdb.WriteBatch, all bool) (int, error) {
|
func (b *BulkConnect) storeAddressContracts(wb *grocksdb.WriteBatch, all bool) (int, error) {
|
||||||
var ac map[string]*AddrContracts
|
var ac map[string]*AddrContracts
|
||||||
if all {
|
if all {
|
||||||
ac = b.addressContracts
|
ac = b.addressContracts
|
||||||
@ -260,7 +260,7 @@ func (b *BulkConnect) storeAddressContracts(wb *gorocksdb.WriteBatch, all bool)
|
|||||||
func (b *BulkConnect) parallelStoreAddressContracts(c chan error, all bool) {
|
func (b *BulkConnect) parallelStoreAddressContracts(c chan error, all bool) {
|
||||||
defer close(c)
|
defer close(c)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
count, err := b.storeAddressContracts(wb, all)
|
count, err := b.storeAddressContracts(wb, all)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -303,7 +303,7 @@ func (b *BulkConnect) connectBlockEthereumType(block *bchain.Block, storeBlockTx
|
|||||||
// open WriteBatch only if going to write
|
// open WriteBatch only if going to write
|
||||||
if sa || b.bulkAddressesCount > maxBulkAddresses || storeBlockTxs {
|
if sa || b.bulkAddressesCount > maxBulkAddresses || storeBlockTxs {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
bac := b.bulkAddressesCount
|
bac := b.bulkAddressesCount
|
||||||
if sa || b.bulkAddressesCount > maxBulkAddresses {
|
if sa || b.bulkAddressesCount > maxBulkAddresses {
|
||||||
@ -333,7 +333,7 @@ func (b *BulkConnect) connectBlockEthereumType(block *bchain.Block, storeBlockTx
|
|||||||
// if there are blockSpecificData, store them
|
// if there are blockSpecificData, store them
|
||||||
blockSpecificData, _ := block.CoinSpecificData.(*bchain.EthereumBlockSpecificData)
|
blockSpecificData, _ := block.CoinSpecificData.(*bchain.EthereumBlockSpecificData)
|
||||||
if blockSpecificData != nil {
|
if blockSpecificData != nil {
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
if err = b.d.storeBlockSpecificDataEthereumType(wb, block); err != nil {
|
if err = b.d.storeBlockSpecificDataEthereumType(wb, block); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -378,7 +378,7 @@ func (b *BulkConnect) Close() error {
|
|||||||
storeAddressContractsChan = make(chan error)
|
storeAddressContractsChan = make(chan error)
|
||||||
go b.parallelStoreAddressContracts(storeAddressContractsChan, true)
|
go b.parallelStoreAddressContracts(storeAddressContractsChan, true)
|
||||||
}
|
}
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
bac := b.bulkAddressesCount
|
bac := b.bulkAddressesCount
|
||||||
if err := b.storeBulkAddresses(wb); err != nil {
|
if err := b.storeBulkAddresses(wb); err != nil {
|
||||||
|
|||||||
@ -2,31 +2,28 @@ package db
|
|||||||
|
|
||||||
// #include "rocksdb/c.h"
|
// #include "rocksdb/c.h"
|
||||||
import "C"
|
import "C"
|
||||||
|
import "github.com/linxGnu/grocksdb"
|
||||||
import (
|
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
possible additional tuning, using options not accessible by gorocksdb
|
possible additional tuning, using options not accessible by grocksdb
|
||||||
|
|
||||||
// #include "rocksdb/c.h"
|
// #include "rocksdb/c.h"
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
cNativeOpts := C.rocksdb_options_create()
|
cNativeOpts := C.rocksdb_options_create()
|
||||||
opts := &gorocksdb.Options{}
|
opts := &grocksdb.Options{}
|
||||||
cField := reflect.Indirect(reflect.ValueOf(opts)).FieldByName("c")
|
cField := reflect.Indirect(reflect.ValueOf(opts)).FieldByName("c")
|
||||||
cPtr := (**C.rocksdb_options_t)(unsafe.Pointer(cField.UnsafeAddr()))
|
cPtr := (**C.rocksdb_options_t)(unsafe.Pointer(cField.UnsafeAddr()))
|
||||||
*cPtr = cNativeOpts
|
*cPtr = cNativeOpts
|
||||||
|
|
||||||
cNativeBlockOpts := C.rocksdb_block_based_options_create()
|
cNativeBlockOpts := C.rocksdb_block_based_options_create()
|
||||||
blockOpts := &gorocksdb.BlockBasedTableOptions{}
|
blockOpts := &grocksdb.BlockBasedTableOptions{}
|
||||||
cBlockField := reflect.Indirect(reflect.ValueOf(blockOpts)).FieldByName("c")
|
cBlockField := reflect.Indirect(reflect.ValueOf(blockOpts)).FieldByName("c")
|
||||||
cBlockPtr := (**C.rocksdb_block_based_table_options_t)(unsafe.Pointer(cBlockField.UnsafeAddr()))
|
cBlockPtr := (**C.rocksdb_block_based_table_options_t)(unsafe.Pointer(cBlockField.UnsafeAddr()))
|
||||||
*cBlockPtr = cNativeBlockOpts
|
*cBlockPtr = cNativeBlockOpts
|
||||||
|
|
||||||
// https://github.com/facebook/rocksdb/wiki/Partitioned-Index-Filters
|
// https://github.com/facebook/rocksdb/wiki/Partitioned-Index-Filters
|
||||||
blockOpts.SetIndexType(gorocksdb.KTwoLevelIndexSearchIndexType)
|
blockOpts.SetIndexType(grocksdb.KTwoLevelIndexSearchIndexType)
|
||||||
C.rocksdb_block_based_options_set_partition_filters(cNativeBlockOpts, boolToChar(true))
|
C.rocksdb_block_based_options_set_partition_filters(cNativeBlockOpts, boolToChar(true))
|
||||||
C.rocksdb_block_based_options_set_metadata_block_size(cNativeBlockOpts, C.uint64_t(4096))
|
C.rocksdb_block_based_options_set_metadata_block_size(cNativeBlockOpts, C.uint64_t(4096))
|
||||||
C.rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority(cNativeBlockOpts, boolToChar(true))
|
C.rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority(cNativeBlockOpts, boolToChar(true))
|
||||||
@ -41,16 +38,16 @@ func boolToChar(b bool) C.uchar {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func createAndSetDBOptions(bloomBits int, c *gorocksdb.Cache, maxOpenFiles int) *gorocksdb.Options {
|
func createAndSetDBOptions(bloomBits int, c *grocksdb.Cache, maxOpenFiles int) *grocksdb.Options {
|
||||||
blockOpts := gorocksdb.NewDefaultBlockBasedTableOptions()
|
blockOpts := grocksdb.NewDefaultBlockBasedTableOptions()
|
||||||
blockOpts.SetBlockSize(32 << 10) // 32kB
|
blockOpts.SetBlockSize(32 << 10) // 32kB
|
||||||
blockOpts.SetBlockCache(c)
|
blockOpts.SetBlockCache(c)
|
||||||
if bloomBits > 0 {
|
if bloomBits > 0 {
|
||||||
blockOpts.SetFilterPolicy(gorocksdb.NewBloomFilter(bloomBits))
|
blockOpts.SetFilterPolicy(grocksdb.NewBloomFilter(float64(bloomBits)))
|
||||||
}
|
}
|
||||||
blockOpts.SetFormatVersion(4)
|
blockOpts.SetFormatVersion(4)
|
||||||
|
|
||||||
opts := gorocksdb.NewDefaultOptions()
|
opts := grocksdb.NewDefaultOptions()
|
||||||
opts.SetBlockBasedTableFactory(blockOpts)
|
opts.SetBlockBasedTableFactory(blockOpts)
|
||||||
opts.SetCreateIfMissing(true)
|
opts.SetCreateIfMissing(true)
|
||||||
opts.SetCreateIfMissingColumnFamilies(true)
|
opts.SetCreateIfMissingColumnFamilies(true)
|
||||||
@ -60,6 +57,6 @@ func createAndSetDBOptions(bloomBits int, c *gorocksdb.Cache, maxOpenFiles int)
|
|||||||
opts.SetWriteBufferSize(1 << 27) // 128MB
|
opts.SetWriteBufferSize(1 << 27) // 128MB
|
||||||
opts.SetMaxBytesForLevelBase(1 << 27) // 128MB
|
opts.SetMaxBytesForLevelBase(1 << 27) // 128MB
|
||||||
opts.SetMaxOpenFiles(maxOpenFiles)
|
opts.SetMaxOpenFiles(maxOpenFiles)
|
||||||
opts.SetCompression(gorocksdb.LZ4HCCompression)
|
opts.SetCompression(grocksdb.LZ4HCCompression)
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
vlq "github.com/bsm/go-vlq"
|
vlq "github.com/bsm/go-vlq"
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FiatRatesTimeFormat is a format string for storing FiatRates timestamps in rocksdb
|
// FiatRatesTimeFormat is a format string for storing FiatRates timestamps in rocksdb
|
||||||
@ -152,7 +152,7 @@ func FiatRatesConvertDate(date string) (*time.Time, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FiatRatesStoreTicker stores ticker data at the specified time
|
// FiatRatesStoreTicker stores ticker data at the specified time
|
||||||
func (d *RocksDB) FiatRatesStoreTicker(wb *gorocksdb.WriteBatch, ticker *CurrencyRatesTicker) error {
|
func (d *RocksDB) FiatRatesStoreTicker(wb *grocksdb.WriteBatch, ticker *CurrencyRatesTicker) error {
|
||||||
if len(ticker.Rates) == 0 {
|
if len(ticker.Rates) == 0 {
|
||||||
return errors.New("Error storing ticker: empty rates")
|
return errors.New("Error storing ticker: empty rates")
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ func isSuitableTicker(ticker *CurrencyRatesTicker, vsCurrency string, token stri
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTickerFromIterator(it *gorocksdb.Iterator, vsCurrency string, token string) (*CurrencyRatesTicker, error) {
|
func getTickerFromIterator(it *grocksdb.Iterator, vsCurrency string, token string) (*CurrencyRatesTicker, error) {
|
||||||
timeObj, err := time.Parse(FiatRatesTimeFormat, string(it.Key().Data()))
|
timeObj, err := time.Parse(FiatRatesTimeFormat, string(it.Key().Data()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/flier/gorocksdb"
|
"github.com/linxGnu/grocksdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRocksTickers(t *testing.T) {
|
func TestRocksTickers(t *testing.T) {
|
||||||
@ -60,7 +60,7 @@ func TestRocksTickers(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
err := d.FiatRatesStoreTicker(wb, ticker1)
|
err := d.FiatRatesStoreTicker(wb, ticker1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -15,9 +15,9 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
vlq "github.com/bsm/go-vlq"
|
vlq "github.com/bsm/go-vlq"
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/trezor/blockbook/bchain"
|
"github.com/trezor/blockbook/bchain"
|
||||||
"github.com/trezor/blockbook/common"
|
"github.com/trezor/blockbook/common"
|
||||||
)
|
)
|
||||||
@ -34,8 +34,8 @@ const refreshIterator = 5000000
|
|||||||
// RepairRocksDB calls RocksDb db repair function
|
// RepairRocksDB calls RocksDb db repair function
|
||||||
func RepairRocksDB(name string) error {
|
func RepairRocksDB(name string) error {
|
||||||
glog.Infof("rocksdb: repair")
|
glog.Infof("rocksdb: repair")
|
||||||
opts := gorocksdb.NewDefaultOptions()
|
opts := grocksdb.NewDefaultOptions()
|
||||||
return gorocksdb.RepairDb(name, opts)
|
return grocksdb.RepairDb(name, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
type connectBlockStats struct {
|
type connectBlockStats struct {
|
||||||
@ -60,14 +60,14 @@ const (
|
|||||||
// RocksDB handle
|
// RocksDB handle
|
||||||
type RocksDB struct {
|
type RocksDB struct {
|
||||||
path string
|
path string
|
||||||
db *gorocksdb.DB
|
db *grocksdb.DB
|
||||||
wo *gorocksdb.WriteOptions
|
wo *grocksdb.WriteOptions
|
||||||
ro *gorocksdb.ReadOptions
|
ro *grocksdb.ReadOptions
|
||||||
cfh []*gorocksdb.ColumnFamilyHandle
|
cfh []*grocksdb.ColumnFamilyHandle
|
||||||
chainParser bchain.BlockChainParser
|
chainParser bchain.BlockChainParser
|
||||||
is *common.InternalState
|
is *common.InternalState
|
||||||
metrics *common.Metrics
|
metrics *common.Metrics
|
||||||
cache *gorocksdb.Cache
|
cache *grocksdb.Cache
|
||||||
maxOpenFiles int
|
maxOpenFiles int
|
||||||
cbs connectBlockStats
|
cbs connectBlockStats
|
||||||
}
|
}
|
||||||
@ -104,20 +104,20 @@ var cfBaseNames = []string{"default", "height", "addresses", "blockTxs", "transa
|
|||||||
var cfNamesBitcoinType = []string{"addressBalance", "txAddresses"}
|
var cfNamesBitcoinType = []string{"addressBalance", "txAddresses"}
|
||||||
var cfNamesEthereumType = []string{"addressContracts", "internalData", "contracts", "functionSignatures", "blockInternalDataErrors", "addressAliases"}
|
var cfNamesEthereumType = []string{"addressContracts", "internalData", "contracts", "functionSignatures", "blockInternalDataErrors", "addressAliases"}
|
||||||
|
|
||||||
func openDB(path string, c *gorocksdb.Cache, openFiles int) (*gorocksdb.DB, []*gorocksdb.ColumnFamilyHandle, error) {
|
func openDB(path string, c *grocksdb.Cache, openFiles int) (*grocksdb.DB, []*grocksdb.ColumnFamilyHandle, error) {
|
||||||
// opts with bloom filter
|
// opts with bloom filter
|
||||||
opts := createAndSetDBOptions(10, c, openFiles)
|
opts := createAndSetDBOptions(10, c, openFiles)
|
||||||
// opts for addresses without bloom filter
|
// opts for addresses without bloom filter
|
||||||
// from documentation: if most of your queries are executed using iterators, you shouldn't set bloom filter
|
// from documentation: if most of your queries are executed using iterators, you shouldn't set bloom filter
|
||||||
optsAddresses := createAndSetDBOptions(0, c, openFiles)
|
optsAddresses := createAndSetDBOptions(0, c, openFiles)
|
||||||
// default, height, addresses, blockTxids, transactions
|
// default, height, addresses, blockTxids, transactions
|
||||||
cfOptions := []*gorocksdb.Options{opts, opts, optsAddresses, opts, opts, opts}
|
cfOptions := []*grocksdb.Options{opts, opts, optsAddresses, opts, opts, opts}
|
||||||
// append type specific options
|
// append type specific options
|
||||||
count := len(cfNames) - len(cfOptions)
|
count := len(cfNames) - len(cfOptions)
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
cfOptions = append(cfOptions, opts)
|
cfOptions = append(cfOptions, opts)
|
||||||
}
|
}
|
||||||
db, cfh, err := gorocksdb.OpenDbColumnFamilies(opts, path, cfNames, cfOptions)
|
db, cfh, err := grocksdb.OpenDbColumnFamilies(opts, path, cfNames, cfOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -139,13 +139,13 @@ func NewRocksDB(path string, cacheSize, maxOpenFiles int, parser bchain.BlockCha
|
|||||||
return nil, errors.New("Unknown chain type")
|
return nil, errors.New("Unknown chain type")
|
||||||
}
|
}
|
||||||
|
|
||||||
c := gorocksdb.NewLRUCache(uint64(cacheSize))
|
c := grocksdb.NewLRUCache(uint64(cacheSize))
|
||||||
db, cfh, err := openDB(path, c, maxOpenFiles)
|
db, cfh, err := openDB(path, c, maxOpenFiles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
wo := gorocksdb.NewDefaultWriteOptions()
|
wo := grocksdb.NewDefaultWriteOptions()
|
||||||
ro := gorocksdb.NewDefaultReadOptions()
|
ro := grocksdb.NewDefaultReadOptions()
|
||||||
return &RocksDB{path, db, wo, ro, cfh, parser, nil, metrics, c, maxOpenFiles, connectBlockStats{}}, nil
|
return &RocksDB{path, db, wo, ro, cfh, parser, nil, metrics, c, maxOpenFiles, connectBlockStats{}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ func atoUint64(s string) uint64 {
|
|||||||
return uint64(i)
|
return uint64(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) WriteBatch(wb *gorocksdb.WriteBatch) error {
|
func (d *RocksDB) WriteBatch(wb *grocksdb.WriteBatch) error {
|
||||||
return d.db.Write(d.wo, wb)
|
return d.db.Write(d.wo, wb)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ const (
|
|||||||
|
|
||||||
// ConnectBlock indexes addresses in the block and stores them in db
|
// ConnectBlock indexes addresses in the block and stores them in db
|
||||||
func (d *RocksDB) ConnectBlock(block *bchain.Block) error {
|
func (d *RocksDB) ConnectBlock(block *bchain.Block) error {
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
|
|
||||||
if glog.V(2) {
|
if glog.V(2) {
|
||||||
@ -740,7 +740,7 @@ func addToAddressesMap(addresses addressesMap, strAddrDesc string, btxID []byte,
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeAddresses(wb *gorocksdb.WriteBatch, height uint32, addresses addressesMap) error {
|
func (d *RocksDB) storeAddresses(wb *grocksdb.WriteBatch, height uint32, addresses addressesMap) error {
|
||||||
for addrDesc, txi := range addresses {
|
for addrDesc, txi := range addresses {
|
||||||
ba := bchain.AddressDescriptor(addrDesc)
|
ba := bchain.AddressDescriptor(addrDesc)
|
||||||
key := packAddressKey(ba, height)
|
key := packAddressKey(ba, height)
|
||||||
@ -750,7 +750,7 @@ func (d *RocksDB) storeAddresses(wb *gorocksdb.WriteBatch, height uint32, addres
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeTxAddresses(wb *gorocksdb.WriteBatch, am map[string]*TxAddresses) error {
|
func (d *RocksDB) storeTxAddresses(wb *grocksdb.WriteBatch, am map[string]*TxAddresses) error {
|
||||||
varBuf := make([]byte, maxPackedBigintBytes)
|
varBuf := make([]byte, maxPackedBigintBytes)
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
for txID, ta := range am {
|
for txID, ta := range am {
|
||||||
@ -760,7 +760,7 @@ func (d *RocksDB) storeTxAddresses(wb *gorocksdb.WriteBatch, am map[string]*TxAd
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeBalances(wb *gorocksdb.WriteBatch, abm map[string]*AddrBalance) error {
|
func (d *RocksDB) storeBalances(wb *grocksdb.WriteBatch, abm map[string]*AddrBalance) error {
|
||||||
// allocate buffer initial buffer
|
// allocate buffer initial buffer
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
varBuf := make([]byte, maxPackedBigintBytes)
|
varBuf := make([]byte, maxPackedBigintBytes)
|
||||||
@ -776,7 +776,7 @@ func (d *RocksDB) storeBalances(wb *gorocksdb.WriteBatch, abm map[string]*AddrBa
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) cleanupBlockTxs(wb *gorocksdb.WriteBatch, block *bchain.Block) error {
|
func (d *RocksDB) cleanupBlockTxs(wb *grocksdb.WriteBatch, block *bchain.Block) error {
|
||||||
keep := d.chainParser.KeepBlockAddresses()
|
keep := d.chainParser.KeepBlockAddresses()
|
||||||
// cleanup old block address
|
// cleanup old block address
|
||||||
if block.Height > uint32(keep) {
|
if block.Height > uint32(keep) {
|
||||||
@ -797,7 +797,7 @@ func (d *RocksDB) cleanupBlockTxs(wb *gorocksdb.WriteBatch, block *bchain.Block)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeAndCleanupBlockTxs(wb *gorocksdb.WriteBatch, block *bchain.Block) error {
|
func (d *RocksDB) storeAndCleanupBlockTxs(wb *grocksdb.WriteBatch, block *bchain.Block) error {
|
||||||
pl := d.chainParser.PackedTxidLen()
|
pl := d.chainParser.PackedTxidLen()
|
||||||
buf := make([]byte, 0, pl*len(block.Txs))
|
buf := make([]byte, 0, pl*len(block.Txs))
|
||||||
varBuf := make([]byte, vlq.MaxLen64)
|
varBuf := make([]byte, vlq.MaxLen64)
|
||||||
@ -1225,7 +1225,7 @@ func (d *RocksDB) GetBlockInfo(height uint32) (*BlockInfo, error) {
|
|||||||
return bi, err
|
return bi, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) writeHeightFromBlock(wb *gorocksdb.WriteBatch, block *bchain.Block, op int) error {
|
func (d *RocksDB) writeHeightFromBlock(wb *grocksdb.WriteBatch, block *bchain.Block, op int) error {
|
||||||
return d.writeHeight(wb, block.Height, &BlockInfo{
|
return d.writeHeight(wb, block.Height, &BlockInfo{
|
||||||
Hash: block.Hash,
|
Hash: block.Hash,
|
||||||
Time: block.Time,
|
Time: block.Time,
|
||||||
@ -1235,7 +1235,7 @@ func (d *RocksDB) writeHeightFromBlock(wb *gorocksdb.WriteBatch, block *bchain.B
|
|||||||
}, op)
|
}, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) writeHeight(wb *gorocksdb.WriteBatch, height uint32, bi *BlockInfo, op int) error {
|
func (d *RocksDB) writeHeight(wb *grocksdb.WriteBatch, height uint32, bi *BlockInfo, op int) error {
|
||||||
key := packUint(height)
|
key := packUint(height)
|
||||||
switch op {
|
switch op {
|
||||||
case opInsert:
|
case opInsert:
|
||||||
@ -1281,7 +1281,7 @@ func (d *RocksDB) GetAddressAlias(address string) string {
|
|||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeAddressAliasRecords(wb *gorocksdb.WriteBatch, records []bchain.AddressAliasRecord) error {
|
func (d *RocksDB) storeAddressAliasRecords(wb *grocksdb.WriteBatch, records []bchain.AddressAliasRecord) error {
|
||||||
if d.chainParser.UseAddressAliases() {
|
if d.chainParser.UseAddressAliases() {
|
||||||
for i := range records {
|
for i := range records {
|
||||||
r := &records[i]
|
r := &records[i]
|
||||||
@ -1298,7 +1298,7 @@ func (d *RocksDB) storeAddressAliasRecords(wb *gorocksdb.WriteBatch, records []b
|
|||||||
|
|
||||||
// Disconnect blocks
|
// Disconnect blocks
|
||||||
|
|
||||||
func (d *RocksDB) disconnectTxAddressesInputs(wb *gorocksdb.WriteBatch, btxID []byte, inputs []outpoint, txa *TxAddresses, txAddressesToUpdate map[string]*TxAddresses,
|
func (d *RocksDB) disconnectTxAddressesInputs(wb *grocksdb.WriteBatch, btxID []byte, inputs []outpoint, txa *TxAddresses, txAddressesToUpdate map[string]*TxAddresses,
|
||||||
getAddressBalance func(addrDesc bchain.AddressDescriptor) (*AddrBalance, error),
|
getAddressBalance func(addrDesc bchain.AddressDescriptor) (*AddrBalance, error),
|
||||||
addressFoundInTx func(addrDesc bchain.AddressDescriptor, btxID []byte) bool) error {
|
addressFoundInTx func(addrDesc bchain.AddressDescriptor, btxID []byte) bool) error {
|
||||||
var err error
|
var err error
|
||||||
@ -1354,7 +1354,7 @@ func (d *RocksDB) disconnectTxAddressesInputs(wb *gorocksdb.WriteBatch, btxID []
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) disconnectTxAddressesOutputs(wb *gorocksdb.WriteBatch, btxID []byte, txa *TxAddresses,
|
func (d *RocksDB) disconnectTxAddressesOutputs(wb *grocksdb.WriteBatch, btxID []byte, txa *TxAddresses,
|
||||||
getAddressBalance func(addrDesc bchain.AddressDescriptor) (*AddrBalance, error),
|
getAddressBalance func(addrDesc bchain.AddressDescriptor) (*AddrBalance, error),
|
||||||
addressFoundInTx func(addrDesc bchain.AddressDescriptor, btxID []byte) bool) error {
|
addressFoundInTx func(addrDesc bchain.AddressDescriptor, btxID []byte) bool) error {
|
||||||
for i, t := range txa.Outputs {
|
for i, t := range txa.Outputs {
|
||||||
@ -1386,7 +1386,7 @@ func (d *RocksDB) disconnectTxAddressesOutputs(wb *gorocksdb.WriteBatch, btxID [
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) disconnectBlock(height uint32, blockTxs []blockTxs) error {
|
func (d *RocksDB) disconnectBlock(height uint32, blockTxs []blockTxs) error {
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
txAddressesToUpdate := make(map[string]*TxAddresses)
|
txAddressesToUpdate := make(map[string]*TxAddresses)
|
||||||
txAddresses := make([]*TxAddresses, len(blockTxs))
|
txAddresses := make([]*TxAddresses, len(blockTxs))
|
||||||
@ -1498,7 +1498,7 @@ func (d *RocksDB) DisconnectBlockRangeBitcoinType(lower uint32, higher uint32) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeBalancesDisconnect(wb *gorocksdb.WriteBatch, balances map[string]*AddrBalance) {
|
func (d *RocksDB) storeBalancesDisconnect(wb *grocksdb.WriteBatch, balances map[string]*AddrBalance) {
|
||||||
for _, b := range balances {
|
for _, b := range balances {
|
||||||
if b != nil {
|
if b != nil {
|
||||||
// remove spent utxos
|
// remove spent utxos
|
||||||
@ -1584,14 +1584,14 @@ func (d *RocksDB) DeleteTx(txid string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// use write batch so that this delete matches other deletes
|
// use write batch so that this delete matches other deletes
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
d.internalDeleteTx(wb, key)
|
d.internalDeleteTx(wb, key)
|
||||||
return d.WriteBatch(wb)
|
return d.WriteBatch(wb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// internalDeleteTx checks if tx is cached and updates internal state accordingly
|
// internalDeleteTx checks if tx is cached and updates internal state accordingly
|
||||||
func (d *RocksDB) internalDeleteTx(wb *gorocksdb.WriteBatch, key []byte) {
|
func (d *RocksDB) internalDeleteTx(wb *grocksdb.WriteBatch, key []byte) {
|
||||||
val, err := d.db.GetCF(d.ro, d.cfh[cfTransactions], key)
|
val, err := d.db.GetCF(d.ro, d.cfh[cfTransactions], key)
|
||||||
// ignore error, it is only for statistics
|
// ignore error, it is only for statistics
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -1745,7 +1745,7 @@ func (d *RocksDB) computeColumnSize(col int, stopCompute chan os.Signal) (int64,
|
|||||||
var rows, keysSum, valuesSum int64
|
var rows, keysSum, valuesSum int64
|
||||||
var seekKey []byte
|
var seekKey []byte
|
||||||
// do not use cache
|
// do not use cache
|
||||||
ro := gorocksdb.NewDefaultReadOptions()
|
ro := grocksdb.NewDefaultReadOptions()
|
||||||
ro.SetFillCache(false)
|
ro.SetFillCache(false)
|
||||||
for {
|
for {
|
||||||
var key []byte
|
var key []byte
|
||||||
@ -1890,7 +1890,7 @@ func (d *RocksDB) fixUtxo(addrDesc bchain.AddressDescriptor, ba *AddrBalance) (b
|
|||||||
utxos[i], utxos[opp] = utxos[opp], utxos[i]
|
utxos[i], utxos[opp] = utxos[opp], utxos[i]
|
||||||
}
|
}
|
||||||
ba.Utxos = utxos
|
ba.Utxos = utxos
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
err = d.storeBalances(wb, map[string]*AddrBalance{string(addrDesc): ba})
|
err = d.storeBalances(wb, map[string]*AddrBalance{string(addrDesc): ba})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = d.WriteBatch(wb)
|
err = d.WriteBatch(wb)
|
||||||
@ -1903,7 +1903,7 @@ func (d *RocksDB) fixUtxo(addrDesc bchain.AddressDescriptor, ba *AddrBalance) (b
|
|||||||
}
|
}
|
||||||
return fixed, false, errors.Errorf("balance %s, checksum %s, from txa %s, txs %d", ba.BalanceSat.String(), checksum.String(), checksumFromTxs.String(), ba.Txs)
|
return fixed, false, errors.Errorf("balance %s, checksum %s, from txa %s, txs %d", ba.BalanceSat.String(), checksum.String(), checksumFromTxs.String(), ba.Txs)
|
||||||
} else if reorder {
|
} else if reorder {
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
err := d.storeBalances(wb, map[string]*AddrBalance{string(addrDesc): ba})
|
err := d.storeBalances(wb, map[string]*AddrBalance{string(addrDesc): ba})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = d.WriteBatch(wb)
|
err = d.WriteBatch(wb)
|
||||||
@ -1926,7 +1926,7 @@ func (d *RocksDB) FixUtxos(stop chan os.Signal) error {
|
|||||||
var row, errorsCount, fixedCount int64
|
var row, errorsCount, fixedCount int64
|
||||||
var seekKey []byte
|
var seekKey []byte
|
||||||
// do not use cache
|
// do not use cache
|
||||||
ro := gorocksdb.NewDefaultReadOptions()
|
ro := grocksdb.NewDefaultReadOptions()
|
||||||
ro.SetFillCache(false)
|
ro.SetFillCache(false)
|
||||||
for {
|
for {
|
||||||
var addrDesc bchain.AddressDescriptor
|
var addrDesc bchain.AddressDescriptor
|
||||||
|
|||||||
@ -7,9 +7,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
vlq "github.com/bsm/go-vlq"
|
vlq "github.com/bsm/go-vlq"
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/trezor/blockbook/bchain"
|
"github.com/trezor/blockbook/bchain"
|
||||||
"github.com/trezor/blockbook/bchain/coins/eth"
|
"github.com/trezor/blockbook/bchain/coins/eth"
|
||||||
)
|
)
|
||||||
@ -131,7 +131,7 @@ func unpackAddrContracts(buf []byte, addrDesc bchain.AddressDescriptor) (*AddrCo
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeAddressContracts(wb *gorocksdb.WriteBatch, acm map[string]*AddrContracts) error {
|
func (d *RocksDB) storeAddressContracts(wb *grocksdb.WriteBatch, acm map[string]*AddrContracts) error {
|
||||||
for addrDesc, acs := range acm {
|
for addrDesc, acs := range acm {
|
||||||
// address with 0 contracts is removed from db - happens on disconnect
|
// address with 0 contracts is removed from db - happens on disconnect
|
||||||
if acs == nil || (acs.NonContractTxs == 0 && acs.InternalTxs == 0 && len(acs.Contracts) == 0) {
|
if acs == nil || (acs.NonContractTxs == 0 && acs.InternalTxs == 0 && len(acs.Contracts) == 0) {
|
||||||
@ -659,7 +659,7 @@ func (d *RocksDB) GetFourByteSignatures(fourBytes uint32) (*[]bchain.FourByteSig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StoreFourByteSignature stores 4byte signature in DB
|
// StoreFourByteSignature stores 4byte signature in DB
|
||||||
func (d *RocksDB) StoreFourByteSignature(wb *gorocksdb.WriteBatch, fourBytes uint32, id uint32, signature *bchain.FourByteSignature) error {
|
func (d *RocksDB) StoreFourByteSignature(wb *grocksdb.WriteBatch, fourBytes uint32, id uint32, signature *bchain.FourByteSignature) error {
|
||||||
key := packFourByteKey(fourBytes, id)
|
key := packFourByteKey(fourBytes, id)
|
||||||
wb.PutCF(d.cfh[cfFunctionSignatures], key, packFourByteSignature(signature))
|
wb.PutCF(d.cfh[cfFunctionSignatures], key, packFourByteSignature(signature))
|
||||||
cachedByteSignaturesMux.Lock()
|
cachedByteSignaturesMux.Lock()
|
||||||
@ -690,7 +690,7 @@ func (d *RocksDB) getEthereumInternalData(btxID []byte) (*bchain.EthereumInterna
|
|||||||
return d.unpackEthInternalData(buf)
|
return d.unpackEthInternalData(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeInternalDataEthereumType(wb *gorocksdb.WriteBatch, blockTxs []ethBlockTx) error {
|
func (d *RocksDB) storeInternalDataEthereumType(wb *grocksdb.WriteBatch, blockTxs []ethBlockTx) error {
|
||||||
for i := range blockTxs {
|
for i := range blockTxs {
|
||||||
blockTx := &blockTxs[i]
|
blockTx := &blockTxs[i]
|
||||||
if blockTx.internalData != nil {
|
if blockTx.internalData != nil {
|
||||||
@ -785,7 +785,7 @@ func (d *RocksDB) GetContractInfo(contract bchain.AddressDescriptor, typeFromCon
|
|||||||
// StoreContractInfo stores contractInfo in DB
|
// StoreContractInfo stores contractInfo in DB
|
||||||
// if CreatedInBlock==0 and DestructedInBlock!=0, it is evaluated as a desctruction of a contract, the contract info is updated
|
// if CreatedInBlock==0 and DestructedInBlock!=0, it is evaluated as a desctruction of a contract, the contract info is updated
|
||||||
// in all other cases the contractInfo overwrites previously stored data in DB (however it should not really happen as contract is created only once)
|
// in all other cases the contractInfo overwrites previously stored data in DB (however it should not really happen as contract is created only once)
|
||||||
func (d *RocksDB) StoreContractInfo(wb *gorocksdb.WriteBatch, contractInfo *bchain.ContractInfo) error {
|
func (d *RocksDB) StoreContractInfo(wb *grocksdb.WriteBatch, contractInfo *bchain.ContractInfo) error {
|
||||||
if contractInfo.Contract != "" {
|
if contractInfo.Contract != "" {
|
||||||
key, err := d.chainParser.GetAddrDescFromAddress(contractInfo.Contract)
|
key, err := d.chainParser.GetAddrDescFromAddress(contractInfo.Contract)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -840,7 +840,7 @@ func packBlockTx(buf []byte, blockTx *ethBlockTx) []byte {
|
|||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeAndCleanupBlockTxsEthereumType(wb *gorocksdb.WriteBatch, block *bchain.Block, blockTxs []ethBlockTx) error {
|
func (d *RocksDB) storeAndCleanupBlockTxsEthereumType(wb *grocksdb.WriteBatch, block *bchain.Block, blockTxs []ethBlockTx) error {
|
||||||
pl := d.chainParser.PackedTxidLen()
|
pl := d.chainParser.PackedTxidLen()
|
||||||
buf := make([]byte, 0, (pl+2*eth.EthereumTypeAddressDescriptorLen)*len(blockTxs))
|
buf := make([]byte, 0, (pl+2*eth.EthereumTypeAddressDescriptorLen)*len(blockTxs))
|
||||||
for i := range blockTxs {
|
for i := range blockTxs {
|
||||||
@ -851,7 +851,7 @@ func (d *RocksDB) storeAndCleanupBlockTxsEthereumType(wb *gorocksdb.WriteBatch,
|
|||||||
return d.cleanupBlockTxs(wb, block)
|
return d.cleanupBlockTxs(wb, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeBlockInternalDataErrorEthereumType(wb *gorocksdb.WriteBatch, block *bchain.Block, message string) error {
|
func (d *RocksDB) storeBlockInternalDataErrorEthereumType(wb *grocksdb.WriteBatch, block *bchain.Block, message string) error {
|
||||||
key := packUint(block.Height)
|
key := packUint(block.Height)
|
||||||
txid, err := d.chainParser.PackTxid(block.Hash)
|
txid, err := d.chainParser.PackTxid(block.Hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -867,7 +867,7 @@ func (d *RocksDB) storeBlockInternalDataErrorEthereumType(wb *gorocksdb.WriteBat
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) storeBlockSpecificDataEthereumType(wb *gorocksdb.WriteBatch, block *bchain.Block) error {
|
func (d *RocksDB) storeBlockSpecificDataEthereumType(wb *grocksdb.WriteBatch, block *bchain.Block) error {
|
||||||
blockSpecificData, _ := block.CoinSpecificData.(*bchain.EthereumBlockSpecificData)
|
blockSpecificData, _ := block.CoinSpecificData.(*bchain.EthereumBlockSpecificData)
|
||||||
if blockSpecificData != nil {
|
if blockSpecificData != nil {
|
||||||
if blockSpecificData.InternalDataError != "" {
|
if blockSpecificData.InternalDataError != "" {
|
||||||
@ -1112,7 +1112,7 @@ func (d *RocksDB) disconnectInternalData(btxID []byte, addresses map[string]map[
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RocksDB) disconnectBlockTxsEthereumType(wb *gorocksdb.WriteBatch, height uint32, blockTxs []ethBlockTx, contracts map[string]*AddrContracts) error {
|
func (d *RocksDB) disconnectBlockTxsEthereumType(wb *grocksdb.WriteBatch, height uint32, blockTxs []ethBlockTx, contracts map[string]*AddrContracts) error {
|
||||||
glog.Info("Disconnecting block ", height, " containing ", len(blockTxs), " transactions")
|
glog.Info("Disconnecting block ", height, " containing ", len(blockTxs), " transactions")
|
||||||
addresses := make(map[string]map[string]struct{})
|
addresses := make(map[string]map[string]struct{})
|
||||||
for i := range blockTxs {
|
for i := range blockTxs {
|
||||||
@ -1169,7 +1169,7 @@ func (d *RocksDB) DisconnectBlockRangeEthereumType(lower uint32, higher uint32)
|
|||||||
}
|
}
|
||||||
blocks[height-lower] = blockTxs
|
blocks[height-lower] = blockTxs
|
||||||
}
|
}
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
contracts := make(map[string]*AddrContracts)
|
contracts := make(map[string]*AddrContracts)
|
||||||
for height := higher; height >= lower; height-- {
|
for height := higher; height >= lower; height-- {
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/trezor/blockbook/bchain"
|
"github.com/trezor/blockbook/bchain"
|
||||||
"github.com/trezor/blockbook/bchain/coins/eth"
|
"github.com/trezor/blockbook/bchain/coins/eth"
|
||||||
"github.com/trezor/blockbook/common"
|
"github.com/trezor/blockbook/common"
|
||||||
@ -359,7 +359,7 @@ func testFourByteSignature(t *testing.T, d *RocksDB) {
|
|||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
Parameters: []string{"address", "(bytes,uint256[],uint256)", "uint16"},
|
Parameters: []string{"address", "(bytes,uint256[],uint256)", "uint16"},
|
||||||
}
|
}
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
if err := d.StoreFourByteSignature(wb, fourBytes, id, &signature); err != nil {
|
if err := d.StoreFourByteSignature(wb, fourBytes, id, &signature); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
@ -78,7 +78,7 @@ There are few variables that can be passed to `make` in order to modify build pr
|
|||||||
|
|
||||||
`BASE_IMAGE`: Specifies the base image of the Docker build image. By default, it chooses the same Linux distro as the host machine but you can override it this way `make BASE_IMAGE=debian:10 all-bitcoin` to make a build for Debian 10.
|
`BASE_IMAGE`: Specifies the base image of the Docker build image. By default, it chooses the same Linux distro as the host machine but you can override it this way `make BASE_IMAGE=debian:10 all-bitcoin` to make a build for Debian 10.
|
||||||
|
|
||||||
*Please be aware that we are running our Blockbooks on Debian 9 and Debian 10 and do not offer support with running it on other distros.*
|
*Please be aware that we are currently running our Blockbooks on Debian 11 and do not offer support with running it on other distros.*
|
||||||
|
|
||||||
`NO_CACHE`: Common behaviour of Docker image build is that build steps are cached and next time they are executed much faster.
|
`NO_CACHE`: Common behaviour of Docker image build is that build steps are cached and next time they are executed much faster.
|
||||||
Although this is a good idea, when something went wrong you will need to override this behaviour somehow. Execute this
|
Although this is a good idea, when something went wrong you will need to override this behaviour somehow. Execute this
|
||||||
@ -185,13 +185,13 @@ Configuration is described in [config.md](/docs/config.md).
|
|||||||
|
|
||||||
## Manual build
|
## Manual build
|
||||||
|
|
||||||
Instructions below are focused on Debian 9 (Stretch) and 10 (Buster). If you want to use another Linux distribution or operating system
|
Instructions below are focused on Debian 11 on amd64. If you want to use another Linux distribution or operating system
|
||||||
like macOS or Windows, please read instructions specific for each project.
|
like macOS or Windows, please adapt the instructions to your target system.
|
||||||
|
|
||||||
Setup go environment (use newer version of go as available)
|
Setup go environment (use newer version of go as available)
|
||||||
|
|
||||||
```
|
```
|
||||||
wget https://golang.org/dl/go1.17.1.linux-amd64.tar.gz && tar xf go1.17.1.linux-amd64.tar.gz
|
wget https://golang.org/dl/go1.19.linux-amd64.tar.gz && tar xf go1.19.linux-amd64.tar.gz
|
||||||
sudo mv go /opt/go
|
sudo mv go /opt/go
|
||||||
sudo ln -s /opt/go/bin/go /usr/bin/go
|
sudo ln -s /opt/go/bin/go /usr/bin/go
|
||||||
# see `go help gopath` for details
|
# see `go help gopath` for details
|
||||||
@ -206,18 +206,18 @@ make command to create a portable binary.
|
|||||||
|
|
||||||
```
|
```
|
||||||
sudo apt-get update && sudo apt-get install -y \
|
sudo apt-get update && sudo apt-get install -y \
|
||||||
build-essential git wget pkg-config libzmq3-dev libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev
|
build-essential git wget pkg-config libzmq3-dev libgflags-dev libsnappy-dev zlib1g-dev libzstd-dev libbz2-dev liblz4-dev
|
||||||
git clone https://github.com/facebook/rocksdb.git
|
git clone https://github.com/facebook/rocksdb.git
|
||||||
cd rocksdb
|
cd rocksdb
|
||||||
git checkout v6.22.1
|
git checkout v7.5.3
|
||||||
CFLAGS=-fPIC CXXFLAGS=-fPIC make release
|
CFLAGS=-fPIC CXXFLAGS=-fPIC make release
|
||||||
```
|
```
|
||||||
|
|
||||||
Setup variables for gorocksdb
|
Setup variables for grocksdb
|
||||||
|
|
||||||
```
|
```
|
||||||
export CGO_CFLAGS="-I/path/to/rocksdb/include"
|
export CGO_CFLAGS="-I/path/to/rocksdb/include"
|
||||||
export CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -ldl -lbz2 -lsnappy -llz4"
|
export CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -ldl -lbz2 -lsnappy -llz4 -lzstd"
|
||||||
```
|
```
|
||||||
|
|
||||||
Install ZeroMQ: https://github.com/zeromq/libzmq
|
Install ZeroMQ: https://github.com/zeromq/libzmq
|
||||||
@ -237,7 +237,7 @@ Get blockbook sources, install dependencies, build:
|
|||||||
cd $GOPATH/src
|
cd $GOPATH/src
|
||||||
git clone https://github.com/trezor/blockbook.git
|
git clone https://github.com/trezor/blockbook.git
|
||||||
cd blockbook
|
cd blockbook
|
||||||
go build -tags rocksdb_6_16
|
go build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example command
|
### Example command
|
||||||
|
|||||||
@ -10,8 +10,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/trezor/blockbook/db"
|
"github.com/trezor/blockbook/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ func (cg *Coingecko) getHistoricalTicker(tickersToUpdate map[uint]*db.CurrencyRa
|
|||||||
|
|
||||||
func (cg *Coingecko) storeTickers(tickersToUpdate map[uint]*db.CurrencyRatesTicker) error {
|
func (cg *Coingecko) storeTickers(tickersToUpdate map[uint]*db.CurrencyRatesTicker) error {
|
||||||
if len(tickersToUpdate) > 0 {
|
if len(tickersToUpdate) > 0 {
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
for _, v := range tickersToUpdate {
|
for _, v := range tickersToUpdate {
|
||||||
if err := cg.db.FiatRatesStoreTicker(wb, v); err != nil {
|
if err := cg.db.FiatRatesStoreTicker(wb, v); err != nil {
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/trezor/blockbook/bchain"
|
"github.com/trezor/blockbook/bchain"
|
||||||
"github.com/trezor/blockbook/db"
|
"github.com/trezor/blockbook/db"
|
||||||
)
|
)
|
||||||
@ -173,7 +173,7 @@ func (fd *FourByteSignaturesDownloader) downloadSignatures() {
|
|||||||
}
|
}
|
||||||
if len(results) > 0 {
|
if len(results) > 0 {
|
||||||
glog.Infof("FourByteSignaturesDownloader storing %d new signatures", len(results))
|
glog.Infof("FourByteSignaturesDownloader storing %d new signatures", len(results))
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
|
|
||||||
for i := range results {
|
for i := range results {
|
||||||
|
|||||||
9
go.mod
9
go.mod
@ -15,16 +15,13 @@ require (
|
|||||||
github.com/decred/dcrd/hdkeychain/v3 v3.0.0
|
github.com/decred/dcrd/hdkeychain/v3 v3.0.0
|
||||||
github.com/decred/dcrd/txscript/v3 v3.0.0
|
github.com/decred/dcrd/txscript/v3 v3.0.0
|
||||||
github.com/ethereum/go-ethereum v1.10.15
|
github.com/ethereum/go-ethereum v1.10.15
|
||||||
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
|
|
||||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
|
|
||||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
|
|
||||||
github.com/flier/gorocksdb v0.0.0-20210322035443-567cc51a1652
|
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||||
github.com/golang/protobuf v1.5.0
|
github.com/golang/protobuf v1.5.0
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/juju/errors v0.0.0-20170703010042-c7d06af17c68
|
github.com/juju/errors v0.0.0-20170703010042-c7d06af17c68
|
||||||
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
|
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
|
||||||
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b // indirect
|
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b // indirect
|
||||||
|
github.com/linxGnu/grocksdb v1.7.7
|
||||||
github.com/martinboehm/bchutil v0.0.0-20190104112650-6373f11b6efe
|
github.com/martinboehm/bchutil v0.0.0-20190104112650-6373f11b6efe
|
||||||
github.com/martinboehm/btcd v0.0.0-20221101112928-408689e15809
|
github.com/martinboehm/btcd v0.0.0-20221101112928-408689e15809
|
||||||
github.com/martinboehm/btcutil v0.0.0-20211010173611-6ef1889c1819
|
github.com/martinboehm/btcutil v0.0.0-20211010173611-6ef1889c1819
|
||||||
@ -48,6 +45,7 @@ require (
|
|||||||
github.com/btcsuite/btcd v0.20.1-beta // indirect
|
github.com/btcsuite/btcd v0.20.1-beta // indirect
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dchest/siphash v1.2.1 // indirect
|
github.com/dchest/siphash v1.2.1 // indirect
|
||||||
github.com/decred/base58 v1.0.3 // indirect
|
github.com/decred/base58 v1.0.3 // indirect
|
||||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
|
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
|
||||||
@ -59,14 +57,17 @@ require (
|
|||||||
github.com/go-ole/go-ole v1.2.1 // indirect
|
github.com/go-ole/go-ole v1.2.1 // indirect
|
||||||
github.com/go-stack/stack v1.8.0 // indirect
|
github.com/go-stack/stack v1.8.0 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/prometheus/client_model v0.2.0 // indirect
|
github.com/prometheus/client_model v0.2.0 // indirect
|
||||||
github.com/prometheus/common v0.14.0 // indirect
|
github.com/prometheus/common v0.14.0 // indirect
|
||||||
github.com/prometheus/procfs v0.2.0 // indirect
|
github.com/prometheus/procfs v0.2.0 // indirect
|
||||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
||||||
|
github.com/stretchr/testify v1.8.0 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.5 // indirect
|
github.com/tklauser/go-sysconf v0.3.5 // indirect
|
||||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||||
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 // indirect
|
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 // indirect
|
||||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
// replace github.com/martinboehm/btcutil => ../btcutil
|
// replace github.com/martinboehm/btcutil => ../btcutil
|
||||||
|
|||||||
18
go.sum
18
go.sum
@ -189,17 +189,9 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
|
|||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/ethereum/go-ethereum v1.10.15 h1:E9o0kMbD8HXhp7g6UwIwntY05WTDheCGziMhegcBsQw=
|
github.com/ethereum/go-ethereum v1.10.15 h1:E9o0kMbD8HXhp7g6UwIwntY05WTDheCGziMhegcBsQw=
|
||||||
github.com/ethereum/go-ethereum v1.10.15/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw=
|
github.com/ethereum/go-ethereum v1.10.15/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw=
|
||||||
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
|
|
||||||
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
|
|
||||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
|
|
||||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
|
|
||||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
|
|
||||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
|
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
|
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
|
||||||
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
|
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
|
||||||
github.com/flier/gorocksdb v0.0.0-20210322035443-567cc51a1652 h1:8GVjZ8n6qgX3b/0aklxpNar3RLkvS6G7FZcHkiHDUHs=
|
|
||||||
github.com/flier/gorocksdb v0.0.0-20210322035443-567cc51a1652/go.mod h1:CzkODoa0BVoE4x+tw0Pd0MOyGN/u4ip7M06gXTI7htQ=
|
|
||||||
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
||||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||||
@ -402,6 +394,8 @@ github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2
|
|||||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||||
|
github.com/linxGnu/grocksdb v1.7.7 h1:b6o8gagb4FL+P55qUzPchBR/C0u1lWjJOWQSWbhvTWg=
|
||||||
|
github.com/linxGnu/grocksdb v1.7.7/go.mod h1:0hTf+iA+GOr0jDX4CgIYyJZxqOH9XlBh6KVj8+zmF34=
|
||||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
@ -592,13 +586,16 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3
|
|||||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||||
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
@ -909,8 +906,9 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/trezor/blockbook/bchain"
|
"github.com/trezor/blockbook/bchain"
|
||||||
"github.com/trezor/blockbook/bchain/coins/eth"
|
"github.com/trezor/blockbook/bchain/coins/eth"
|
||||||
"github.com/trezor/blockbook/db"
|
"github.com/trezor/blockbook/db"
|
||||||
@ -128,7 +128,7 @@ func httpTestsEthereumType(t *testing.T, ts *httptest.Server) {
|
|||||||
|
|
||||||
func initEthereumTypeDB(d *db.RocksDB) error {
|
func initEthereumTypeDB(d *db.RocksDB) error {
|
||||||
// add 0xa9059cbb transfer(address,uint256) signature
|
// add 0xa9059cbb transfer(address,uint256) signature
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
if err := d.StoreFourByteSignature(wb, 2835717307, 145, &bchain.FourByteSignature{
|
if err := d.StoreFourByteSignature(wb, 2835717307, 145, &bchain.FourByteSignature{
|
||||||
Name: "transfer",
|
Name: "transfer",
|
||||||
|
|||||||
@ -14,9 +14,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/flier/gorocksdb"
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
"github.com/linxGnu/grocksdb"
|
||||||
"github.com/martinboehm/btcutil/chaincfg"
|
"github.com/martinboehm/btcutil/chaincfg"
|
||||||
gosocketio "github.com/martinboehm/golang-socketio"
|
gosocketio "github.com/martinboehm/golang-socketio"
|
||||||
"github.com/martinboehm/golang-socketio/transport"
|
"github.com/martinboehm/golang-socketio/transport"
|
||||||
@ -176,7 +176,7 @@ func insertFiatRate(date string, rates map[string]float32, tokenRates map[string
|
|||||||
Rates: rates,
|
Rates: rates,
|
||||||
TokenRates: tokenRates,
|
TokenRates: tokenRates,
|
||||||
}
|
}
|
||||||
wb := gorocksdb.NewWriteBatch()
|
wb := grocksdb.NewWriteBatch()
|
||||||
defer wb.Destroy()
|
defer wb.Destroy()
|
||||||
if err := d.FiatRatesStoreTicker(wb, ticker); err != nil {
|
if err := d.FiatRatesStoreTicker(wb, ticker); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user