Compare commits
1 Commits
deepcrayon
...
fiatRates
Author | SHA1 | Date |
---|---|---|
Martin Boehm | b4db9de260 |
|
@ -55,8 +55,8 @@ type Configuration struct {
|
|||
XPubMagicSegwitP2sh uint32 `json:"xpub_magic_segwit_p2sh,omitempty"`
|
||||
XPubMagicSegwitNative uint32 `json:"xpub_magic_segwit_native,omitempty"`
|
||||
Slip44 uint32 `json:"slip44,omitempty"`
|
||||
AlternativeEstimateFee string `json:"alternativeEstimateFee,omitempty"`
|
||||
AlternativeEstimateFeeParams string `json:"alternativeEstimateFeeParams,omitempty"`
|
||||
AlternativeEstimateFee string `json:"alternative_estimate_fee,omitempty"`
|
||||
AlternativeEstimateFeeParams string `json:"alternative_estimate_fee_params,omitempty"`
|
||||
MinimumCoinbaseConfirmations int `json:"minimumCoinbaseConfirmations,omitempty"`
|
||||
}
|
||||
|
||||
|
|
24
blockbook.go
24
blockbook.go
|
@ -8,7 +8,9 @@ import (
|
|||
"blockbook/db"
|
||||
"blockbook/server"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
@ -317,6 +319,8 @@ func mainWithExitCode() int {
|
|||
}
|
||||
|
||||
if internalServer != nil || publicServer != nil || chain != nil {
|
||||
// start fiat rates downloader only if not shutting down immediately
|
||||
initFiatRatesDownloader(*blockchain)
|
||||
waitForSignalAndShutdown(internalServer, publicServer, chain, 10*time.Second)
|
||||
}
|
||||
|
||||
|
@ -650,3 +654,23 @@ func computeFeeStats(stopCompute chan os.Signal, blockFrom, blockTo int, db *db.
|
|||
glog.Info("computeFeeStats finished in ", time.Since(start))
|
||||
return err
|
||||
}
|
||||
|
||||
func initFiatRatesDownloader(configfile string) {
|
||||
data, err := ioutil.ReadFile(configfile)
|
||||
if err != nil {
|
||||
glog.Errorf("Error reading file %v, %v", configfile, err)
|
||||
return
|
||||
}
|
||||
var config struct {
|
||||
FiatRates string `json:"fiat_rates"`
|
||||
FiatRatesParams string `json:"fiat_rates_params"`
|
||||
}
|
||||
err = json.Unmarshal(data, &config)
|
||||
if err != nil {
|
||||
glog.Errorf("Error parsing file %v, %v", configfile, err)
|
||||
}
|
||||
if config.FiatRates == "coingecko" {
|
||||
// coingecko:=fiat.NewCoingeckoDownloader(config.FiatRatesParams)
|
||||
// go coingecko.Run()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,10 @@
|
|||
"xpub_magic_segwit_p2sh": 77429938,
|
||||
"xpub_magic_segwit_native": 78792518,
|
||||
"additional_params": {
|
||||
"alternativeEstimateFee": "whatthefee-disabled",
|
||||
"alternativeEstimateFeeParams": "{\"url\": \"https://whatthefee.io/data.json\", \"periodSeconds\": 60}"
|
||||
"alternative_estimate_fee": "whatthefee-disabled",
|
||||
"alternative_estimate_fee_params": "{\"url\": \"https://whatthefee.io/data.json\", \"periodSeconds\": 60}",
|
||||
"fiat_rates": "coingecko",
|
||||
"fiat_rates_params": "{\"coin\": \"bitcoin\", \"periodSeconds\": 60}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -77,6 +77,7 @@ const (
|
|||
cfAddresses
|
||||
cfBlockTxs
|
||||
cfTransactions
|
||||
cfFiatRates
|
||||
// BitcoinType
|
||||
cfAddressBalance
|
||||
cfTxAddresses
|
||||
|
@ -86,7 +87,7 @@ const (
|
|||
|
||||
// common columns
|
||||
var cfNames []string
|
||||
var cfBaseNames = []string{"default", "height", "addresses", "blockTxs", "transactions"}
|
||||
var cfBaseNames = []string{"default", "height", "addresses", "blockTxs", "transactions", "fiatRates"}
|
||||
|
||||
// type specific columns
|
||||
var cfNamesBitcoinType = []string{"addressBalance", "txAddresses"}
|
||||
|
@ -99,7 +100,7 @@ func openDB(path string, c *gorocksdb.Cache, openFiles int) (*gorocksdb.DB, []*g
|
|||
// from documentation: if most of your queries are executed using iterators, you shouldn't set bloom filter
|
||||
optsAddresses := createAndSetDBOptions(0, c, openFiles)
|
||||
// default, height, addresses, blockTxids, transactions
|
||||
cfOptions := []*gorocksdb.Options{opts, opts, optsAddresses, opts, opts}
|
||||
cfOptions := []*gorocksdb.Options{opts, opts, optsAddresses, opts, opts, opts}
|
||||
// append type specific options
|
||||
count := len(cfNames) - len(cfOptions)
|
||||
for i := 0; i < count; i++ {
|
||||
|
|
Loading…
Reference in New Issue