mirror of
https://github.com/Retropex/bitfeed.git
synced 2025-05-12 19:20:46 +02:00
Make rocksdb dependency optional
This commit is contained in:
parent
79145d653c
commit
0a35207dd7
@ -575,7 +575,7 @@
|
||||
{/if}
|
||||
|
||||
{#if $loading}
|
||||
<div class="loading-overlay" in:fade={{ delay: 500, duration: 500 }} out:fade={{ duration: 200 }}>
|
||||
<div class="loading-overlay" in:fade={{ delay: 1000, duration: 500 }} out:fade={{ duration: 200 }}>
|
||||
<div class="loading-wrapper">
|
||||
<LoadingAnimation />
|
||||
<p class="loading-msg">loading</p>
|
||||
|
@ -11,6 +11,30 @@
|
||||
|
||||
#### Installation
|
||||
|
||||
Set the `MIX_TARGET` environment variable to choose a build target (defaults to "personal")
|
||||
|
||||
"personal" - tailored to low traffic personal deployments. resource-intensive features & dependencies disabled
|
||||
|
||||
```shell
|
||||
export MIX_TARGET=personal
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
"public" - tailored to high traffic, high performance public deployments.
|
||||
|
||||
```shell
|
||||
export MIX_TARGET=public
|
||||
```
|
||||
|
||||
✅❌
|
||||
|
||||
| feature | "public" | "personal" |
|
||||
|---|---|---|
|
||||
| Spend index | ✅ | ❌ |
|
||||
|
||||
|
||||
|
||||
```shell
|
||||
mix do deps.get
|
||||
mix do deps.compile
|
||||
@ -27,7 +51,6 @@ The API server expects the following environment variables to be set:
|
||||
| LOG_LEVEL | Tailor logging verbosity. either "error", "info" (default) or "debug" |
|
||||
| RPC_POOLS | Number of connection pools for RPC requests to Bitcoin Core |
|
||||
| RPC_POOL_SIZE | Number of connections maintained per pool (RPC_POOLS x RPC_POOL_SIZE should be substantially lower than `rpcworkqueue` in bitcoin.conf) |
|
||||
| INDEXED | 'true' to build indexes required for certain features (see [INDEXES.md](https://github.com/bitfeed-project/block/master/server/INDEXES.md) for details). Omit this variable to disable indexing |
|
||||
| BITCOIN_HOST | Bitcoin node host address |
|
||||
| BITCOIN_ZMQ_RAWBLOCK_PORT | Bitcoin node ZMQ port for block events (to match `zmqpubrawblock` in bitcoin.conf) |
|
||||
| BITCOIN_ZMQ_RAWTX_PORT | Bitcoin node ZMQ port for transaction events (to match `zmqpubrawtx` in bitcoin.conf) |
|
||||
|
@ -13,7 +13,7 @@ defmodule BitcoinStream.Server do
|
||||
{ rpc_pool_size, "" } = Integer.parse(System.get_env("RPC_POOL_SIZE") || "16");
|
||||
log_level = System.get_env("LOG_LEVEL");
|
||||
btc_host = System.get_env("BITCOIN_HOST");
|
||||
indexed = System.get_env("INDEXED")
|
||||
indexed = Mix.target == "public";
|
||||
|
||||
case log_level do
|
||||
"debug" ->
|
||||
|
@ -17,7 +17,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
@impl true
|
||||
def init([indexed]) do
|
||||
:ets.new(:spend_cache, [:set, :public, :named_table]);
|
||||
if (indexed != nil) do
|
||||
if (indexed) do
|
||||
{:ok, dbref} = :rocksdb.open(String.to_charlist("data/index/spend"), [create_if_missing: true]);
|
||||
Process.send_after(self(), :sync, 2000);
|
||||
{:ok, [dbref, indexed, false]}
|
||||
@ -28,14 +28,14 @@ defmodule BitcoinStream.Index.Spend do
|
||||
|
||||
@impl true
|
||||
def terminate(_reason, [dbref, indexed, _done]) do
|
||||
if (indexed != nil) do
|
||||
if (indexed) do
|
||||
:rocksdb.close(dbref)
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info(:sync, [dbref, indexed, done]) do
|
||||
if (indexed != nil) do
|
||||
if (indexed) do
|
||||
case sync(dbref) do
|
||||
true ->
|
||||
{:noreply, [dbref, indexed, true]}
|
||||
@ -57,7 +57,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
|
||||
@impl true
|
||||
def handle_call({:get_tx_spends, txid}, _from, [dbref, indexed, done]) do
|
||||
case get_transaction_spends(dbref, txid, (indexed != nil)) do
|
||||
case get_transaction_spends(dbref, txid, (indexed)) do
|
||||
{:ok, spends} ->
|
||||
{:reply, {:ok, spends}, [dbref, indexed, done]}
|
||||
|
||||
@ -69,7 +69,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
|
||||
@impl true
|
||||
def handle_cast(:new_block, [dbref, indexed, done]) do
|
||||
if (indexed != nil and done) do
|
||||
if (indexed and done) do
|
||||
case sync(dbref) do
|
||||
true ->
|
||||
{:noreply, [dbref, indexed, true]}
|
||||
@ -86,7 +86,7 @@ defmodule BitcoinStream.Index.Spend do
|
||||
@impl true
|
||||
def handle_cast({:block_disconnected, hash}, [dbref, indexed, done]) do
|
||||
Logger.info("block disconnected: #{hash}");
|
||||
if (indexed != nil and done) do
|
||||
if (indexed and done) do
|
||||
block_disconnected(dbref, hash)
|
||||
end
|
||||
{:noreply, [dbref, indexed, done]}
|
||||
|
@ -42,7 +42,7 @@ defmodule BitcoinStream.MixProject do
|
||||
{:corsica, "~> 1.0"},
|
||||
{:plug_cowboy, "~> 2.0"},
|
||||
{:jason, "~> 1.1"},
|
||||
{:rocksdb, "~> 1.6"}
|
||||
{:rocksdb, "~> 1.6", targets: :public}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user