Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
265eb9da67 |
No files matched your search
+11
-52
@@ -1,5 +1,9 @@
|
||||
name: ci
|
||||
on: ["push", "pull_request"]
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -27,8 +31,8 @@ jobs:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
#- macos-latest
|
||||
#- windows-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -44,31 +48,11 @@ jobs:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
|
||||
restore-keys: ${{ runner.os }}-pip-
|
||||
- id: os-name
|
||||
uses: ASzc/change-string-case-action@v1
|
||||
with:
|
||||
string: ${{ runner.os }}
|
||||
- run: pip install --user --upgrade pip wheel
|
||||
- if: startsWith(runner.os, 'linux')
|
||||
run: pip install -e .[torrent,test]
|
||||
- if: startsWith(runner.os, 'linux')
|
||||
env:
|
||||
- run: pip install -e .[torrent,test]
|
||||
- env:
|
||||
HOME: /tmp
|
||||
run: make test-unit-coverage
|
||||
- if: startsWith(runner.os, 'linux') != true
|
||||
run: pip install -e .[test]
|
||||
- if: startsWith(runner.os, 'linux') != true
|
||||
env:
|
||||
HOME: /tmp
|
||||
run: coverage run --source=lbry -m unittest tests/unit/test_conf.py
|
||||
- name: submit coverage report
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
COVERALLS_FLAG_NAME: tests-unit-${{ steps.os-name.outputs.lowercase }}
|
||||
COVERALLS_PARALLEL: true
|
||||
run: |
|
||||
pip install coveralls
|
||||
coveralls --service=github
|
||||
|
||||
tests-integration:
|
||||
name: "tests / integration"
|
||||
@@ -78,11 +62,6 @@ jobs:
|
||||
test:
|
||||
- datanetwork
|
||||
- blockchain
|
||||
- claims
|
||||
- takeovers
|
||||
- transactions
|
||||
- claims_legacy_search
|
||||
- takeovers_legacy_search
|
||||
- other
|
||||
steps:
|
||||
- name: Configure sysctl limits
|
||||
@@ -109,28 +88,8 @@ jobs:
|
||||
path: ./.tox
|
||||
key: tox-integration-${{ matrix.test }}-${{ hashFiles('setup.py') }}
|
||||
restore-keys: txo-integration-${{ matrix.test }}-
|
||||
- run: pip install tox coverage coveralls
|
||||
- run: pip install tox
|
||||
- run: tox -e ${{ matrix.test }}
|
||||
- name: submit coverage report
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
COVERALLS_FLAG_NAME: tests-integration-${{ matrix.test }}
|
||||
COVERALLS_PARALLEL: true
|
||||
run: |
|
||||
coverage combine tests
|
||||
coveralls --service=github
|
||||
|
||||
|
||||
coverage:
|
||||
needs: ["tests-unit", "tests-integration"]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: finalize coverage report submission
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
pip install coveralls
|
||||
coveralls --service=github --finish
|
||||
|
||||
build:
|
||||
needs: ["lint", "tests-unit", "tests-integration"]
|
||||
@@ -138,7 +97,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-18.04
|
||||
- ubuntu-16.04
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@@ -18,5 +18,5 @@ jobs:
|
||||
CHANGELOG: '<!channel> ${{ steps.markdown.outputs.text }}'
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASE_BOT_WEBHOOK }}
|
||||
with:
|
||||
payload: '{"type": "mrkdwn", "text": ${{ toJSON(env.CHANGELOG) }} }'
|
||||
payload: '{"type": "mrkdwn", "text": ${{ toJSON(env.CHANGELOG) }}'
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ __pycache__
|
||||
_trial_temp/
|
||||
trending*.log
|
||||
|
||||
/tests/integration/claims/files
|
||||
/tests/integration/blockchain/files
|
||||
/tests/.coverage.*
|
||||
|
||||
/lbry/wallet/bin
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
install:
|
||||
pip install -e .
|
||||
|
||||
tools:
|
||||
pip install mypy==0.701 pylint==2.4.4
|
||||
pip install coverage astroid pylint
|
||||
|
||||
lint:
|
||||
pylint --rcfile=setup.cfg lbry
|
||||
#mypy --ignore-missing-imports lbry
|
||||
@@ -13,7 +17,7 @@ test-unit:
|
||||
python -m unittest discover tests.unit
|
||||
|
||||
test-unit-coverage:
|
||||
coverage run --source=lbry -m unittest discover -vv tests.unit
|
||||
coverage run -p --source=lbry -m unittest discover -vv tests.unit
|
||||
|
||||
test-integration:
|
||||
tox
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# <img src="https://raw.githubusercontent.com/lbryio/lbry-sdk/master/lbry.png" alt="LBRY" width="48" height="36" /> LBRY SDK [](https://github.com/lbryio/lbry-sdk/actions/workflows/main.yml) [](https://coveralls.io/github/lbryio/lbry-sdk)
|
||||
# <img src="https://raw.githubusercontent.com/lbryio/lbry-sdk/master/lbry.png" alt="LBRY" width="48" height="36" /> LBRY SDK [](https://ci.lbry.tech/lbry/lbry-sdk)
|
||||
|
||||
LBRY is a decentralized peer-to-peer protocol for publishing and accessing digital content. It utilizes the [LBRY blockchain](https://github.com/lbryio/lbrycrd) as a global namespace and database of digital content. Blockchain entries contain searchable content metadata, identities, rights and access rules. LBRY also provides a data network that consists of peers (seeders) uploading and downloading data from other peers, possibly in exchange for payments, as well as a distributed hash table used by peers to discover other peers.
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
FROM debian:10-slim
|
||||
|
||||
ARG user=lbry
|
||||
ARG projects_dir=/home/$user
|
||||
|
||||
ARG DOCKER_TAG
|
||||
ARG DOCKER_COMMIT=docker
|
||||
ENV DOCKER_TAG=$DOCKER_TAG DOCKER_COMMIT=$DOCKER_COMMIT
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y --no-install-recommends install \
|
||||
wget \
|
||||
automake libtool \
|
||||
tar unzip \
|
||||
build-essential \
|
||||
pkg-config \
|
||||
libleveldb-dev \
|
||||
python3.7 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-wheel \
|
||||
python3-setuptools && \
|
||||
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN groupadd -g 999 $user && useradd -m -u 999 -g $user $user
|
||||
|
||||
COPY . $projects_dir
|
||||
RUN chown -R $user:$user $projects_dir
|
||||
|
||||
USER $user
|
||||
WORKDIR $projects_dir
|
||||
|
||||
RUN make install
|
||||
RUN python3 docker/set_build.py
|
||||
RUN rm ~/.cache -rf
|
||||
ENTRYPOINT ["python3", "scripts/dht_node.py"]
|
||||
|
||||
@@ -15,11 +15,11 @@ RUN apt-get update && \
|
||||
build-essential \
|
||||
automake libtool \
|
||||
pkg-config \
|
||||
libleveldb-dev \
|
||||
python3.7 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-wheel \
|
||||
python3-cffi \
|
||||
python3-setuptools && \
|
||||
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
@@ -18,27 +18,23 @@ services:
|
||||
- "wallet_server:/database"
|
||||
environment:
|
||||
- DAEMON_URL=http://lbry:lbry@127.0.0.1:9245
|
||||
- MAX_QUERY_WORKERS=4
|
||||
- CACHE_MB=1024
|
||||
- CACHE_ALL_TX_HASHES=
|
||||
- CACHE_ALL_CLAIM_TXOS=
|
||||
- MAX_SEND=1000000000000000000
|
||||
- MAX_RECEIVE=1000000000000000000
|
||||
- MAX_SESSIONS=100000
|
||||
- HOST=0.0.0.0
|
||||
- TCP_PORT=50001
|
||||
- PROMETHEUS_PORT=2112
|
||||
- QUERY_TIMEOUT_MS=3000 # how long search queries allowed to run before cancelling, in milliseconds
|
||||
- TRENDING_ALGORITHMS=variable_decay
|
||||
- MAX_SEND=10000000000000 # deprecated. leave it high until its removed
|
||||
- MAX_SUBS=1000000000000 # deprecated. leave it high until its removed
|
||||
- FILTERING_CHANNEL_IDS=770bd7ecba84fd2f7607fb15aedd2b172c2e153f 95e5db68a3101df19763f3a5182e4b12ba393ee8
|
||||
- BLOCKING_CHANNEL_IDS=dd687b357950f6f271999971f43c785e8067c3a9 06871aa438032244202840ec59a469b303257cad b4a2528f436eca1bf3bf3e10ff3f98c57bd6c4c6
|
||||
- BLOCKING_CHANNEL_IDS=dd687b357950f6f271999971f43c785e8067c3a9 06871aa438032244202840ec59a469b303257cad b4a2528f436eca1bf3bf3e10ff3f98c57bd6c4c6 e4e230b131082f6b10c8f7994bbb83f29e8e6fb9
|
||||
es01:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0
|
||||
container_name: es01
|
||||
environment:
|
||||
- node.name=es01
|
||||
- discovery.type=single-node
|
||||
- indices.query.bool.max_clause_count=8192
|
||||
- indices.query.bool.max_clause_count=4096
|
||||
- bootstrap.memory_lock=true
|
||||
- "ES_JAVA_OPTS=-Xms4g -Xmx4g" # no more than 32, remember to disable swap
|
||||
- "ES_JAVA_OPTS=-Xms8g -Xmx8g" # no more than 32, remember to disable swap
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
|
||||
@@ -6,7 +6,7 @@ set -euo pipefail
|
||||
|
||||
SNAPSHOT_URL="${SNAPSHOT_URL:-}" #off by default. latest snapshot at https://lbry.com/snapshot/wallet
|
||||
|
||||
if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/lbry-leveldb ]]; then
|
||||
if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/claims.db ]]; then
|
||||
files="$(ls)"
|
||||
echo "Downloading wallet snapshot from $SNAPSHOT_URL"
|
||||
wget --no-verbose --trust-server-names --content-disposition "$SNAPSHOT_URL"
|
||||
@@ -20,6 +20,6 @@ if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/lbry-leveldb ]]; then
|
||||
rm "$filename"
|
||||
fi
|
||||
|
||||
/home/lbry/.local/bin/lbry-hub-elastic-sync
|
||||
/home/lbry/.local/bin/lbry-hub-elastic-sync /database/claims.db
|
||||
echo 'starting server'
|
||||
/home/lbry/.local/bin/lbry-hub "$@"
|
||||
+481
-127
@@ -54,10 +54,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Get a file",
|
||||
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet get astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1634935385,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmprf50bsj_\",\n \"download_path\": \"/tmp/tmprf50bsj_/tmptzmyf1rt\",\n \"file_name\": \"tmptzmyf1rt\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"5b1c3ce02186cc7087ab27bc1075af3a\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0117fbdd61f0cad185dcc191da185ef3513c9c94c99e1c2e131b166b817150587eab67a66890a9b619afdc81eb07bd2d645156e94b237ca75b4f03434734a9937628ff6ad161133542fcd6437c4acf58ed65e63bd70a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70747a6d7966317274180b22186170706c69636174696f6e2f6f637465742d73747265616d3230283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"222955d463b92971d9f76420a405d2a9b1a18d1d9160afa11660276f5ec0f5990adc547f4a36bba42252f97a3f089769\",\n \"stream_name\": \"tmptzmyf1rt\",\n \"streaming_url\": \"http://localhost:5280/stream/283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"suggested_file_name\": \"tmptzmyf1rt\",\n \"timestamp\": 1634935409,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet get astream#ea41b9f807c6982cf97a1178838dfef64feaa014",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1621405335,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmp5s0wcgsl\",\n \"download_path\": \"/tmp/tmp5s0wcgsl/tmpvccpjv29\",\n \"file_name\": \"tmpvccpjv29\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": 1621405356,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -268,10 +268,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Publish a file",
|
||||
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpjdj6v96z\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet publish a-new-stream --bid=1.0 --file_path=/tmp/tmpjdj6v96z",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpjdj6v96z\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000016b49df035628671948d13270cc5e8660a7ec8b93793b2d3a2e1c0627bbd61579010000006a4730440220553c95930097d5e0e25e740d411f3fcdb704979783b3e22a0c34e8e1830155750220130c0b9d4d6b1555ab17714b39d6945a9906d9fe1f37eba36c9580c1d7a385cc0121037d921d5cc62c2d1a5e3d3bd0139e6878b9a5f0acbaba5e96395b957d38a59be2ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706a646a367639367a180b22186170706c69636174696f6e2f6f637465742d73747265616d3230bdf5ff9713da1c6d00b60bab8fe04fbc40eb6d033ca211fdfe70e8a10469056150fe4fa4db978b4f2a9f060f27b73a206d7576a914fe865a1f108b5ff3c9783debef93b8012190cda588ac54826311000000001976a91491b20884a3b48a466543e66f16cbe04dcd7ea96e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"msCc66GAkDKNYiuMJji5iKo7QVTUXnX7p4\",\n \"amount\": \"3.941448\",\n \"confirmations\": 3,\n \"height\": 217,\n \"nout\": 1,\n \"timestamp\": 1634935409,\n \"txid\": \"7915d6bb27061c2e3a2d3b79938beca760865ecc7032d1481967285603df496b\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n4iksiqPQat3t7rsXAVkUzG2d7egNGE7Yv\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe2ddf50caa075c1242d509fd6f9691f2f9693d9\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"a-new-stream\",\n \"normalized_name\": \"a-new-stream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://a-new-stream#fe2ddf50caa075c1242d509fd6f9691f2f9693d9\",\n \"timestamp\": null,\n \"txid\": \"08211f8e9cff0adb0914533d607ebee0e4483321e9f5bf58294ae5195bec162c\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpjdj6v96z\",\n \"sd_hash\": \"bdf5ff9713da1c6d00b60bab8fe04fbc40eb6d033ca211fdfe70e8a10469056150fe4fa4db978b4f2a9f060f27b73a20\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mtoKYqZqUZd6RtwDC87dChbUofSgvtWz66\",\n \"amount\": \"2.917341\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"08211f8e9cff0adb0914533d607ebee0e4483321e9f5bf58294ae5195bec162c\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"3.941448\",\n \"total_output\": \"3.917341\",\n \"txid\": \"08211f8e9cff0adb0914533d607ebee0e4483321e9f5bf58294ae5195bec162c\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp71cpkkpk\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet publish a-new-stream --bid=1.0 --file_path=/tmp/tmp71cpkkpk",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp71cpkkpk\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015f41ebc2b2af4adaafc3fe8631d6f56f9c2cd1d67c384fa8c10559354183f3ab010000006b483045022100c00b31d02741ecce403cce42c8ffb89a977ba9a769b11947b19727e1253670b302203ee3d3e40b7b81e4ae3b9d1260014089231309a6873ae8de061efd9e1dbc6514012103654434c522fa0681cb1131a62328a3c3c99f43242edf2d055dbefa69b3c9b5d3ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70373163706b6b706b180b22186170706c69636174696f6e2f6f637465742d73747265616d32303ba910e14fbcd8314f7de8e5e39b7442a2d257c3b975d0780131e7fe5978e17b5f59708abb7279597e71646d0970bf4e6d7576a9145199d244266b2168acfccfcf3c12f6b7b2f37fa088ac54826311000000001976a914b940ff67df6bd84a70a08f88ec01a4bfba20db5e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mgyaP4FvA3DLPfatc7bfJS8a62c2AHQZH1\",\n \"amount\": \"3.941448\",\n \"confirmations\": 3,\n \"height\": 217,\n \"nout\": 1,\n \"timestamp\": 1621405356,\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnxRJHcT6tEndwbT2fS3bTjcyknA8x1MV3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"26ed324fb68e5f0093d8bb16ee4b2f371004f456\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"a-new-stream\",\n \"normalized_name\": \"a-new-stream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://a-new-stream#26ed324fb68e5f0093d8bb16ee4b2f371004f456\",\n \"timestamp\": null,\n \"txid\": \"f5a1b7441bcb30df43696f135975e16c303c1ed8ab443353390de8bac25c3cad\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp71cpkkpk\",\n \"sd_hash\": \"3ba910e14fbcd8314f7de8e5e39b7442a2d257c3b975d0780131e7fe5978e17b5f59708abb7279597e71646d0970bf4e\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mxQVAfGJmsfYiH6JrM3uTxzHjNpBesAWFe\",\n \"amount\": \"2.917341\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"f5a1b7441bcb30df43696f135975e16c303c1ed8ab443353390de8bac25c3cad\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"3.941448\",\n \"total_output\": \"3.917341\",\n \"txid\": \"f5a1b7441bcb30df43696f135975e16c303c1ed8ab443353390de8bac25c3cad\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -332,10 +332,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Resolve a claim",
|
||||
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet resolve astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\": {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c/astream#6\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 214,\n \"creation_height\": 213,\n \"creation_timestamp\": 1634935409,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 714,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"short_url\": \"lbry://astream#6\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 210,\n \"claims_in_channel\": 2,\n \"creation_height\": 209,\n \"creation_timestamp\": 1634935408,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 710,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"short_url\": \"lbry://@channel#c\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet resolve astream#ea41b9f807c6982cf97a1178838dfef64feaa014",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\": {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 2,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -350,14 +350,14 @@
|
||||
"name": "status",
|
||||
"description": "Get daemon status",
|
||||
"arguments": [],
|
||||
"returns": "(dict) lbrynet-daemon status\n {\n 'installation_id': (str) installation id - base58,\n 'is_running': (bool),\n 'skipped_components': (list) [names of skipped components (str)],\n 'startup_status': { Does not include components which have been skipped\n 'blob_manager': (bool),\n 'blockchain_headers': (bool),\n 'database': (bool),\n 'dht': (bool),\n 'exchange_rate_manager': (bool),\n 'hash_announcer': (bool),\n 'peer_protocol_server': (bool),\n 'file_manager': (bool),\n 'libtorrent_component': (bool),\n 'upnp': (bool),\n 'wallet': (bool),\n },\n 'connection_status': {\n 'code': (str) connection status code,\n 'message': (str) connection status message\n },\n 'blockchain_headers': {\n 'downloading_headers': (bool),\n 'download_progress': (float) 0-100.0\n },\n 'wallet': {\n 'connected': (str) host and port of the connected spv server,\n 'blocks': (int) local blockchain height,\n 'blocks_behind': (int) remote_height - local_height,\n 'best_blockhash': (str) block hash of most recent block,\n 'is_encrypted': (bool),\n 'is_locked': (bool),\n 'connected_servers': (list) [\n {\n 'host': (str) server hostname,\n 'port': (int) server port,\n 'latency': (int) milliseconds\n }\n ],\n },\n 'libtorrent_component': {\n 'running': (bool) libtorrent was detected and started successfully,\n },\n 'dht': {\n 'node_id': (str) lbry dht node id - hex encoded,\n 'peers_in_routing_table': (int) the number of peers in the routing table,\n },\n 'blob_manager': {\n 'finished_blobs': (int) number of finished blobs in the blob manager,\n 'connections': {\n 'incoming_bps': {\n <source ip and tcp port>: (int) bytes per second received,\n },\n 'outgoing_bps': {\n <destination ip and tcp port>: (int) bytes per second sent,\n },\n 'total_outgoing_mps': (float) megabytes per second sent,\n 'total_incoming_mps': (float) megabytes per second received,\n 'max_outgoing_mbs': (float) maximum bandwidth (megabytes per second) sent, since the\n daemon was started\n 'max_incoming_mbs': (float) maximum bandwidth (megabytes per second) received, since the\n daemon was started\n 'total_sent' : (int) total number of bytes sent since the daemon was started\n 'total_received' : (int) total number of bytes received since the daemon was started\n }\n },\n 'hash_announcer': {\n 'announce_queue_size': (int) number of blobs currently queued to be announced\n },\n 'file_manager': {\n 'managed_files': (int) count of files in the stream manager,\n },\n 'upnp': {\n 'aioupnp_version': (str),\n 'redirects': {\n <TCP | UDP>: (int) external_port,\n },\n 'gateway': (str) manufacturer and model,\n 'dht_redirect_set': (bool),\n 'peer_redirect_set': (bool),\n 'external_ip': (str) external ip address,\n }\n }",
|
||||
"returns": "(dict) lbrynet-daemon status\n {\n 'installation_id': (str) installation id - base58,\n 'is_running': (bool),\n 'skipped_components': (list) [names of skipped components (str)],\n 'startup_status': { Does not include components which have been skipped\n 'blob_manager': (bool),\n 'blockchain_headers': (bool),\n 'database': (bool),\n 'dht': (bool),\n 'exchange_rate_manager': (bool),\n 'hash_announcer': (bool),\n 'peer_protocol_server': (bool),\n 'file_manager': (bool),\n 'libtorrent_component': (bool),\n 'upnp': (bool),\n 'wallet': (bool),\n },\n 'connection_status': {\n 'code': (str) connection status code,\n 'message': (str) connection status message\n },\n 'blockchain_headers': {\n 'downloading_headers': (bool),\n 'download_progress': (float) 0-100.0\n },\n 'wallet': {\n 'connected': (str) host and port of the connected spv server,\n 'blocks': (int) local blockchain height,\n 'blocks_behind': (int) remote_height - local_height,\n 'best_blockhash': (str) block hash of most recent block,\n 'is_encrypted': (bool),\n 'is_locked': (bool),\n 'connected_servers': (list) [\n {\n 'host': (str) server hostname,\n 'port': (int) server port,\n 'latency': (int) milliseconds\n }\n ],\n },\n 'libtorrent_component': {\n 'running': (bool) libtorrent was detected and started successfully,\n },\n 'dht': {\n 'node_id': (str) lbry dht node id - hex encoded,\n 'peers_in_routing_table': (int) the number of peers in the routing table,\n },\n 'blob_manager': {\n 'finished_blobs': (int) number of finished blobs in the blob manager,\n 'connections': {\n 'incoming_bps': {\n <source ip and tcp port>: (int) bytes per second received,\n },\n 'outgoing_bps': {\n <destination ip and tcp port>: (int) bytes per second sent,\n },\n 'total_outgoing_mps': (float) megabytes per second sent,\n 'total_incoming_mps': (float) megabytes per second received,\n 'time': (float) timestamp\n }\n },\n 'hash_announcer': {\n 'announce_queue_size': (int) number of blobs currently queued to be announced\n },\n 'file_manager': {\n 'managed_files': (int) count of files in the stream manager,\n },\n 'upnp': {\n 'aioupnp_version': (str),\n 'redirects': {\n <TCP | UDP>: (int) external_port,\n },\n 'gateway': (str) manufacturer and model,\n 'dht_redirect_set': (bool),\n 'peer_redirect_set': (bool),\n 'external_ip': (str) external ip address,\n }\n }",
|
||||
"examples": [
|
||||
{
|
||||
"title": "Get status",
|
||||
"curl": "curl -d'{\"method\": \"status\", \"params\": {}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet status",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"status\", \"params\": {}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blob_manager\": {\n \"connections\": {\n \"incoming_bps\": {},\n \"max_incoming_mbs\": 0.0,\n \"max_outgoing_mbs\": 0.0,\n \"outgoing_bps\": {},\n \"total_incoming_mbs\": 0.0,\n \"total_outgoing_mbs\": 0.0,\n \"total_received\": 0,\n \"total_sent\": 0\n },\n \"finished_blobs\": 0\n },\n \"disk_space\": {\n \"running\": true,\n \"space_used\": \"0\"\n },\n \"ffmpeg_status\": {\n \"analyze_audio_volume\": true,\n \"available\": true,\n \"which\": \"/usr/bin/ffmpeg\"\n },\n \"file_manager\": {\n \"managed_files\": 0\n },\n \"installation_id\": \"7Heg2TFdygzcjQVvZBHK6hnXNWYMT43F9jyh2PoRyzHK3BeHMfjbL5AVvz4F9i8PxL\",\n \"is_running\": true,\n \"skipped_components\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\",\n \"libtorrent_component\"\n ],\n \"startup_status\": {\n \"blob_manager\": true,\n \"database\": true,\n \"disk_space\": true,\n \"exchange_rate_manager\": true,\n \"file_manager\": true,\n \"wallet\": true,\n \"wallet_server_payments\": true\n },\n \"wallet\": {\n \"available_servers\": 1,\n \"best_blockhash\": \"02ae257ee08c2368fa243b2ff29b4824fd178efbfb59f58d0e36c9edc69323a1\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"connected\": \"localhost:50002\",\n \"connected_features\": {\n \"daily_fee\": \"0\",\n \"description\": \"\",\n \"donation_address\": \"\",\n \"genesis_hash\": \"6e3fcf1299d4ec5d79c3a4c91d624a4acf9e2e173d95a1a0504f677669687556\",\n \"hash_function\": \"sha256\",\n \"hosts\": {},\n \"payment_address\": \"\",\n \"protocol_max\": \"0.199.0\",\n \"protocol_min\": \"0.54.0\",\n \"pruning\": null,\n \"server_version\": \"0.105.0\",\n \"trending_algorithm\": \"variable_decay\"\n },\n \"headers_synchronization_progress\": 100,\n \"known_servers\": 0,\n \"servers\": [\n {\n \"availability\": true,\n \"host\": \"localhost\",\n \"latency\": 0.002615762990899384,\n \"port\": 50002\n }\n ]\n },\n \"wallet_server_payments\": {\n \"max_fee\": \"0.0\",\n \"running\": false\n }\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blob_manager\": {\n \"connections\": {\n \"incoming_bps\": {},\n \"max_incoming_mbs\": 0.0,\n \"max_outgoing_mbs\": 0.0,\n \"outgoing_bps\": {},\n \"total_incoming_mbs\": 0.0,\n \"total_outgoing_mbs\": 0.0,\n \"total_received\": 0,\n \"total_sent\": 0\n },\n \"finished_blobs\": 0\n },\n \"ffmpeg_status\": {\n \"analyze_audio_volume\": true,\n \"available\": true,\n \"which\": \"/usr/bin/ffmpeg\"\n },\n \"file_manager\": {\n \"managed_files\": 0\n },\n \"installation_id\": \"5b3thUHqWPtw7tsqms7k6EhytxX6kg99EtrTSLjrZpPohJfgdtDFw9v3vHQkTLHjkJ\",\n \"is_running\": true,\n \"skipped_components\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\",\n \"libtorrent_component\"\n ],\n \"startup_status\": {\n \"blob_manager\": true,\n \"database\": true,\n \"exchange_rate_manager\": true,\n \"file_manager\": true,\n \"wallet\": true,\n \"wallet_server_payments\": true\n },\n \"wallet\": {\n \"available_servers\": 1,\n \"best_blockhash\": \"ec817b4f72ffdc8f2e1fef1eec569b4a96ab1b9a7a5421d6dea82c12ae817753\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"connected\": \"localhost:50002\",\n \"connected_features\": {\n \"daily_fee\": \"0\",\n \"description\": \"\",\n \"donation_address\": \"\",\n \"genesis_hash\": \"6e3fcf1299d4ec5d79c3a4c91d624a4acf9e2e173d95a1a0504f677669687556\",\n \"hash_function\": \"sha256\",\n \"hosts\": {},\n \"payment_address\": \"\",\n \"protocol_max\": \"0.99.0\",\n \"protocol_min\": \"0.54.0\",\n \"pruning\": null,\n \"server_version\": \"0.97.0\",\n \"trending_algorithm\": \"zscore\"\n },\n \"headers_synchronization_progress\": 100,\n \"known_servers\": 1,\n \"servers\": [\n {\n \"availability\": true,\n \"host\": \"localhost\",\n \"latency\": 0.004196007997961715,\n \"port\": 50002\n }\n ]\n },\n \"wallet_server_payments\": {\n \"max_fee\": \"0.0\",\n \"running\": false\n }\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -379,7 +379,7 @@
|
||||
"curl": "curl -d'{\"method\": \"version\", \"params\": {}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet version",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"version\", \"params\": {}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"build\": \"dev\",\n \"desktop\": \"ubuntu:GNOME\",\n \"distro\": {\n \"codename\": \"focal\",\n \"id\": \"ubuntu\",\n \"like\": \"debian\",\n \"version\": \"20.04\",\n \"version_parts\": {\n \"build_number\": \"\",\n \"major\": \"20\",\n \"minor\": \"04\"\n }\n },\n \"lbrynet_version\": \"0.102.0\",\n \"os_release\": \"5.11.0-27-generic\",\n \"os_system\": \"Linux\",\n \"platform\": \"Linux-5.11.0-27-generic-x86_64-with-debian-bullseye-sid\",\n \"processor\": \"x86_64\",\n \"python_version\": \"3.7.10\",\n \"version\": \"0.102.0\"\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"build\": \"dev\",\n \"desktop\": \"Unknown\",\n \"distro\": {\n \"codename\": \"buster\",\n \"id\": \"debian\",\n \"like\": \"\",\n \"version\": \"10\",\n \"version_parts\": {\n \"build_number\": \"\",\n \"major\": \"10\",\n \"minor\": \"\"\n }\n },\n \"lbrynet_version\": \"0.97.0\",\n \"os_release\": \"5.4.107-1.fc25.qubes.x86_64\",\n \"os_system\": \"Linux\",\n \"platform\": \"Linux-5.4.107-1.fc25.qubes.x86_64-x86_64-with-debian-10.9\",\n \"processor\": \"\",\n \"python_version\": \"3.7.3\",\n \"version\": \"0.97.0\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -433,10 +433,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Add an account from seed",
|
||||
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"doll chat slow design pupil give settle such couch salon father useless\", \"single_key\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account add \"new account\" --seed=\"doll chat slow design pupil give settle such couch salon father useless\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"doll chat slow design pupil give settle such couch salon father useless\", \"single_key\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1634935375,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdtjGxuBjK4arzToQmruTWTTKtGNuNYzHyghCvCnVBDM2e5swQWzgrmXQv6NteKshXaJLae2Zkcp14F12Q69sGZazPo73ppA\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XMm4rYrKiUEyZVKLwC6N5m47AnRCnpngpAwyYbc5MhxtpCvJAtGSwomTm9DUyCwAnYTwhBqrYRXUp8P9EiLz5BTANWuPjeF\",\n \"seed\": \"doll chat slow design pupil give settle such couch salon father useless\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\", \"single_key\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account add \"new account\" --seed=\"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\", \"single_key\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -474,9 +474,9 @@
|
||||
},
|
||||
{
|
||||
"title": "Get balance for specific account by id",
|
||||
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account balance \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"}}).json()",
|
||||
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account balance \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"available\": \"2.0\",\n \"reserved\": \"0.0\",\n \"reserved_subtotals\": {\n \"claims\": \"0.0\",\n \"supports\": \"0.0\",\n \"tips\": \"0.0\"\n },\n \"total\": \"2.0\"\n }\n}"
|
||||
}
|
||||
]
|
||||
@@ -511,7 +511,7 @@
|
||||
"curl": "curl -d'{\"method\": \"account_create\", \"params\": {\"account_name\": \"generated account\", \"single_key\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account create \"generated account\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_create\", \"params\": {\"account_name\": \"generated account\", \"single_key\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1634935375,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdtjGxuBjK4arzToQmruTWTTKtGNuNYzHyghCvCnVBDM2e5swQWzgrmXQv6NteKshXaJLae2Zkcp14F12Q69sGZazPo73ppA\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XMm4rYrKiUEyZVKLwC6N5m47AnRCnpngpAwyYbc5MhxtpCvJAtGSwomTm9DUyCwAnYTwhBqrYRXUp8P9EiLz5BTANWuPjeF\",\n \"seed\": \"doll chat slow design pupil give settle such couch salon father useless\"\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -566,24 +566,24 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Transfer 2 LBC from default account to specific account",
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --to_account=\"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\" --amount=2.0 --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015545b7af71b2490713e42a5d52990bd4f0a4b5b01b2f31d93f99847acb463d65010000006a47304402200587a0a30048e93180462f0e1ae2cdb293806748091fbbc384493b8225cf606a022047f557d5056efb11da8e57568f82556e0463de5844e35054f6a15f7e4721c68b012103bf05276d8c1ef596980da6c2dffb4f975d3c2bfbbc05c8512e53d15dd77729c3ffffffff0200c2eb0b000000001976a9140f86eda6ee5e49499c2c8222aba3db2978ae7da388ac90d7ae2f000000001976a914b44a4996d14815d5ee308f936d76e49aa7dac19088ac00000000\",\n \"inputs\": [\n {\n \"address\": \"my2PpEjELjw5LxFtDgY4QuEpG6QJW6bBYG\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"nout\": 1,\n \"timestamp\": 1634935407,\n \"txid\": \"653d46cb7a84993fd9312f1bb0b5a4f0d40b99525d2ae4130749b271afb74555\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mgw44v5yrsj63HqNRgbKKnhsx3FNYLPhcz\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"95f85d786c60e12731c553f7510a8f83bd14a913f6d4dbdca580882ae767c6cb\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwxEvAcUgiYGEjrJPNg51rzPvQgCUfvYEn\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"95f85d786c60e12731c553f7510a8f83bd14a913f6d4dbdca580882ae767c6cb\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"95f85d786c60e12731c553f7510a8f83bd14a913f6d4dbdca580882ae767c6cb\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --to_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --amount=2.0 --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000158b9aacf16272c014b4ea68547f99b83aac802ec1649da83922ecdc9273b727a010000006b483045022100daca5565f0ad55024830d3ea012285bfa572abda34d585b086899ae9959025db022025b134dcb5ce9d9eee109c649b5aaa1efb82bd782ec0bc7fc8982c563cb61470012103f2ee97726d5454ae20354313092052968f819e77b792e6fc52458fa4ddfe34e7ffffffff0200c2eb0b000000001976a914cdfc5605a8e5ea0e13e4be23811bba94622e161b88ac90d7ae2f000000001976a9142ad7e4109f922f32e09cb95ccd0d94150cc9e6fc88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mffPeSmHrFE3tg5J4zCQGP4muR6CcUV5wu\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"nout\": 1,\n \"timestamp\": 1621405354,\n \"txid\": \"7a723b27c9cd2e9283da4916ec02c8aa839bf94785a64e4b012c2716cfaab958\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzJ76zabb25ur5UEzCcPqDNcdnANJJktk1\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mjRVJULUCxB7s3guxUriGqN5C7RFj6Fsxh\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\"\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Spread LBC between multiple addresses",
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"from_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --to_account=\"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\" --from_account=\"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\" --amount=1.5 --outputs=2 --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"from_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001cbc667e72a8880a5dcdbd4f613a914bd838f0a51f753c53127e1606c785df895000000006a47304402205d25b565951d6033f557cdf0559cc6510c1b83a5f6bd1a2ced48a18d742515ff0220372fae67623c9b48c46dc206569b18ae3b82473197a781fbe652e86c15431af80121032d3a01a5050470412633e27e44c2a71ca6da0cce6f479c31cd99996327682858ffffffff03c0687804000000001976a91453a48dddf4d841afcfa9dd818854e52b3bcc697388acc0687804000000001976a91453a48dddf4d841afcfa9dd818854e52b3bcc697388ac6cb9fa02000000001976a9147cf20dafe2166f9f56dab48a2ee65861d0853b9888ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mgw44v5yrsj63HqNRgbKKnhsx3FNYLPhcz\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"nout\": 0,\n \"timestamp\": 1634935408,\n \"txid\": \"95f85d786c60e12731c553f7510a8f83bd14a913f6d4dbdca580882ae767c6cb\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mo9DWQ9o2ZxT4Zqnh6cY7bkJ8HkL2og7yH\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"229d34e1018b4075dbf7a5f6d654b86ff6e83ae40c36543f5d1a5fb111f4bfb9\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mo9DWQ9o2ZxT4Zqnh6cY7bkJ8HkL2og7yH\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"229d34e1018b4075dbf7a5f6d654b86ff6e83ae40c36543f5d1a5fb111f4bfb9\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mruc41ZrqK1yMoFganp1AXTpNHKBxJuhZo\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"229d34e1018b4075dbf7a5f6d654b86ff6e83ae40c36543f5d1a5fb111f4bfb9\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"229d34e1018b4075dbf7a5f6d654b86ff6e83ae40c36543f5d1a5fb111f4bfb9\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --to_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --from_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --amount=1.5 --outputs=2 --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001a2a08aed2135620a6c05793822961a98dc9cccb41eb629d6865dc29b2dccf0d0000000006a47304402205f3edef7ce0ca0c525806eeb3d6cbbc4435cd0e99af6b255b3adf850053597c4022007356877e70c4db839f3fe7c3895143482a84db7691f2efb7fbc1b15def1e2c501210374fa170082b9b46254f2887e0f938be9e9b2e2753f5966d03eca0b3c238ecc6affffffff03c0687804000000001976a914b49ada82e78a48e693c1cfe3c4472a0b994c4bce88acc0687804000000001976a914b49ada82e78a48e693c1cfe3c4472a0b994c4bce88ac6cb9fa02000000001976a91420f5af908fbb3a2dff2ad9c136cfc60c9b48170c88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mzJ76zabb25ur5UEzCcPqDNcdnANJJktk1\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"nout\": 0,\n \"timestamp\": 1621405355,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\"\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Transfer all LBC to a specified account",
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --from_account=\"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\" --everything --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"everything\": true, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000003b9bff411b15f1a5d3f54360ce43ae8f66fb854d6f6a5f7db75408b01e1349d22000000006b4830450221009a143ab082a0e403e129e13f45ff16d906c3e28ca99d4d84fa1c53887afa2df00220041b862a85137d77e281223c3741d884176dbd6b9fb5af90306b1a407fa9141f0121031705b49331c5c45955f4faa1b89dd182d958155306460f6a2bbbc8173a753612ffffffffb9bff411b15f1a5d3f54360ce43ae8f66fb854d6f6a5f7db75408b01e1349d22010000006a473044022078274f613cfb8c8d4d5885a9b402e8e8b52e689c2ed2f4a8fc89c29a02b7ebf60220792004171c2901b17585dfea07040e2a2979965d776c69fd9d85b220c07332310121031705b49331c5c45955f4faa1b89dd182d958155306460f6a2bbbc8173a753612ffffffffb9bff411b15f1a5d3f54360ce43ae8f66fb854d6f6a5f7db75408b01e1349d22020000006a4730440220363d9b03457d78952902b1d04acdf329eea348ec98ec18de01e0f94f5cfdfdbf022009daa3ff9f8861e02b40a54c23aa3f0a59b9fd12bef0d35c70369d76447fa0e70121023948b524b27b337b3f787cbe89a24de420c3c31cb1a2ecc00b0a43aec38a159cffffffff015027eb0b000000001976a91473640fc84ee8fe4ce3f4391376326f00bfe1062188ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mo9DWQ9o2ZxT4Zqnh6cY7bkJ8HkL2og7yH\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 0,\n \"timestamp\": 1634935408,\n \"txid\": \"229d34e1018b4075dbf7a5f6d654b86ff6e83ae40c36543f5d1a5fb111f4bfb9\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mo9DWQ9o2ZxT4Zqnh6cY7bkJ8HkL2og7yH\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 1,\n \"timestamp\": 1634935408,\n \"txid\": \"229d34e1018b4075dbf7a5f6d654b86ff6e83ae40c36543f5d1a5fb111f4bfb9\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mruc41ZrqK1yMoFganp1AXTpNHKBxJuhZo\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 2,\n \"timestamp\": 1634935408,\n \"txid\": \"229d34e1018b4075dbf7a5f6d654b86ff6e83ae40c36543f5d1a5fb111f4bfb9\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mr35sX74Yo1aZkF72DwHu4RjTBcMQvSaxF\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"4f93bf94c48cd34778f8965bc76a6f6643023344585a4e5ee178470043bf5e98\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"4f93bf94c48cd34778f8965bc76a6f6643023344585a4e5ee178470043bf5e98\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --from_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --everything --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"everything\": true, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000037745ebd964dff03ad2cd3989d956476eda614cbe95bdf8aaef54ed6f76fa2eff000000006b4830450221008f287b89057f784e197e2318f2be9f5ad53c3e19300ea61bbc6bc030cbb013c90220425cdeb4b5dd8207ec4c755a63cfdda9788a27598c24c0ada41fa7901cfbd82b012103c0330685b2f4734821f4f6b8116c9de7c5faa9d518da7275c823e1440864631bffffffff7745ebd964dff03ad2cd3989d956476eda614cbe95bdf8aaef54ed6f76fa2eff010000006a4730440220493dbb56e0750528e33a6313f1b5577e46b584cfbee44088717c1de513ffa50002207385d2a245325be823ffbc0a2445a02212d75c04a13140c4d885e05588021465012103c0330685b2f4734821f4f6b8116c9de7c5faa9d518da7275c823e1440864631bffffffff7745ebd964dff03ad2cd3989d956476eda614cbe95bdf8aaef54ed6f76fa2eff020000006b483045022100f1344b664449676fdd4b99e4c21e22e361ecd223fae1b05108d0d5e919350d9902203fef98f15717541f256841fb5964f1c22c2bd9281a32420aaf112cc9e79974850121025780217a60380b1410bd46a3c261ac0ae3d86b1dc4b8c45addb0525217ddd31dffffffff015027eb0b000000001976a9147ef48a8cc47e6fbce1d7bb3d909d5e5aa557bd3488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 0,\n \"timestamp\": 1621405355,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 2,\n \"timestamp\": 1621405355,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"ms6EPFDDfSb3gVMgyBZ5drGuYH9uqvvmPq\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"ac0d083d10fabb4abcd15d2a8c94868fd4a64de15f0d94d10eecc547155fb8f5\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"ac0d083d10fabb4abcd15d2a8c94868fd4a64de15f0d94d10eecc547155fb8f5\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -641,7 +641,7 @@
|
||||
"curl": "curl -d'{\"method\": \"account_list\", \"params\": {\"include_claims\": false, \"show_seed\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_list\", \"params\": {\"include_claims\": false, \"show_seed\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"certificates\": 0,\n \"coins\": 10.0,\n \"encrypted\": false,\n \"id\": \"muFrAE42mp5qh5YT33pt1pN7CFHPAn1cYS\",\n \"is_default\": true,\n \"ledger\": \"lbc_regtest\",\n \"name\": \"Account #muFrAE42mp5qh5YT33pt1pN7CFHPAn1cYS\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Xk3jNkqc12Bm2u8usSuJSDpovKgnzjDpqyUGxNQqdd93wk8BGHHBKpAex6Vqt25hUmpoixAQjMwA5W1eaggNx6CTwDAmHC4\",\n \"satoshis\": 1000000000\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"certificates\": 0,\n \"coins\": 10.0,\n \"encrypted\": false,\n \"id\": \"n34d7tsf9D7HjzWr2LnE7c9x9rwtvGNNwG\",\n \"is_default\": true,\n \"ledger\": \"lbc_regtest\",\n \"name\": \"Account #n34d7tsf9D7HjzWr2LnE7c9x9rwtvGNNwG\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Y47gVC3GHm5nxPbxoWF7fxq3L59VBTkw5X3iiyHrka3AD5M7YWvC8NvUngQwrm6wacpWxEeJMXNH3YvJBYAbtp2TVmsSyw4\",\n \"satoshis\": 1000000000\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -686,10 +686,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Remove an account",
|
||||
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account remove mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1634935375,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdtjGxuBjK4arzToQmruTWTTKtGNuNYzHyghCvCnVBDM2e5swQWzgrmXQv6NteKshXaJLae2Zkcp14F12Q69sGZazPo73ppA\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XMm4rYrKiUEyZVKLwC6N5m47AnRCnpngpAwyYbc5MhxtpCvJAtGSwomTm9DUyCwAnYTwhBqrYRXUp8P9EiLz5BTANWuPjeF\",\n \"seed\": \"doll chat slow design pupil give settle such couch salon father useless\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account remove mue613K8x5kLXpsePncrd5xqSoRi7NXmYx",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -782,10 +782,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Modify maximum number of times a change address can be reused",
|
||||
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account set mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk --change_max_uses=10",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\", \"default\": false, \"change_max_uses\": 10}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 10\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1634935375,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdtjGxuBjK4arzToQmruTWTTKtGNuNYzHyghCvCnVBDM2e5swQWzgrmXQv6NteKshXaJLae2Zkcp14F12Q69sGZazPo73ppA\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XMm4rYrKiUEyZVKLwC6N5m47AnRCnpngpAwyYbc5MhxtpCvJAtGSwomTm9DUyCwAnYTwhBqrYRXUp8P9EiLz5BTANWuPjeF\",\n \"seed\": \"doll chat slow design pupil give settle such couch salon father useless\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account set mue613K8x5kLXpsePncrd5xqSoRi7NXmYx --change_max_uses=10",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"default\": false, \"change_max_uses\": 10}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 10\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -821,9 +821,9 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Check if address is mine",
|
||||
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mjEFq6JGQWFVj45vYxybnWgYAMYjfpDQ91\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address is_mine mjEFq6JGQWFVj45vYxybnWgYAMYjfpDQ91",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mjEFq6JGQWFVj45vYxybnWgYAMYjfpDQ91\"}}).json()",
|
||||
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address is_mine mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
|
||||
}
|
||||
]
|
||||
@@ -870,14 +870,14 @@
|
||||
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mgkp4JFgYEjG8WTwQ6z1NoNRCkar7qo57E\",\n \"pubkey\": \"tpubDA9GDAntyJu53xnNZzuzAsggGmoTegjyr4WFNYMecJt77s7UvHyPLXj4mZXSUwv32T3ai1gB5FnjMoHNezD53b9W7b14aV5XHLTgXw1ZDNp\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mgw44v5yrsj63HqNRgbKKnhsx3FNYLPhcz\",\n \"pubkey\": \"tpubDA9GDAntyJu4TPbn7DW5GuTPaEDjM7XgGhoi9UihhiUDvkMztgEeCMKjepZcSBKbEDHTpkFcinmwKxfrz4KkkC2QY5Q14DbVzBBf1s7uFjv\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mhGWq1gzorJaRL1JKRfX2GbJ2fBj6rMU46\",\n \"pubkey\": \"tpubDA9GDAntyJu4He6utE59U1DrugFsXPYngEbNKsrgrdtvpDicA8PzmrG3FZiVv8qANt3Z5e2UiMYmy5b6bgxT2nH7cfgYXP3155uqbgMzvpo\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mhXk5DN4DZ7Ja8YopzR8ZjbXxfPTikFsBq\",\n \"pubkey\": \"tpubDA9GDAntyJu4tmNfk9j1cHbPGCrM1V63c65vwTc9fh3ua8FM1oc6UW2eX9hWrWdpw1nHbA6wGasvuFXpuyRSgempAhLkbmLrBAJiCof2ZL4\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mhfjgs9rgcs38GecydznnT6fbXSynkKLPK\",\n \"pubkey\": \"tpubDA9GDAntyJu4QjQkMvLBgeD8ohuXQzrnvseJhfiEMrqYJuKvYgTVcNyao4mxcywauFZq5KnUgie6yeD8S7uD1GU5JiGSNDsYdagpNLiVDPH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mictvXCZLgkPyiZCVEfneWT1javUHbDDda\",\n \"pubkey\": \"tpubDA9GDAntyJu4y2UGwAiSkwS5PziP7ZuHQZ2u2zJutbaG9ZiknYx9PHCvtYBNM8iyGkW6X6cCDmeXUa3RoDJGdxTDmVWv1tVt4qaAf2tCLjz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mjMGYF9Lb8DskftCxfn5VB3oQijzjMW8h2\",\n \"pubkey\": \"tpubDA9GDAntyJu4YT9ZFtTS3VKXG1XUn2ZKAjrtWFDKqhTmgiDCSHcMdAVdGQiy1g4XXBxgGahVckxo8xoCx3BQGYmyUFWtmg9kd3XSbEJh2NB\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mjWEVAiNEFRzQtuAkMnH92J2eC2uEnw5eq\",\n \"pubkey\": \"tpubDA9GDAntyJu4aZP1j9usCH3fpB2NTYgopcSNCckgb3YEQmHK8YWmAXZXMfyUxwZQVFNCWjMX7yDmTMoKqfYozvHWZ3u3APLytYQVDBeWxwg\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mkD2mLM6souSC2gLWHgupf5HE27T8dP3y5\",\n \"pubkey\": \"tpubDA9GDAntyJu4LJ21ii3AJFhSYB7aRQ5BSTVRgXoxt7rx3Wat4SxWTS6CuNUEVJhE7VHBzMVCdvD9AucP9gEASv323RPKHpU1dfsPygvqCjx\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mkR5j6pFyNqtQXjEbwMW5Zf1uamnFhYCmU\",\n \"pubkey\": \"tpubDA9GDAntyJu4TqAJYPj6bcJkgXPkH2QwFZcFwnWVNAY1EypN8RFMPYWQDRE86tMfLqut3UpthmBqUDpHPbj2jsEZHDS3cuB5NcVp7KvJx9T\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mo9DWQ9o2ZxT4Zqnh6cY7bkJ8HkL2og7yH\",\n \"pubkey\": \"tpubDA9GDAntyJu4PZGHJzCD9g8vRVcdW4YsXDrN8iFbMvN6JPquVeckdS8CNBEApQTvfRSomSkkGfrVYFMnBN3RgeuBgpwB8hakS2FDeUchLEu\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"moehgmuVEGybMMLouZzTq75rFSg8ZvvzaQ\",\n \"pubkey\": \"tpubDA9GDAntyJu4Fer18DukQDtg7A6MYtG7211wQVjtFCRVRSaQxpseWDAPnP8K6B1oMxq54fmfh8EQqbVWEDsx3YRDLMoDyxJrDddZvCJEZiQ\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mombXRgLtvKym7WyfxRVZ6BrGe6fYKVQxq\",\n \"pubkey\": \"tpubDA9GDAntyJu4ohLVJHP8g52wXNXV1qT9Z56uVPuuvmYii7DWhCR1s1CHwy383KtXa8TMCZ8H8MFee8x96ZZJrfvV716zGvQp9fXUPhcF7RN\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mrFk9QmxRayMhz3hMysQinRcU75B7Zs5No\",\n \"pubkey\": \"tpubDA9GDAntyJu4f4bsRFEMn7y4sz2wRzY1KJdwhQsEqqvHLDS81Y3u4FGK6cC3DH3HGt9e9vRvMgsgL5NcJJnMVTkuFDqwQZbGiU4T7vSvyya\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mruc41ZrqK1yMoFganp1AXTpNHKBxJuhZo\",\n \"pubkey\": \"tpubDA9GDAntyJu4JMjkw7vVnukpCkqY6vjTYmz1XbXyz4r2EvpkpgW5AZVQ1YeXCSAHazLgsxRS4arBFsFkLoJN87LgT9HAfCST9owwJJYf5jm\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mrzmYmjAUKUM8thxDDhQaojZAVNC1ZH71k\",\n \"pubkey\": \"tpubDA9GDAntyJu4k8s5x82WpJLPbiCKMZ91MkkH2sqSuWWZqNTkkqQxyPih43ZxzWGggAhpdqAFHCrXH5ZdS7uUYVkT6HqAzZ27DLLD7actrd1\",\n \"Line truncated
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mfeQWMvmtnuZnSpGwjNDy33jQvgy2nu4vR\",\n \"pubkey\": \"tpubDA9GDAntyJu4Ytag2HiGb2Hrmgtjga1oSRTdWNZz6Vh6mW2yWyMkhKtJS9rH3ctZzPFvFhenoTfoArgceQgaLSXXQATSa9r5iVjAWHHxpBc\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mhgyiqzXraHQvoYN4oRsnmZGeB5e27v7X6\",\n \"pubkey\": \"tpubDA9GDAntyJu56nZDL32W3uoYzpZQ3HuE5zDDzVnCzNzgH3fAaHx2p8PgX9oETY13FKHdiiN8zZEgZHxGks6B12exJigtntT9FQTPrYpwuKH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"pubkey\": \"tpubDA9GDAntyJu4NUN7zjtAZaH7SwJJGrNw3GGXpLXus5dTmGEcHUsuAC9M7tH5oeirCACaY4kWWwo6zEFFYt8xK6JgUSSR24ZwmcHsbPaCxNr\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mjhaqbLhpch3DebPyWr21ppDGLukn1YSeh\",\n \"pubkey\": \"tpubDA9GDAntyJu4cZWdAgJTwKrWNEXdbNPrydUPVLiURVv6DmDYRTAAAMMW4y7RXJkPYNofLKohDGNPmbV6yNwnxVijRhxkVNYY4Ei6amXvrVA\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mk6aLnMyWNce5z7pkAFjT7VKvgddRfpuPZ\",\n \"pubkey\": \"tpubDA9GDAntyJu4V1BUGVmutJZCuz1TtuzwidW2b7masz8qtFuZmpJ7HZvVy95TL1MQpszsmuK5KgmEXXRzAfg2xRRituyqqaKtQHjxxHnyXtz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mkygHEMa1gckjft4HdnXdBCA2qNn8ocEnd\",\n \"pubkey\": \"tpubDA9GDAntyJu4juqLBa7brBP1W1x3G7XvPCTRqUsunQh7u2Ly3jmevsLu3BDmsFJUuwdLx38BTHa5ip6wVoFVqUinnp6EahBfd9uSDXZZrkM\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mmGWzcEtP4BYh2rxf82c9L7cdVyvbkxhfB\",\n \"pubkey\": \"tpubDA9GDAntyJu4XQhL61tDESr7XG7YnKJRzRM6hCvRxv4x3tMTqK2yv17k8qXWiVziW2jdFwbGpeVLkcdxonchVPj4beHsv8hRy1dfmipdrm3\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mn8SVfBD3117apKuXMVjVeefpeHVfni2xW\",\n \"pubkey\": \"tpubDA9GDAntyJu4QuRUc8EBJvTo74ZbvQiN1StbbZnFX6qBBCoVocV3VsFFC6SUteRFj2rJp2LGxUDXmQHcHqZa3LhFpKeCtguhimnxgKaYtYJ\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mnwPnyB24JZfXUqd7vn8MsMhmNTRkj4Amr\",\n \"pubkey\": \"tpubDA9GDAntyJu4LW5QvSz76VzXmRsAUoQ4otyRRnKz3yrANK2G39avPvQigzzVj1wVyYZxVqot7C6LjzdyFE5prYR49tcWJUYfFvqdnvy2FbG\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mo2ydnUzgxFX1YsZPuECeQxeRwiuR9haHK\",\n \"pubkey\": \"tpubDA9GDAntyJu4gTKzy4MShkNiFnhQxEZQ5S7y7nKtvhWFsxqQ8mGuSWCQJUGL4jdNcFFRU9neXyJaDjMZP3RuKTDXi5BFz6Ao7GFfc9cFmsn\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"moEwuQhAkg3hT7qhTjHXiFuf7KBcUhGzCt\",\n \"pubkey\": \"tpubDA9GDAntyJu52jXcb9gAsJXM1CVAabeFAktL9nw3yBoFWpE3m5mocdwDANmosEhdna2tUb2uuR6wBnFXR3RmQ3fsuHsEVucP3BcHquzKmXm\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"morR7jG1kXb7AbvQRXRYH554jpCnQkfXYg\",\n \"pubkey\": \"tpubDA9GDAntyJu4G59VFEdQaAoKs3LeNRP9rKTZ8a1rK5ocUPV8i8i9hbZiGbCgEFZiH3dGvf8Gstw7nbfxA5R5gum7Mf9GRa9vCi6xhXn7rPs\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mouye7ULsS8mZ6GDZ6t4LyNDKt1NR9YYxS\",\n \"pubkey\": \"tpubDA9GDAntyJu4wQF2sSaUSY4RpHuypUbKKbuVJz3Dyv4VZsnuMetXPVnx1RuGBgLAj8ARSqNe5xF9j6Y4JuBHca98YDS2DQxbzVbqsdDcAVw\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mpZtKoHsPTyPoUPdmhG6sDpj6AJeKWeB5g\",\n \"pubkey\": \"tpubDA9GDAntyJu4fHj1PXGSc2DLHTxwphZRVAg4qo8p56iUaigrzzgo3qSaeCEEMkKjUgBxy6oq8Y9Rfm6epyF7DTzcbMuYBRt8acTf4SAZpaT\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mqKfz8h1dEwid46RueaL1RSZ6KAACn4iPw\",\n \"pubkey\": \"tpubDA9GDAntyJu4JPiW5aSsNcqLb49zqbKNLVZcMhDKF5vWyv5XRzHFtbwKXPfNUW9mX7ahKiC9qUMxtGVtJP9oBVupKZFifEGXDEwZvWvXWMP\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"msSrvvj7mbVxFE65GQcGyTqfgjCqHGjRWS\",\n \"pubkey\": \"tpubDA9GDAntyJu4RA2NaDmVC8192ZULDVGbbsBFNv87jbjqfX6mtNHWVarfxJR9dEbxFivrJAfnggyg1ysVGWWa746mp4pXq9kKKG56HWnQDpJ\",\n \"Line truncated
|
||||
},
|
||||
{
|
||||
"title": "List addresses in specified account",
|
||||
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address list --account_id=\"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mgkp4JFgYEjG8WTwQ6z1NoNRCkar7qo57E\",\n \"pubkey\": \"tpubDA9GDAntyJu53xnNZzuzAsggGmoTegjyr4WFNYMecJt77s7UvHyPLXj4mZXSUwv32T3ai1gB5FnjMoHNezD53b9W7b14aV5XHLTgXw1ZDNp\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mgw44v5yrsj63HqNRgbKKnhsx3FNYLPhcz\",\n \"pubkey\": \"tpubDA9GDAntyJu4TPbn7DW5GuTPaEDjM7XgGhoi9UihhiUDvkMztgEeCMKjepZcSBKbEDHTpkFcinmwKxfrz4KkkC2QY5Q14DbVzBBf1s7uFjv\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mhGWq1gzorJaRL1JKRfX2GbJ2fBj6rMU46\",\n \"pubkey\": \"tpubDA9GDAntyJu4He6utE59U1DrugFsXPYngEbNKsrgrdtvpDicA8PzmrG3FZiVv8qANt3Z5e2UiMYmy5b6bgxT2nH7cfgYXP3155uqbgMzvpo\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mhXk5DN4DZ7Ja8YopzR8ZjbXxfPTikFsBq\",\n \"pubkey\": \"tpubDA9GDAntyJu4tmNfk9j1cHbPGCrM1V63c65vwTc9fh3ua8FM1oc6UW2eX9hWrWdpw1nHbA6wGasvuFXpuyRSgempAhLkbmLrBAJiCof2ZL4\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mhfjgs9rgcs38GecydznnT6fbXSynkKLPK\",\n \"pubkey\": \"tpubDA9GDAntyJu4QjQkMvLBgeD8ohuXQzrnvseJhfiEMrqYJuKvYgTVcNyao4mxcywauFZq5KnUgie6yeD8S7uD1GU5JiGSNDsYdagpNLiVDPH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mictvXCZLgkPyiZCVEfneWT1javUHbDDda\",\n \"pubkey\": \"tpubDA9GDAntyJu4y2UGwAiSkwS5PziP7ZuHQZ2u2zJutbaG9ZiknYx9PHCvtYBNM8iyGkW6X6cCDmeXUa3RoDJGdxTDmVWv1tVt4qaAf2tCLjz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mjMGYF9Lb8DskftCxfn5VB3oQijzjMW8h2\",\n \"pubkey\": \"tpubDA9GDAntyJu4YT9ZFtTS3VKXG1XUn2ZKAjrtWFDKqhTmgiDCSHcMdAVdGQiy1g4XXBxgGahVckxo8xoCx3BQGYmyUFWtmg9kd3XSbEJh2NB\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mjWEVAiNEFRzQtuAkMnH92J2eC2uEnw5eq\",\n \"pubkey\": \"tpubDA9GDAntyJu4aZP1j9usCH3fpB2NTYgopcSNCckgb3YEQmHK8YWmAXZXMfyUxwZQVFNCWjMX7yDmTMoKqfYozvHWZ3u3APLytYQVDBeWxwg\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mkD2mLM6souSC2gLWHgupf5HE27T8dP3y5\",\n \"pubkey\": \"tpubDA9GDAntyJu4LJ21ii3AJFhSYB7aRQ5BSTVRgXoxt7rx3Wat4SxWTS6CuNUEVJhE7VHBzMVCdvD9AucP9gEASv323RPKHpU1dfsPygvqCjx\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mkR5j6pFyNqtQXjEbwMW5Zf1uamnFhYCmU\",\n \"pubkey\": \"tpubDA9GDAntyJu4TqAJYPj6bcJkgXPkH2QwFZcFwnWVNAY1EypN8RFMPYWQDRE86tMfLqut3UpthmBqUDpHPbj2jsEZHDS3cuB5NcVp7KvJx9T\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mo9DWQ9o2ZxT4Zqnh6cY7bkJ8HkL2og7yH\",\n \"pubkey\": \"tpubDA9GDAntyJu4PZGHJzCD9g8vRVcdW4YsXDrN8iFbMvN6JPquVeckdS8CNBEApQTvfRSomSkkGfrVYFMnBN3RgeuBgpwB8hakS2FDeUchLEu\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"moehgmuVEGybMMLouZzTq75rFSg8ZvvzaQ\",\n \"pubkey\": \"tpubDA9GDAntyJu4Fer18DukQDtg7A6MYtG7211wQVjtFCRVRSaQxpseWDAPnP8K6B1oMxq54fmfh8EQqbVWEDsx3YRDLMoDyxJrDddZvCJEZiQ\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mombXRgLtvKym7WyfxRVZ6BrGe6fYKVQxq\",\n \"pubkey\": \"tpubDA9GDAntyJu4ohLVJHP8g52wXNXV1qT9Z56uVPuuvmYii7DWhCR1s1CHwy383KtXa8TMCZ8H8MFee8x96ZZJrfvV716zGvQp9fXUPhcF7RN\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mrFk9QmxRayMhz3hMysQinRcU75B7Zs5No\",\n \"pubkey\": \"tpubDA9GDAntyJu4f4bsRFEMn7y4sz2wRzY1KJdwhQsEqqvHLDS81Y3u4FGK6cC3DH3HGt9e9vRvMgsgL5NcJJnMVTkuFDqwQZbGiU4T7vSvyya\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mruc41ZrqK1yMoFganp1AXTpNHKBxJuhZo\",\n \"pubkey\": \"tpubDA9GDAntyJu4JMjkw7vVnukpCkqY6vjTYmz1XbXyz4r2EvpkpgW5AZVQ1YeXCSAHazLgsxRS4arBFsFkLoJN87LgT9HAfCST9owwJJYf5jm\",\n \"used_times\": 0\n },\n {\n \"account\": \"mfjMRYrR8Pww5cvDn1bfDEyMag5BNp3pAk\",\n \"address\": \"mrzmYmjAUKUM8thxDDhQaojZAVNC1ZH71k\",\n \"pubkey\": \"tpubDA9GDAntyJu4k8s5x82WpJLPbiCKMZ91MkkH2sqSuWWZqNTkkqQxyPih43ZxzWGggAhpdqAFHCrXH5ZdS7uUYVkT6HqAzZ27DLLD7actrd1\",\n \"Line truncated
|
||||
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address list --account_id=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mfeQWMvmtnuZnSpGwjNDy33jQvgy2nu4vR\",\n \"pubkey\": \"tpubDA9GDAntyJu4Ytag2HiGb2Hrmgtjga1oSRTdWNZz6Vh6mW2yWyMkhKtJS9rH3ctZzPFvFhenoTfoArgceQgaLSXXQATSa9r5iVjAWHHxpBc\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mhgyiqzXraHQvoYN4oRsnmZGeB5e27v7X6\",\n \"pubkey\": \"tpubDA9GDAntyJu56nZDL32W3uoYzpZQ3HuE5zDDzVnCzNzgH3fAaHx2p8PgX9oETY13FKHdiiN8zZEgZHxGks6B12exJigtntT9FQTPrYpwuKH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"pubkey\": \"tpubDA9GDAntyJu4NUN7zjtAZaH7SwJJGrNw3GGXpLXus5dTmGEcHUsuAC9M7tH5oeirCACaY4kWWwo6zEFFYt8xK6JgUSSR24ZwmcHsbPaCxNr\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mjhaqbLhpch3DebPyWr21ppDGLukn1YSeh\",\n \"pubkey\": \"tpubDA9GDAntyJu4cZWdAgJTwKrWNEXdbNPrydUPVLiURVv6DmDYRTAAAMMW4y7RXJkPYNofLKohDGNPmbV6yNwnxVijRhxkVNYY4Ei6amXvrVA\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mk6aLnMyWNce5z7pkAFjT7VKvgddRfpuPZ\",\n \"pubkey\": \"tpubDA9GDAntyJu4V1BUGVmutJZCuz1TtuzwidW2b7masz8qtFuZmpJ7HZvVy95TL1MQpszsmuK5KgmEXXRzAfg2xRRituyqqaKtQHjxxHnyXtz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mkygHEMa1gckjft4HdnXdBCA2qNn8ocEnd\",\n \"pubkey\": \"tpubDA9GDAntyJu4juqLBa7brBP1W1x3G7XvPCTRqUsunQh7u2Ly3jmevsLu3BDmsFJUuwdLx38BTHa5ip6wVoFVqUinnp6EahBfd9uSDXZZrkM\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mmGWzcEtP4BYh2rxf82c9L7cdVyvbkxhfB\",\n \"pubkey\": \"tpubDA9GDAntyJu4XQhL61tDESr7XG7YnKJRzRM6hCvRxv4x3tMTqK2yv17k8qXWiVziW2jdFwbGpeVLkcdxonchVPj4beHsv8hRy1dfmipdrm3\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mn8SVfBD3117apKuXMVjVeefpeHVfni2xW\",\n \"pubkey\": \"tpubDA9GDAntyJu4QuRUc8EBJvTo74ZbvQiN1StbbZnFX6qBBCoVocV3VsFFC6SUteRFj2rJp2LGxUDXmQHcHqZa3LhFpKeCtguhimnxgKaYtYJ\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mnwPnyB24JZfXUqd7vn8MsMhmNTRkj4Amr\",\n \"pubkey\": \"tpubDA9GDAntyJu4LW5QvSz76VzXmRsAUoQ4otyRRnKz3yrANK2G39avPvQigzzVj1wVyYZxVqot7C6LjzdyFE5prYR49tcWJUYfFvqdnvy2FbG\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mo2ydnUzgxFX1YsZPuECeQxeRwiuR9haHK\",\n \"pubkey\": \"tpubDA9GDAntyJu4gTKzy4MShkNiFnhQxEZQ5S7y7nKtvhWFsxqQ8mGuSWCQJUGL4jdNcFFRU9neXyJaDjMZP3RuKTDXi5BFz6Ao7GFfc9cFmsn\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"moEwuQhAkg3hT7qhTjHXiFuf7KBcUhGzCt\",\n \"pubkey\": \"tpubDA9GDAntyJu52jXcb9gAsJXM1CVAabeFAktL9nw3yBoFWpE3m5mocdwDANmosEhdna2tUb2uuR6wBnFXR3RmQ3fsuHsEVucP3BcHquzKmXm\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"morR7jG1kXb7AbvQRXRYH554jpCnQkfXYg\",\n \"pubkey\": \"tpubDA9GDAntyJu4G59VFEdQaAoKs3LeNRP9rKTZ8a1rK5ocUPV8i8i9hbZiGbCgEFZiH3dGvf8Gstw7nbfxA5R5gum7Mf9GRa9vCi6xhXn7rPs\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mouye7ULsS8mZ6GDZ6t4LyNDKt1NR9YYxS\",\n \"pubkey\": \"tpubDA9GDAntyJu4wQF2sSaUSY4RpHuypUbKKbuVJz3Dyv4VZsnuMetXPVnx1RuGBgLAj8ARSqNe5xF9j6Y4JuBHca98YDS2DQxbzVbqsdDcAVw\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mpZtKoHsPTyPoUPdmhG6sDpj6AJeKWeB5g\",\n \"pubkey\": \"tpubDA9GDAntyJu4fHj1PXGSc2DLHTxwphZRVAg4qo8p56iUaigrzzgo3qSaeCEEMkKjUgBxy6oq8Y9Rfm6epyF7DTzcbMuYBRt8acTf4SAZpaT\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mqKfz8h1dEwid46RueaL1RSZ6KAACn4iPw\",\n \"pubkey\": \"tpubDA9GDAntyJu4JPiW5aSsNcqLb49zqbKNLVZcMhDKF5vWyv5XRzHFtbwKXPfNUW9mX7ahKiC9qUMxtGVtJP9oBVupKZFifEGXDEwZvWvXWMP\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"msSrvvj7mbVxFE65GQcGyTqfgjCqHGjRWS\",\n \"pubkey\": \"tpubDA9GDAntyJu4RA2NaDmVC8192ZULDVGbbsBFNv87jbjqfX6mtNHWVarfxJR9dEbxFivrJAfnggyg1ysVGWWa746mp4pXq9kKKG56HWnQDpJ\",\n \"Line truncated
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -905,7 +905,7 @@
|
||||
"curl": "curl -d'{\"method\": \"address_unused\", \"params\": {}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address unused",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_unused\", \"params\": {}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"mjEFq6JGQWFVj45vYxybnWgYAMYjfpDQ91\"\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X\"\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -940,13 +940,6 @@
|
||||
"returns": "(bool) true if successful",
|
||||
"examples": []
|
||||
},
|
||||
{
|
||||
"name": "blob_clean",
|
||||
"description": "Deletes blobs to cleanup disk space",
|
||||
"arguments": [],
|
||||
"returns": "(bool) true if successful",
|
||||
"examples": []
|
||||
},
|
||||
{
|
||||
"name": "blob_delete",
|
||||
"description": "Delete a blob",
|
||||
@@ -962,10 +955,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Delete a blob",
|
||||
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"a6ee32b7ce053c060ff9a5670cb1e5d8b4746d70e9451ce301089ef30c3c6cf581cb1afc6628122956b39f4a1b4c210d\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet blob delete a6ee32b7ce053c060ff9a5670cb1e5d8b4746d70e9451ce301089ef30c3c6cf581cb1afc6628122956b39f4a1b4c210d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"a6ee32b7ce053c060ff9a5670cb1e5d8b4746d70e9451ce301089ef30c3c6cf581cb1afc6628122956b39f4a1b4c210d\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted a6ee32b7ce053c060ff9a5670cb1e5d8b4746d70e9451ce301089ef30c3c6cf581cb1afc6628122956b39f4a1b4c210d\"\n}"
|
||||
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet blob delete c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\"\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1020,7 +1013,7 @@
|
||||
{
|
||||
"name": "sd_hash",
|
||||
"type": "str",
|
||||
"description": "filter blobs in a stream by sd hash, ie the hash of the stream descriptor blob for a stream that has been downloaded",
|
||||
"description": "filter blobs by sd hash",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
@@ -1043,7 +1036,7 @@
|
||||
"curl": "curl -d'{\"method\": \"blob_list\", \"params\": {\"needed\": false, \"finished\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet blob list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_list\", \"params\": {\"needed\": false, \"finished\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n \"a6ee32b7ce053c060ff9a5670cb1e5d8b4746d70e9451ce301089ef30c3c6cf581cb1afc6628122956b39f4a1b4c210d\",\n \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"ebd8f9c608071aef7aacd35aa21661ab8c074091482783b66d435af30dc41437274584ffa9e72a5d7371cbd02e3c1306\",\n \"7156e1fcf35440bdba316dfbae88896855be0816c4fd4adefa0ad1871edb247681ba415b6f27fd10e6b46431b6746e0b\"\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 4,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\",\n \"a6f0d442c48c63004f85151f3424da59c9e358680c60174202a174e1a9d2152e909cfca24ef182c0fcf44e91978a9121\",\n \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"9656965659aa2e1e3e4b07e2ad6047c13341769af4742ff1bca364682dbff614e3761cfb0a4fece29155331110611a10\"\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 4,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1124,10 +1117,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Abandon a channel claim",
|
||||
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel abandon c9949c3c51f35e18da91c1dc85d1caf061ddfb17",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001168dd44f7e5dd7156e278b452943aeaf264493009184d936eb23dee2df2d564e000000006a47304402207f1203d7620ea29f417c23cb1134d67cd945f3ba3ba783d3ea1f97f19d9a2c8f02204d0e4a250d36d251bd6a020a2a177460a0e51dc67916814644a0d9af56b51f420121023ac5e880441805724e0934e7ec14acec856c87cbda631735e1d4480da71215fbffffffff0134b7f505000000001976a9142f7cbbec4c0b813878ded67230029bb93bf3623c88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 9,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mjr3UkC2brEFViLpZKUHUP6LzCMGfwfEuP\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"130221a7c8d8a6a21244157148835c16f97fc6b82ffce94a7b9848c66d365dd1\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"130221a7c8d8a6a21244157148835c16f97fc6b82ffce94a7b9848c66d365dd1\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel abandon 20ccc609603f9c6f01d74f2d6a133867d2903fc2",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001942c37d36793290feb0e2ab637e6da02b1eea67d85a872dff83c8b0c19a322ff000000006b48304502210097bf5a07e8051956c2f9291207c7cd5acb4becbb4057ceeff56f55cd00d34b2902200b99e51cb96ea088fd76a914348d8487e6e22c74edff84e4573f54572d9d426c01210353931cc595ec3293186c7f9d63a8e1b8aecc5cc4fd0e010092d2b40483213902ffffffff0134b7f505000000001976a9140bc6abe6b62ea58b85132979e66092310a33ab5588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 9,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mgbDj6pkqZoTouwLRaAfCTueUTyZRHMCbB\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"5a1104a6f7094b070fe9b286204903e05c0982124436d9d68d8f3de26993033d\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"5a1104a6f7094b070fe9b286204903e05c0982124436d9d68d8f3de26993033d\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1257,14 +1250,14 @@
|
||||
"curl": "curl -d'{\"method\": \"channel_create\", \"params\": {\"name\": \"@channel\", \"bid\": \"1.0\", \"featured\": [], \"tags\": [], \"languages\": [], \"locations\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel create @channel 1.0",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_create\", \"params\": {\"name\": \"@channel\", \"bid\": \"1.0\", \"featured\": [], \"tags\": [], \"languages\": [], \"locations\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001cbc667e72a8880a5dcdbd4f613a914bd838f0a51f753c53127e1606c785df895010000006b483045022100f1ddbbed34b688ee4469cc6c248cb3f9922284607b12e2397263e4a40594838b02204feea4d5525dc9e4a07489af469911eda4367fca14bc18cca907a3615bde9045012103dc7c4fadc330b72a5eb7ff89c01e57ba241f870f9b0f41bb1d691de5819f3660ffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead6d7576a914371e9c80db93ed666338f705d0092a8f18b2526d88acc462a029000000001976a914ad7934994a66145964b482ab7070d747ccd001d488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mwxEvAcUgiYGEjrJPNg51rzPvQgCUfvYEn\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"nout\": 1,\n \"timestamp\": 1634935408,\n \"txid\": \"95f85d786c60e12731c553f7510a8f83bd14a913f6d4dbdca580882ae767c6cb\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": null,\n \"txid\": \"0f862973dcd3279dc53a54f0026446edf69184689bbdf6ed178983bf8a211156\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mwLCPk6wpNzHXZ8k8JzaMJu1Uig8Kw8qiQ\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"0f862973dcd3279dc53a54f0026446edf69184689bbdf6ed178983bf8a211156\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"0f862973dcd3279dc53a54f0026446edf69184689bbdf6ed178983bf8a211156\"\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001a2a08aed2135620a6c05793822961a98dc9cccb41eb629d6865dc29b2dccf0d0010000006b483045022100c5400dc6883d3a4bbc7856ce2398ce65cb1f3c78c7656898c5dc50a1e2becf2702206d1544c74b380cb5b5e2bbdabe19c15e9115f2cea5566eb9defba3a6b0f196fd012103755009dd0af23759ad72b338313e1f9635070afebd056af92a62a4f6cb5b0353ffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b866d7576a91433ad5a86909d2aeb60f6bb427cfaf9acfd51078e88acc462a029000000001976a9143941a8e680e7196066423b400ac8edd4549c35de88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mjRVJULUCxB7s3guxUriGqN5C7RFj6Fsxh\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": null,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mkjhU7Go11ZuCbGEp6edSr4At5CBDW23xH\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\"\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Create a channel claim with all metadata",
|
||||
"curl": "curl -d'{\"method\": \"channel_create\", \"params\": {\"name\": \"@bigchannel\", \"bid\": \"1.0\", \"title\": \"Big Channel\", \"description\": \"A channel with lots of videos.\", \"email\": \"creator@smallmedia.com\", \"website_url\": \"http://smallmedia.com\", \"featured\": [], \"tags\": [\"music\", \"art\"], \"languages\": [\"pt-BR\", \"uk\"], \"locations\": [\"BR\", \"UA::Kiyv\"], \"thumbnail_url\": \"http://smallmedia.com/logo.jpg\", \"cover_url\": \"http://smallmedia.com/logo.jpg\", \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel create @bigchannel 1.0 --title=\"Big Channel\" --description=\"A channel with lots of videos.\" --email=\"creator@smallmedia.com\" --tags=music --tags=art --languages=pt-BR --languages=uk --locations=BR --locations=UA::Kiyv --website_url=\"http://smallmedia.com\" --thumbnail_url=\"http://smallmedia.com/logo.jpg\" --cover_url=\"http://smallmedia.com/logo.jpg\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_create\", \"params\": {\"name\": \"@bigchannel\", \"bid\": \"1.0\", \"title\": \"Big Channel\", \"description\": \"A channel with lots of videos.\", \"email\": \"creator@smallmedia.com\", \"website_url\": \"http://smallmedia.com\", \"featured\": [], \"tags\": [\"music\", \"art\"], \"languages\": [\"pt-BR\", \"uk\"], \"locations\": [\"BR\", \"UA::Kiyv\"], \"thumbnail_url\": \"http://smallmedia.com/logo.jpg\", \"cover_url\": \"http://smallmedia.com/logo.jpg\", \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001168dd44f7e5dd7156e278b452943aeaf264493009184d936eb23dee2df2d564e010000006b483045022100c24dd961bd552cfe27ffa503ea7e0a761097892f8e6f70d027817076001acd3f02201b001771d7231bbc36f5e69ed6ea27b00545a8305ccc3bd1a31720c9efe040d20121028849a6d8df7a0508197329a0832b4e4cab1cee65a59b362caa37c31f666650f5ffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a034200040d46c1f999b0feefc85b96ab8454dbc0aec90e261d0d3c19d9699eb6713b7211c56789f67c109655b03d3b837562ed155813471855783e3fc7389386feb76098121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a914ce906c391c5d93a6a75330ae90cffcdea8fdbf7b88ace221d305000000001976a9140af22b545d45c92b9f7868ae9b3f651256e3d31788ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mw96HgE4jD7nBP6FRnurCrVygYa5Jcp6aU\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"nout\": 1,\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzMAWEqhHba2L35SK2pQHBSuTDqYKbHXg4\",\n \"amount\": \"1.0\",\n \"claim_id\": \"52fdfa5f9e431b9db23e3e842ff0d386ba8c2c78\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@bigchannel\",\n \"normalized_name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#52fdfa5f9e431b9db23e3e842ff0d386ba8c2c78\",\n \"timestamp\": null,\n \"txid\": \"bcd1ce1879259b46731f1eb6675ba766ef3ddd066532359ce54febbbb99995ad\",\n \"type\": \"claim\",\n \"value\": {\n \"cover\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"description\": \"A channel with lots of videos.\",\n \"email\": \"creator@smallmedia.com\",\n \"languages\": [\n \"pt-BR\",\n \"uk\"\n ],\n \"locations\": [\n {\n \"country\": \"BR\"\n },\n {\n \"city\": \"Kiyv\",\n \"country\": \"UA\"\n }\n ],\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200040d46c1f999b0feefc85b96ab8454dbc0aec90e261d0d3c19d9699eb6713b7211c56789f67c109655b03d3b837562ed155813471855783e3fc7389386feb76098\",\n \"public_key_id\": \"mhfrTY9VPkSxJDTiHth6num47kaVfBuAFE\",\n \"tags\": [\n \"music\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"title\": \"Big Channel\",\n \"website_url\": \"http://smallmedia.com\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mgWqABp4HumxP1Ezw4XqbfKud2DgbyuwNq\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"bcd1ce1879259b46731f1eb6675ba766ef3ddd066532359ce54febbbb99995ad\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"bcd1ce1879259b46731f1eb6675ba766ef3ddd066532359ce54febbbb99995ad\"\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001942c37d36793290feb0e2ab637e6da02b1eea67d85a872dff83c8b0c19a322ff010000006b483045022100f3ffa25ac1f85a5401eab38c796a4bce7af42d230142617634731f22256662f102207373f746f06fefe1b8998dae433b8aa01816c388d1ffb2c03ba0cab67cc9cbe8012103f10e8cfbe3f83dfa4ac39c22d5bf47b3bbfa96c7a43ab951c0480b9956bf86dcffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a03420004cd1aec7a333657cd8e881fd07817e7ddf71edee513a954bc118608348a94945066d352a9397937944db8ae9f30c87d937a200ad5e9c549a306fe542d618def4d121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a9144db8fdeee2015a424c5ba86fa68b7261bd8c33d088ace221d305000000001976a914a03ab95f4d7565fff8a76ff10859fb5fc0572f7f88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mxfwopyUuJxZQZXA7HvmGQXk9jVMLC97gr\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnbuwHjbMJRqWHMhqzo2Co8QvMLfA7RPzL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"d877c978e04ff30ccbd8133ca07116064430f4eb\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@bigchannel\",\n \"normalized_name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#d877c978e04ff30ccbd8133ca07116064430f4eb\",\n \"timestamp\": null,\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\",\n \"type\": \"claim\",\n \"value\": {\n \"cover\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"description\": \"A channel with lots of videos.\",\n \"email\": \"creator@smallmedia.com\",\n \"languages\": [\n \"pt-BR\",\n \"uk\"\n ],\n \"locations\": [\n {\n \"country\": \"BR\"\n },\n {\n \"city\": \"Kiyv\",\n \"country\": \"UA\"\n }\n ],\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004cd1aec7a333657cd8e881fd07817e7ddf71edee513a954bc118608348a94945066d352a9397937944db8ae9f30c87d937a200ad5e9c549a306fe542d618def4d\",\n \"public_key_id\": \"mwHUnTRHRMZRvQUK8h15HihHQ5Ujz3mybi\",\n \"tags\": [\n \"music\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"title\": \"Big Channel\",\n \"website_url\": \"http://smallmedia.com\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mv8AkyC2tGywD9ARYqEkznnjM7gs8LG17A\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1386,14 +1379,14 @@
|
||||
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"0f862973dcd3279dc53a54f0026446edf69184689bbdf6ed178983bf8a211156\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Paginate your channel claims",
|
||||
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel list --page=1 --page_size=20",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"0f862973dcd3279dc53a54f0026446edf69184689bbdf6ed178983bf8a211156\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1588,10 +1581,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Update a channel claim",
|
||||
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel update c9949c3c51f35e18da91c1dc85d1caf061ddfb17 --title=\"New Channel\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000025611218abf838917edf6bd9b688491f6ed466402f0543ac59d27d3dc7329860f000000006b483045022100e8a1cbb2219de445df8d9ed897c525bbd5f6744f40b6e37c0d60a2c0dc93cc62022079fa61f864d2a6915dc2fa9385afd08a4d0a1d1c103b9b55c1e5af252aa56bab0121023ac5e880441805724e0934e7ec14acec856c87cbda631735e1d4480da71215fbffffffff985ebf43004778e15e4e5a5844330243666f6ac75b96f87847d38cc494bf934f000000006b483045022100b4e92967b07f7c3001b8916c9cc90874d668e4697e40741a852e7987b9d253df02207a1b29490b66748a71a9c62b6c5ee66df8066f383ca66cd4d779b8ddb4851aa60121025397272c2c1490ab96c3001c231b90bebe77e478c05da12ed3c6f8d9bb4111edffffffff0200e1f50500000000a6b708406368616e6e656c1417fbdd61f0cad185dcc191da185ef3513c9c94c94c6a00125a0a583056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead420b4e6577204368616e6e656c6d6d76a914371e9c80db93ed666338f705d0092a8f18b2526d88ac6ebeea0b000000001976a914ab5f88b58bfbaa1073128bb0afb07113c172968988ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"0f862973dcd3279dc53a54f0026446edf69184689bbdf6ed178983bf8a211156\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mr35sX74Yo1aZkF72DwHu4RjTBcMQvSaxF\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"nout\": 0,\n \"timestamp\": 1634935408,\n \"txid\": \"4f93bf94c48cd34778f8965bc76a6f6643023344585a4e5ee178470043bf5e98\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": null,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mw96HgE4jD7nBP6FRnurCrVygYa5Jcp6aU\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel update 20ccc609603f9c6f01d74f2d6a133867d2903fc2 --title=\"New Channel\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000002bb384e08ba07d2a2881a4b7bbaca52623e4e9b4802750411a0e0eba84d960aeb000000006b483045022100f86030e4a9e901fcfd8ac8b89d7341ae03f9ef73a7019c282ffedcc6f4c24e0502206e6f7ad8b6eff9b6ea13f6ac1866af80d5ab132a4bad19a9afd8ad407c268ef001210353931cc595ec3293186c7f9d63a8e1b8aecc5cc4fd0e010092d2b40483213902fffffffff5b85f1547c5ec0ed1940d5fe14da6d48f86948c2a5dd1bc4abbfa103d080dac000000006b483045022100816dd9784eb76b97ed127984f5d42b19a8368de3d5a7ef79733500662cb28c39022025f20e6d5820987af30253bd8002940e54e177b1ee188e0422cb939e6fc90af701210211196ea4ea6217ea95455ee10e84bb9d5fc615e7b7e852a1a34e04acb50b108dffffffff0200e1f50500000000a6b708406368616e6e656c14c23f90d26738136a2d4fd7016f9c3f6009c6cc204c6a00125a0a583056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86420b4e6577204368616e6e656c6d6d76a91433ad5a86909d2aeb60f6bb427cfaf9acfd51078e88ac6ebeea0b000000001976a914bc2d79ca1969aceba4290c8f8f04677062d2376b88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"ms6EPFDDfSb3gVMgyBZ5drGuYH9uqvvmPq\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"nout\": 0,\n \"timestamp\": 1621405355,\n \"txid\": \"ac0d083d10fabb4abcd15d2a8c94868fd4a64de15f0d94d10eecc547155fb8f5\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": null,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mxfwopyUuJxZQZXA7HvmGQXk9jVMLC97gr\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1702,14 +1695,14 @@
|
||||
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet claim list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Paginate your claims",
|
||||
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet claim list --page=1 --page_size=20",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2067,14 +2060,14 @@
|
||||
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"claim_ids\": [], \"channel\": \"@channel\", \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet claim search --channel=@channel",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"claim_ids\": [], \"channel\": \"@channel\", \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c/astream#6\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 214,\n \"creation_height\": 213,\n \"creation_timestamp\": 1634935409,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 714,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"short_url\": \"lbry://astream#6\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 210,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1634935408,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 710,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"short_url\": \"lbry://@channel#c\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Search for claims matching a name",
|
||||
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"claim_ids\": [], \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet claim search --name=\"astream\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"claim_ids\": [], \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c/astream#6\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 214,\n \"creation_height\": 213,\n \"creation_timestamp\": 1634935409,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 714,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"short_url\": \"lbry://astream#6\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 210,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1634935408,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 710,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"short_url\": \"lbry://@channel#c\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2262,10 +2255,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Create a collection of one stream",
|
||||
"curl": "curl -d'{\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet collection create --name=tom --bid=1.0 --channel_id=c9949c3c51f35e18da91c1dc85d1caf061ddfb17 --claims=64f38c5077c3bc0a02b34ea214ac899c7caa5f19",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000147676fa2814923321dfaa9b75835d696afe2ec014ec270e4a1f65e82404448cd010000006a47304402202c612bfbb8d4cf41d129eb27b4c93ff084275ac2169f3d2a15ef92c33e3c20000220145d738f608c4dd41c6adccc499d357ab22e509d17bacccff2e6b06e22e68ab401210347c98ebb2eec13419e321cee2f5afff104f65c127c58a76e9319b99b17ccada7ffffffff0200e1f5050000000091b503746f6d4c6f0117fbdd61f0cad185dcc191da185ef3513c9c94c9709f2b8d722805ae932dbd1a20313013b7b5a5a611ff364b5aa981a6dcd7bd795222a7975032556583d7bcb4214dc226530a4ff10da199876e98d923b0abe2bc1a1812160a14195faa7c9c89ac14a24eb3020abcc377508cf3646d7576a91462ea7827ecd509c68fa0896c570f578248aa30c688ac202c7e17000000001976a9148029279eb18f5c1f59ccda146580d858fbb2e19788ac00000000\",\n \"inputs\": [\n {\n \"address\": \"miXbvs1SLCShXkSSazePHZVLU5FG2uUbKg\",\n \"amount\": \"4.947555\",\n \"confirmations\": 2,\n \"height\": 215,\n \"nout\": 1,\n \"timestamp\": 1634935409,\n \"txid\": \"cd484440825ef6a1e470c24e01ece2af96d63558b7a9fa1d32234981a26f6747\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mpXyQ521vz53oHTjskz8rhKLf7wS3xz7kz\",\n \"amount\": \"1.0\",\n \"claim_id\": \"447eaf49fd8f030531dd6f8b490761b37e2e772c\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"tom\",\n \"normalized_name\": \"tom\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://tom#447eaf49fd8f030531dd6f8b490761b37e2e772c\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"7915d6bb27061c2e3a2d3b79938beca760865ecc7032d1481967285603df496b\",\n \"type\": \"claim\",\n \"value\": {\n \"claims\": [\n \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"\n ]\n },\n \"value_type\": \"collection\"\n },\n {\n \"address\": \"msCc66GAkDKNYiuMJji5iKo7QVTUXnX7p4\",\n \"amount\": \"3.941448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"7915d6bb27061c2e3a2d3b79938beca760865ecc7032d1481967285603df496b\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.006107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.941448\",\n \"txid\": \"7915d6bb27061c2e3a2d3b79938beca760865ecc7032d1481967285603df496b\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet collection create --name=tom --bid=1.0 --channel_id=20ccc609603f9c6f01d74f2d6a133867d2903fc2 --claims=ea41b9f807c6982cf97a1178838dfef64feaa014",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000011552a7efeb31dafb72d77acd8dff177d3ab93525ed1b9abde9997412348ae34f010000006b483045022100ec009f539259e608e0a876beb86bfc7cc5439b8d0fe09188ec5711cda2f49e5902207a58d4af049513c5ccd6f1bdd24bc0d7e16f823027e436523f8bb939a69fc530012102b9174bcb2bb1f01a1c17be57386fdb7922f5cabfdeccb0318611ecbc554337cbffffffff0200e1f5050000000091b503746f6d4c6f01c23f90d26738136a2d4fd7016f9c3f6009c6cc20ab977ae13013c5115619502f2a730af6fd385eb74fd78cd7d3df1c0d01d32002e25f9bdfbd15db7a8bd557ffdcdacf475204b1f6df7de65ef174c1a0a43232b01a1812160a1414a0ea4ff6fe8d8378117af92c98c607f8b941ea6d7576a914f27bcbde9870d0d372378d0e2f33bbb92ce0194588ac202c7e17000000001976a91410011067a2603a2f53b941403aec639db140561488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n1V4V9jbac2vgqPKghf7uCw9AJ51unJhfd\",\n \"amount\": \"4.947555\",\n \"confirmations\": 2,\n \"height\": 215,\n \"nout\": 1,\n \"timestamp\": 1621405356,\n \"txid\": \"4fe38a34127499e9bd9a1bed2535b93a7d17ff8dcd7ad772fbda31ebefa75215\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n3d67zugu7tXuuBLhAajnSt56j9Yv2yQ2w\",\n \"amount\": \"1.0\",\n \"claim_id\": \"e60f8f8c2252950c925a4bbb0efa4165aa7a0055\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"tom\",\n \"normalized_name\": \"tom\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://tom#e60f8f8c2252950c925a4bbb0efa4165aa7a0055\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\",\n \"type\": \"claim\",\n \"value\": {\n \"claims\": [\n \"ea41b9f807c6982cf97a1178838dfef64feaa014\"\n ]\n },\n \"value_type\": \"collection\"\n },\n {\n \"address\": \"mgyaP4FvA3DLPfatc7bfJS8a62c2AHQZH1\",\n \"amount\": \"3.941448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.006107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.941448\",\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2317,7 +2310,7 @@
|
||||
"curl": "curl -d'{\"method\": \"collection_list\", \"params\": {\"resolve_claims\": 1, \"resolve\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet collection list --resolve --resolve_claims=1",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"collection_list\", \"params\": {\"resolve_claims\": 1, \"resolve\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mpXyQ521vz53oHTjskz8rhKLf7wS3xz7kz\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c/tom#4\",\n \"claim_id\": \"447eaf49fd8f030531dd6f8b490761b37e2e772c\",\n \"claim_op\": \"create\",\n \"claims\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c/astream#6\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 214,\n \"creation_height\": 213,\n \"creation_timestamp\": 1634935409,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 714,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"short_url\": \"lbry://astream#6\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#c\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 210,\n \"claims_in_channel\": 2,\n \"creation_height\": 209,\n \"creation_timestamp\": 1634935408,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 710,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"short_url\": \"lbry://@channel#c\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"confirmations\": 1,\n \"height\": 217,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 217,\n \"creation_height\": 217,\n \"creation_timestamp\": 1634935409,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 717,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 217\n },\n \"name\": \"tom\",\n \"normalized_name\": \"tom\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://tom#447eaf49fd8f030531dd6f8b490761b37e2e772c\",\n \"short_url\": \"lbry://tom#4\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n Line truncated
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"n3d67zugu7tXuuBLhAajnSt56j9Yv2yQ2w\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/tom#e\",\n \"claim_id\": \"e60f8f8c2252950c925a4bbb0efa4165aa7a0055\",\n \"claim_op\": \"create\",\n \"claims\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 2,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"confirmations\": 1,\n \"height\": 217,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 217,\n \"creation_height\": 217,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263191,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 217,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\"Line truncated
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2489,6 +2482,373 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"comment": {
|
||||
"doc": "View, create and abandon comments.",
|
||||
"commands": [
|
||||
{
|
||||
"name": "comment_abandon",
|
||||
"description": "Abandon a comment published under your channel identity.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "comment_id",
|
||||
"type": "str",
|
||||
"description": "The ID of the comment to be abandoned.",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "restrict operation to specific wallet",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "(dict) Object with the `comment_id` passed in as the key, and a flag indicating if it was abandoned\n {\n <comment_id> (str): {\n \"abandoned\": (bool)\n }\n }",
|
||||
"examples": [
|
||||
{
|
||||
"title": "Abandon a comment",
|
||||
"curl": "curl -d'{\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment abandon 137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\": {\n \"abandoned\": true\n }\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "comment_create",
|
||||
"description": "Create and associate a comment with a claim using your channel identity.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "comment",
|
||||
"type": "str",
|
||||
"description": "Comment to be made, should be at most 2000 characters.",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "claim_id",
|
||||
"type": "str",
|
||||
"description": "The ID of the claim to comment on",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "parent_id",
|
||||
"type": "str",
|
||||
"description": "The ID of a comment to make a response to",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_id",
|
||||
"type": "str",
|
||||
"description": "The ID of the channel you want to post under",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_name",
|
||||
"type": "str",
|
||||
"description": "The channel you want to post as, prepend with a '@'",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_account_id",
|
||||
"type": "str",
|
||||
"description": "one or more account ids for accounts to look in for channel certificates, defaults to all accounts",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "restrict operation to specific wallet",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "(dict) Comment object if successfully made, (None) otherwise\n {\n \"comment\": (str) The actual string as inputted by the user,\n \"comment_id\": (str) The Comment's unique identifier,\n \"claim_id\": (str) The claim commented on,\n \"channel_name\": (str) Name of the channel this was posted under, prepended with a '@',\n \"channel_id\": (str) The Channel Claim ID that this comment was posted under,\n \"is_pinned\": (boolean) Channel owner has pinned this comment,\n \"signature\": (str) The signature of the comment,\n \"signing_ts\": (str) The timestamp used to sign the comment,\n \"channel_url\": (str) Channel's URI in the ClaimTrie,\n \"parent_id\": (str) Comment this is replying to, (None) if this is the root,\n \"timestamp\": (int) The time at which comment was entered into the server at, in nanoseconds.\n }",
|
||||
"examples": [
|
||||
{
|
||||
"title": "Posting a comment as your channel",
|
||||
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment create --comment=\"Thank you Based God\" --channel_name=@channel --claim_id=ea41b9f807c6982cf97a1178838dfef64feaa014",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"371cc84d6d2d487592d1483a4d915b793ced4d6ed843402f958e1aeb22325b977b88a41ac0b1d87094634ade2e68a305bda7a3521139f4c5c6ea7b9167afa1d9\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Use the parent_id param to make replies",
|
||||
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment create --comment=\"I have photographic evidence confirming Sasquatch exists\" --channel_name=@channel --parent_id=137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d --claim_id=ea41b9f807c6982cf97a1178838dfef64feaa014",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"168b09f4067231cd5fd065f2ac466a12af98a44477a9a7d68513ef0a26856c6e26fea4bceb6c8c4b182c4bec7d6a316a0d1ed19455123c701806816c317ee417\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"signature\": \"df5b9417c995e7d1e5864074d7f759b7b0053847cc2a4d741e130d67f029a8fa729e2ef188babc4dfb604474657afceb3a5c4be2de50063cc1a9c71472f76240\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "comment_hide",
|
||||
"description": "Hide a comment published to a claim you control.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "comment_ids",
|
||||
"type": "str, list",
|
||||
"description": "one or more comment_id to hide.",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "restrict operation to specific wallet",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "lists containing the ids comments that are hidden and visible.\n\n {\n \"hidden\": (list) IDs of hidden comments.\n \"visible\": (list) IDs of visible comments.\n }",
|
||||
"examples": []
|
||||
},
|
||||
{
|
||||
"name": "comment_list",
|
||||
"description": "List comments associated with a claim.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "claim_id",
|
||||
"type": "str",
|
||||
"description": "The claim on which the comment will be made on",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "parent_id",
|
||||
"type": "str",
|
||||
"description": "CommentId of a specific thread you'd like to see",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "page",
|
||||
"type": "int",
|
||||
"description": "The page you'd like to see in the comment list.",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "page_size",
|
||||
"type": "int",
|
||||
"description": "The amount of comments that you'd like to retrieve",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "skip_validation",
|
||||
"type": "bool",
|
||||
"description": "Skip resolving comments to validate channel names",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "include_replies",
|
||||
"type": "bool",
|
||||
"description": "Whether or not you want to include replies in list",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "is_channel_signature_valid",
|
||||
"type": "bool",
|
||||
"description": "Only include comments with valid signatures. [Warning: Paginated total size will not change, even if list reduces]",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "visible",
|
||||
"type": "bool",
|
||||
"description": "Select only Visible Comments",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "hidden",
|
||||
"type": "bool",
|
||||
"description": "Select only Hidden Comments",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "(dict) Containing the list, and information about the paginated content:\n {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": \"A List of dict objects representing comments.\"\n [\n {\n \"comment\": (str) The actual string as inputted by the user,\n \"comment_id\": (str) The Comment's unique identifier,\n \"channel_name\": (str) Name of the channel this was posted under, prepended with a '@',\n \"channel_id\": (str) The Channel Claim ID that this comment was posted under,\n \"signature\": (str) The signature of the comment,\n \"channel_url\": (str) Channel's URI in the ClaimTrie,\n \"parent_id\": (str) Comment this is replying to, (None) if this is the root,\n \"timestamp\": (int) The time at which comment was entered into the server at, in nanoseconds.\n },\n ...\n ]\n }",
|
||||
"examples": [
|
||||
{
|
||||
"title": "List all comments on a claim",
|
||||
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"include_replies\": true, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment list ea41b9f807c6982cf97a1178838dfef64feaa014 --include_replies",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"include_replies\": true, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"has_hidden_comments\": false,\n \"items\": [\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"168b09f4067231cd5fd065f2ac466a12af98a44477a9a7d68513ef0a26856c6e26fea4bceb6c8c4b182c4bec7d6a316a0d1ed19455123c701806816c317ee417\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"signature\": \"df5b9417c995e7d1e5864074d7f759b7b0053847cc2a4d741e130d67f029a8fa729e2ef188babc4dfb604474657afceb3a5c4be2de50063cc1a9c71472f76240\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n },\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"371cc84d6d2d487592d1483a4d915b793ced4d6ed843402f958e1aeb22325b977b88a41ac0b1d87094634ade2e68a305bda7a3521139f4c5c6ea7b9167afa1d9\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n ],\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "List a comment thread replying to a top level comment",
|
||||
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"include_replies\": false, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment list ea41b9f807c6982cf97a1178838dfef64feaa014 --parent_id=137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"include_replies\": false, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"has_hidden_comments\": false,\n \"items\": [\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"168b09f4067231cd5fd065f2ac466a12af98a44477a9a7d68513ef0a26856c6e26fea4bceb6c8c4b182c4bec7d6a316a0d1ed19455123c701806816c317ee417\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"signature\": \"df5b9417c995e7d1e5864074d7f759b7b0053847cc2a4d741e130d67f029a8fa729e2ef188babc4dfb604474657afceb3a5c4be2de50063cc1a9c71472f76240\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n },\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"371cc84d6d2d487592d1483a4d915b793ced4d6ed843402f958e1aeb22325b977b88a41ac0b1d87094634ade2e68a305bda7a3521139f4c5c6ea7b9167afa1d9\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n ],\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "comment_pin",
|
||||
"description": "Pin a comment published to a claim you control.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "comment_id",
|
||||
"type": "str",
|
||||
"description": "Hash identifying the comment to pin",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "channel_id",
|
||||
"type": "str",
|
||||
"description": "The ID of channel owning the commented claim",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_name",
|
||||
"type": "str",
|
||||
"description": "The name of channel owning the commented claim",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "remove",
|
||||
"type": "bool",
|
||||
"description": "remove the pin",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_account_id",
|
||||
"type": "str",
|
||||
"description": "one or more account ids for accounts to look in",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "restrict operation to specific wallet",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "lists containing the ids comments that are hidden and visible.\n\n {\n \"hidden\": (list) IDs of hidden comments.\n \"visible\": (list) IDs of visible comments.\n }",
|
||||
"examples": []
|
||||
},
|
||||
{
|
||||
"name": "comment_react",
|
||||
"description": "Create and associate a reaction emoji with a comment using your channel identity.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "comment_ids",
|
||||
"type": "str",
|
||||
"description": "one or more comment id reacted to, comma delimited",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_id",
|
||||
"type": "str",
|
||||
"description": "The ID of channel reacting",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_name",
|
||||
"type": "str",
|
||||
"description": "The name of the channel reacting",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "restrict operation to specific wallet",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_account_id",
|
||||
"type": "str",
|
||||
"description": "one or more account ids for accounts to look in",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "react_type",
|
||||
"type": "str",
|
||||
"description": "name of reaction type",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "remove",
|
||||
"type": "bool",
|
||||
"description": "remove specified react_type",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "clear_types",
|
||||
"type": "str",
|
||||
"description": "types to clear when adding another type",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "(dict) Reaction object if successfully made, (None) otherwise\n {\n \"Reactions\": {\n <comment_id>: {\n <reaction_type>: (int) Count for this reaction\n ...\n }\n }",
|
||||
"examples": []
|
||||
},
|
||||
{
|
||||
"name": "comment_react_list",
|
||||
"description": "List reactions emoji with a claim using your channel identity.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "comment_ids",
|
||||
"type": "str",
|
||||
"description": "The comment ids reacted to, comma delimited",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_id",
|
||||
"type": "str",
|
||||
"description": "The ID of channel reacting",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "channel_name",
|
||||
"type": "str",
|
||||
"description": "The name of the channel reacting",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "restrict operation to specific wallet",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "react_types",
|
||||
"type": "str",
|
||||
"description": "comma delimited reaction types",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "(dict) Comment object if successfully made, (None) otherwise\n {\n \"my_reactions\": {\n <comment_id>: {\n <reaction_type>: (int) Count for this reaction type\n ...\n }\n }\n \"other_reactions\": {\n <comment_id>: {\n <reaction_type>: (int) Count for this reaction type\n ...\n }\n }\n }",
|
||||
"examples": []
|
||||
},
|
||||
{
|
||||
"name": "comment_update",
|
||||
"description": "Edit a comment published as one of your channels.",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "comment",
|
||||
"type": "str",
|
||||
"description": "New comment replacing the old one",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "comment_id",
|
||||
"type": "str",
|
||||
"description": "Hash identifying the comment to edit",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "restrict operation to specific wallet",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
"returns": "(dict) Comment object if edit was successful, (None) otherwise\n {\n \"comment\": (str) The actual string as inputted by the user,\n \"comment_id\": (str) The Comment's unique identifier,\n \"claim_id\": (str) The claim commented on,\n \"channel_name\": (str) Name of the channel this was posted under, prepended with a '@',\n \"channel_id\": (str) The Channel Claim ID that this comment was posted under,\n \"signature\": (str) The signature of the comment,\n \"signing_ts\": (str) Timestamp used to sign the most recent signature,\n \"channel_url\": (str) Channel's URI in the ClaimTrie,\n \"is_pinned\": (boolean) Channel owner has pinned this comment,\n \"parent_id\": (str) Comment this is replying to, (None) if this is the root,\n \"timestamp\": (int) The time at which comment was entered into the server at, in nanoseconds.\n }",
|
||||
"examples": [
|
||||
{
|
||||
"title": "Edit the contents of a comment",
|
||||
"curl": "curl -d'{\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment update Where there was once sasquatch, there is not --comment_id=137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Where there was once sasquatch, there is not\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": null,\n \"signature\": \"56408942b909552d7636cee888f3b964cb3aafd5fed90bca5a24a87e821dd9d808e37c57d4b25a956661b6e91472e8ae7d937ae4ab1c64b88162185fd755e536\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"file": {
|
||||
"doc": "File management.",
|
||||
"commands": [
|
||||
@@ -2573,9 +2933,9 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Delete a file",
|
||||
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file delete --claim_id=\"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"}}).json()",
|
||||
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file delete --claim_id=\"ea41b9f807c6982cf97a1178838dfef64feaa014\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
|
||||
}
|
||||
]
|
||||
@@ -2657,7 +3017,7 @@
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "blobs_in_stream",
|
||||
"name": "blobs_in_stream<blobs_in_stream>",
|
||||
"type": "int",
|
||||
"description": "get file with matching blobs in stream",
|
||||
"is_required": false
|
||||
@@ -2736,14 +3096,14 @@
|
||||
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"reverse\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"reverse\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"is_fully_reflected\": true,\n \"key\": \"5b1c3ce02186cc7087ab27bc1075af3a\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0117fbdd61f0cad185dcc191da185ef3513c9c94c99e1c2e131b166b817150587eab67a66890a9b619afdc81eb07bd2d645156e94b237ca75b4f03434734a9937628ff6ad161133542fcd6437c4acf58ed65e63bd70a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70747a6d7966317274180b22186170706c69636174696f6e2f6f637465742d73747265616d3230283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"222955d463b92971d9f76420a405d2a9b1a18d1d9160afa11660276f5ec0f5990adc547f4a36bba42252f97a3f089769\",\n \"stream_name\": \"tmptzmyf1rt\",\n \"streaming_url\": \"http://localhost:5280/stream/283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"suggested_file_name\": \"tmptzmyf1rt\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n },\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"0a0675ea9b83348d1441fb015628b89f44bfa8cf\",\n \"claim_name\": \"blank-image\",\n \"completed\": false,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"is_fully_reflected\": true,\n \"key\": \"8c9d184f9d2c05117f93ce61226606e4\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mjEFq6JGQWFVj45vYxybnWgYAMYjfpDQ91\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1634935383\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpjpqf3u2r.png\",\n \"sd_hash\": \"7156e1fcf35440bdba316dfbae88896855be0816c4fd4adefa0ad1871edb247681ba415b6f27fd10e6b46431b6746e0b\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/thumbnail.jpg\"\n },\n \"title\": \"BlLine truncated
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"is_fully_reflected\": true,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n },\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"6cd66398c40603947d6e34122d82b782dac24424\",\n \"claim_name\": \"blank-image\",\n \"completed\": false,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"is_fully_reflected\": true,\n \"key\": \"f6a644c1b23e5f9eccc1c1aa7a348a79\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mmqinVr6k9tg4Ndah8rU8euHavqDgPiBi4\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1621405331\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpeu6brs_o.png\",\n \"sd_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/thumbnail.jpg\"\n },\n \"title\": \"Line truncated
|
||||
},
|
||||
{
|
||||
"title": "List files matching a parameter",
|
||||
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\", \"reverse\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file list --claim_id=\"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\", \"reverse\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"is_fully_reflected\": true,\n \"key\": \"5b1c3ce02186cc7087ab27bc1075af3a\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0117fbdd61f0cad185dcc191da185ef3513c9c94c99e1c2e131b166b817150587eab67a66890a9b619afdc81eb07bd2d645156e94b237ca75b4f03434734a9937628ff6ad161133542fcd6437c4acf58ed65e63bd70a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70747a6d7966317274180b22186170706c69636174696f6e2f6f637465742d73747265616d3230283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"222955d463b92971d9f76420a405d2a9b1a18d1d9160afa11660276f5ec0f5990adc547f4a36bba42252f97a3f089769\",\n \"stream_name\": \"tmptzmyf1rt\",\n \"streaming_url\": \"http://localhost:5280/stream/283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"suggested_file_name\": \"tmptzmyf1rt\",\n \"timestamp\": 1634935409,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"reverse\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file list --claim_id=\"ea41b9f807c6982cf97a1178838dfef64feaa014\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"reverse\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"is_fully_reflected\": true,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": 1621405356,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2860,10 +3220,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Save a file to the downloads directory",
|
||||
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file save --sd_hash=\"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1634935385,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmprf50bsj_\",\n \"download_path\": \"/tmp/tmprf50bsj_/tmptzmyf1rt_1\",\n \"file_name\": \"tmptzmyf1rt_1\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"5b1c3ce02186cc7087ab27bc1075af3a\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0117fbdd61f0cad185dcc191da185ef3513c9c94c99e1c2e131b166b817150587eab67a66890a9b619afdc81eb07bd2d645156e94b237ca75b4f03434734a9937628ff6ad161133542fcd6437c4acf58ed65e63bd70a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70747a6d7966317274180b22186170706c69636174696f6e2f6f637465742d73747265616d3230283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"222955d463b92971d9f76420a405d2a9b1a18d1d9160afa11660276f5ec0f5990adc547f4a36bba42252f97a3f089769\",\n \"stream_name\": \"tmptzmyf1rt\",\n \"streaming_url\": \"http://localhost:5280/stream/283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"suggested_file_name\": \"tmptzmyf1rt\",\n \"timestamp\": 1634935409,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file save --sd_hash=\"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1621405335,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmp5s0wcgsl\",\n \"download_path\": \"/tmp/tmp5s0wcgsl/tmpvccpjv29_1\",\n \"file_name\": \"tmpvccpjv29_1\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": 1621405356,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3144,7 +3504,7 @@
|
||||
"curl": "curl -d'{\"method\": \"settings_get\", \"params\": {}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet settings get",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"settings_get\", \"params\": {}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"allowed_origin\": \"\",\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"audio_encoder\": \"aac -b:a 160k\",\n \"blob_download_timeout\": 30.0,\n \"blob_lru_cache_size\": 0,\n \"blob_storage_limit\": 0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"coin_selection_strategy\": \"standard\",\n \"components_to_skip\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\",\n \"libtorrent_component\"\n ],\n \"concurrent_blob_announcers\": 10,\n \"concurrent_hub_requests\": 32,\n \"concurrent_reflector_uploads\": 10,\n \"config\": \"/tmp/tmpdzuoz2r_/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmprf50bsj_\",\n \"download_dir\": \"/tmp/tmprf50bsj_\",\n \"download_timeout\": 30.0,\n \"ffmpeg_path\": \"\",\n \"fixed_peer_delay\": 2.0,\n \"fixed_peers\": [\n [\n \"127.0.0.1\",\n 5567\n ]\n ],\n \"hub_timeout\": 30.0,\n \"jurisdiction\": null,\n \"known_dht_nodes\": [],\n \"lbryum_servers\": [\n [\n \"localhost\",\n 50002\n ]\n ],\n \"max_connections_per_download\": 4,\n \"max_key_fee\": {\n \"amount\": 50.0,\n \"currency\": \"USD\"\n },\n \"max_wallet_server_fee\": \"0.0\",\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"prometheus_port\": 0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"save_blobs\": true,\n \"save_files\": true,\n \"save_resolved_claims\": true,\n \"share_usage_data\": false,\n \"split_buckets_under_index\": 1,\n \"streaming_get\": true,\n \"streaming_server\": \"localhost:5280\",\n \"tcp_port\": 3333,\n \"track_bandwidth\": true,\n \"transaction_cache_size\": 10000,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"video_bitrate_maximum\": 5000000,\n \"video_encoder\": \"libx264 -crf 24 -preset faster -pix_fmt yuv420p\",\n \"video_scaler\": \"-vf \\\"scale=if(gte(iw\\\\,ih)\\\\,min(1920\\\\,iw)\\\\,-2):if(lt(iw\\\\,ih)\\\\,min(1920\\\\,ih)\\\\,-2)\\\" -maxrate 5500K -bufsize 5000K\",\n \"volume_analysis_time\": 240,\n \"volume_filter\": \"\",\n \"wallet_dir\": \"/tmp/tmprf50bsj_\",\n \"wallets\": [\n \"default_wallet\"\n ]\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"allowed_origin\": \"\",\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"audio_encoder\": \"aac -b:a 160k\",\n \"blob_download_timeout\": 30.0,\n \"blob_lru_cache_size\": 0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"coin_selection_strategy\": \"standard\",\n \"comment_server\": \"http://localhost:2903/api\",\n \"components_to_skip\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\",\n \"libtorrent_component\"\n ],\n \"concurrent_blob_announcers\": 10,\n \"concurrent_reflector_uploads\": 10,\n \"config\": \"/home/user/.local/share/lbry/lbrynet/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmp5s0wcgsl\",\n \"download_dir\": \"/tmp/tmp5s0wcgsl\",\n \"download_timeout\": 30.0,\n \"ffmpeg_path\": \"\",\n \"fixed_peer_delay\": 2.0,\n \"fixed_peers\": [\n [\n \"127.0.0.1\",\n 5567\n ]\n ],\n \"known_dht_nodes\": [],\n \"lbryum_servers\": [\n [\n \"127.0.0.1\",\n 50001\n ]\n ],\n \"max_connections_per_download\": 4,\n \"max_key_fee\": {\n \"amount\": 50.0,\n \"currency\": \"USD\"\n },\n \"max_wallet_server_fee\": \"0.0\",\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"prometheus_port\": 0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"save_blobs\": true,\n \"save_files\": true,\n \"save_resolved_claims\": true,\n \"share_usage_data\": false,\n \"split_buckets_under_index\": 1,\n \"streaming_get\": true,\n \"streaming_server\": \"localhost:5280\",\n \"tcp_port\": 3333,\n \"track_bandwidth\": true,\n \"transaction_cache_size\": 10000,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"video_bitrate_maximum\": 5000000,\n \"video_encoder\": \"libx264 -crf 24 -preset faster -pix_fmt yuv420p\",\n \"video_scaler\": \"-vf \\\"scale=if(gte(iw\\\\,ih)\\\\,min(1920\\\\,iw)\\\\,-2):if(lt(iw\\\\,ih)\\\\,min(1920\\\\,ih)\\\\,-2)\\\" -maxrate 5500K -bufsize 5000K\",\n \"volume_analysis_time\": 240,\n \"volume_filter\": \"\",\n \"wallet_dir\": \"/tmp/tmp5s0wcgsl\",\n \"wallets\": [\n \"default_wallet\"\n ]\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3219,10 +3579,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Abandon a stream claim",
|
||||
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream abandon 64f38c5077c3bc0a02b34ea214ac899c7caa5f19",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\", \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001946d29d89ae8fac7edea6dfc87ca2b98fa64dd294408caa51c1d4352e83de36e000000006a473044022016d4505559a791a83404d68bf2a97a11e7fde4893ce5067506d5d16e0a89b7b6022005cfb4b4a7e21af4fba230147e29caa3855ba22ab0df6773b52287f19bbf81b6012102cfc8de70fc51bfa725bf3b6d266439aa02b0bbe4542d1bfc8c74875457f66d9fffffffff0134b7f505000000001976a914730a70203185ebdea2bfd4c0a14dfde971b173ad88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mr1EWMmUSUxkTHwhQE9PR385BW4s54cb5M\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"282db64f025f08d895875ed13129af174c92f5a7d2a8d202c942985104d89149\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"282db64f025f08d895875ed13129af174c92f5a7d2a8d202c942985104d89149\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream abandon ea41b9f807c6982cf97a1178838dfef64feaa014",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000012b02e035e15a2d7b0ad580c13855b399916881dfb62f7739f34773cd4e07eb08000000006a47304402201f154b1ed0e658ed7cecd5eacde667fa53e6da238599c9e617676f78964c0b24022061a30c3d58ce2bab5ec15be078a1a01786d00e9b8fd08a9ae02c57b7b2266f4c0121030bb5d283d077a4d93a13dd43f6ab8886f8f2d39b3e4936fdb1f79baa95bbf19effffffff0134b7f505000000001976a9144eb00af05527118271650a5c534844db57da987e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnh1tgQ4wJwbPpNLh2iCSTpBm1Hp1xDTsT\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"cc04061078010a27c416a485b97fb61db50e49703b91a353fa03464a2ac7e264\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"cc04061078010a27c416a485b97fb61db50e49703b91a353fa03464a2ac7e264\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3453,17 +3813,17 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Create a stream claim without metadata",
|
||||
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmptzmyf1rt\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmptzmyf1rt",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmptzmyf1rt\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015611218abf838917edf6bd9b688491f6ed466402f0543ac59d27d3dc7329860f010000006a473044022021fde4ff1a9d16b9fbe9f28b6ad246e2bf6666b01b02546509886124b0b85cac022067da395ddf73be4a861ec9789765c0b75c99ddbae5e81ea4fd8e71362866e35e0121026ba322de23e7d68008d93d117e411fa11ebfae09baf030920bd859c6e104b4cdffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70747a6d7966317274180b22186170706c69636174696f6e2f6f637465742d73747265616d3230283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf316d7576a91471eb718a76bca81a5a836449ab8915281ddd016388ac38fb9423000000001976a9148ed470b9ff86250699872147b1ee2f9cb49dd65188ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mwLCPk6wpNzHXZ8k8JzaMJu1Uig8Kw8qiQ\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"nout\": 1,\n \"timestamp\": 1634935408,\n \"txid\": \"0f862973dcd3279dc53a54f0026446edf69184689bbdf6ed178983bf8a211156\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"timestamp\": null,\n \"txid\": \"cdca2048245f1c2d7df9ab5ff2c6c6cd48dbbdffee1c406f55b8be1728cb557c\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mtYAjuakunyoudrWPHVQ9r4myztoT4MptK\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"cdca2048245f1c2d7df9ab5ff2c6c6cd48dbbdffee1c406f55b8be1728cb557c\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"cdca2048245f1c2d7df9ab5ff2c6c6cd48dbbdffee1c406f55b8be1728cb557c\"\n }\n}"
|
||||
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpvccpjv29\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmpvccpjv29",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpvccpjv29\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001bb384e08ba07d2a2881a4b7bbaca52623e4e9b4802750411a0e0eba84d960aeb010000006b483045022100ee034d690c385f87e52db7a7c5ecec41c0f5d8eda08332778d9a674046583d7a02207ec24358481bf0c81d2a32fc9e1716e145eda810553d1d814b7c93a968468a49012102c21142e983b9c10d17cd922818fefd1a34f34a708849811a41c25ad13835320fffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb76d7576a9141fcba83c5371c31a24cb491e9d74db9e397784af88ac38fb9423000000001976a914ebc5945ded112d0f109cfdc3d985668de7b27ada88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkjhU7Go11ZuCbGEp6edSr4At5CBDW23xH\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": null,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n31bnChc7o13i4LjY3GMtdhEJoAqdsMb7w\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\"\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Create an image stream claim with all metadata and fee",
|
||||
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpjpqf3u2r.png\", \"validate_file\": false, \"optimize_file\": false, \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1634935383, \"channel_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmpjpqf3u2r.png --tags=blank --tags=art --languages=en --locations=US:NH:Manchester --fee_currency=LBC --fee_amount=0.3 --title=\"Blank Image\" --description=\"A blank PNG that is 5x7.\" --author=Picaso --license=\"Public Domain\" --license_url=http://public-domain.org --thumbnail_url=\"http://smallmedia.com/thumbnail.jpg\" --release_time=1634935383 --channel_id=\"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpjpqf3u2r.png\", \"validate_file\": false, \"optimize_file\": false, \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1634935383, \"channel_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000017c55cb2817beb8556f401ceeffbddb48cdc6c6f25fabf97d2d1c5f244820cacd010000006a4730440220386be4343af35af291a516dfe119dceffe5d14a4c8e083faa6166c07746a028a022000ab4f6bcf645887fe6c54eaa7babac1cd29d3f5b896f434985ee2488e99584e0121029d28dc836b9c5969a6aeaa54019e13949f62170a29a5fd69657d7e8b35cab2dcffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db1010117fbdd61f0cad185dcc191da185ef3513c9c94c9135c21c0656c8b3acac689a72ca4d54e36d450a23024ee1a41fafb55f6ca464cc75eebfff36dfcfe1cc6353a6b4ccd647d62a84c6a130fd800240382e953243e0ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d706a707166337532722e706e6718632209696d6167652f706e6732307156e1fcf35440bdba316dfbae88896855be0816c4fd4adefa0ad1871edb247681ba415b6f27fd10e6b46431b6746e0b120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f726728d7c4cc8b063222080112196f28b811c30f7a4ca9ef1f03a7ce261ca88791dc6d82c9d39c188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a91428b811c30f7a4ca9ef1f03a7ce261ca88791dc6d88acac5e7d1d000000001976a9142107cb0cdafcea341f90429b9f4324fe823c230088ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mtYAjuakunyoudrWPHVQ9r4myztoT4MptK\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"nout\": 1,\n \"timestamp\": 1634935409,\n \"txid\": \"cdca2048245f1c2d7df9ab5ff2c6c6cd48dbbdffee1c406f55b8be1728cb557c\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mjEFq6JGQWFVj45vYxybnWgYAMYjfpDQ91\",\n \"amount\": \"1.0\",\n \"claim_id\": \"0a0675ea9b83348d1441fb015628b89f44bfa8cf\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"blank-image\",\n \"normalized_name\": \"blank-image\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://blank-image#0a0675ea9b83348d1441fb015628b89f44bfa8cf\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"cd484440825ef6a1e470c24e01ece2af96d63558b7a9fa1d32234981a26f6747\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mjEFq6JGQWFVj45vYxybnWgYAMYjfpDQ91\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1634935383\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpjpqf3u2r.png\",\n \"sd_hash\": \"7156e1fcf35440bdba316dfbae88896855be0816c4fd4adefa0ad1871edb247681ba415b6f27fd10e6b46431b6746e0b\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbLine truncated
|
||||
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpeu6brs_o.png\", \"validate_file\": false, \"optimize_file\": false, \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1621405331, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmpeu6brs_o.png --tags=blank --tags=art --languages=en --locations=US:NH:Manchester --fee_currency=LBC --fee_amount=0.3 --title=\"Blank Image\" --description=\"A blank PNG that is 5x7.\" --author=Picaso --license=\"Public Domain\" --license_url=http://public-domain.org --thumbnail_url=\"http://smallmedia.com/thumbnail.jpg\" --release_time=1621405331 --channel_id=\"20ccc609603f9c6f01d74f2d6a133867d2903fc2\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpeu6brs_o.png\", \"validate_file\": false, \"optimize_file\": false, \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1621405331, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015983dbfa63b6de2131f250c8aa08c81fa1c2b75c8614bbc8ed7efcd09f4a37e4010000006b4830450221008fec0f41696f6bdc859e471a60f9f2598c721a197ab106ae24596d999a554542022045a2176cb13e5417bff7299505e382c66a9754d2540915f317b9d1c1a0a73545012102dab800fee684fddb84ce0ae74c3455b38fcb855ae038c60d272a07dbe40dac62ffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db10101c23f90d26738136a2d4fd7016f9c3f6009c6cc20bc86cfc6d27ece4853069056b8995fc7369b9cad50c37d389390d868d7fa8f475b261f7dee284dcd39e29e3c9806cd02b68fd18869ad3c91d16889ef3ab4fdc30ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d706575366272735f6f2e706e6718632209696d6167652f706e673230c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f72672893dd9285063222080112196f455d617873267c515540aeb9dc52903fafa112917f28c9dd188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a914455d617873267c515540aeb9dc52903fafa1129188acac5e7d1d000000001976a914db06da1dd2cf5d45e1870016719db223fb230e5988ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n31bnChc7o13i4LjY3GMtdhEJoAqdsMb7w\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"nout\": 1,\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mmqinVr6k9tg4Ndah8rU8euHavqDgPiBi4\",\n \"amount\": \"1.0\",\n \"claim_id\": \"6cd66398c40603947d6e34122d82b782dac24424\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"blank-image\",\n \"normalized_name\": \"blank-image\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://blank-image#6cd66398c40603947d6e34122d82b782dac24424\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"4fe38a34127499e9bd9a1bed2535b93a7d17ff8dcd7ad772fbda31ebefa75215\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mmqinVr6k9tg4Ndah8rU8euHavqDgPiBi4\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1621405331\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpeu6brs_o.png\",\n \"sd_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thuLine truncated
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3533,14 +3893,14 @@
|
||||
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"timestamp\": 1634935409,\n \"txid\": \"cdca2048245f1c2d7df9ab5ff2c6c6cd48dbbdffee1c406f55b8be1728cb557c\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Paginate your stream claims",
|
||||
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream list --page=1 --page_size=20",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1634935409,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"timestamp\": 1634935409,\n \"txid\": \"cdca2048245f1c2d7df9ab5ff2c6c6cd48dbbdffee1c406f55b8be1728cb557c\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3879,10 +4239,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Update a stream claim to add channel",
|
||||
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream update 64f38c5077c3bc0a02b34ea214ac899c7caa5f19 --channel_id=\"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000027c55cb2817beb8556f401ceeffbddb48cdc6c6f25fabf97d2d1c5f244820cacd000000006a47304402204a657f460270a659344fb3b0dcc43173278040e9ce18990334a51f8055a99e450220337ccdc2c255e20c0677f6f1088410f2330e045b73569987f15d93b56bea9cd9012102cfc8de70fc51bfa725bf3b6d266439aa02b0bbe4542d1bfc8c74875457f66d9fffffffffad9599b9bbeb4fe59c35326506dd3def66a75b67b61e1f73469b257918ced1bc010000006b483045022100e07ad4a758843eab27e010dc76954d9a27645cb70ceed23e5bb0ac4a35f25b7d02206c6b71881c8d80221c721ac11c8d9328ab6f57f740c9c83d21ccb52b90fee4130121033255ce1a6c2cf93cc4e50698e05dd9eb221c28f309c9543453bad3f8b09ad2edffffffff0200e1f50500000000fd2301b7076173747265616d14195faa7c9c89ac14a24eb3020abcc377508cf3644ce80117fbdd61f0cad185dcc191da185ef3513c9c94c99e1c2e131b166b817150587eab67a66890a9b619afdc81eb07bd2d645156e94b237ca75b4f03434734a9937628ff6ad161133542fcd6437c4acf58ed65e63bd70a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70747a6d7966317274180b22186170706c69636174696f6e2f6f637465742d73747265616d3230283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf316d6d76a91471eb718a76bca81a5a836449ab8915281ddd016388ac32a0d205000000001976a914f1ce6cf2fdcb163d19f21a1060f88f814da49e1e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"timestamp\": 1634935409,\n \"txid\": \"cdca2048245f1c2d7df9ab5ff2c6c6cd48dbbdffee1c406f55b8be1728cb557c\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmptzmyf1rt\",\n \"sd_hash\": \"283293d124fa9f6b80633093479fe2464b46fa9a4523aebe5e66689164db50bcdcd258ac6d7c4ecccda3338b4492cf31\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mgWqABp4HumxP1Ezw4XqbfKud2DgbyuwNq\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"nout\": 1,\n \"timestamp\": 1634935408,\n \"txid\": \"bcd1ce1879259b46731f1eb6675ba766ef3ddd066532359ce54febbbb99995ad\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mquJhdgrGiv3tLabBR8wgf2rRwdWuFRQXs\",\n \"amount\": \"1.0\",\n \"claim_id\": \"64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#64f38c5077c3bc0a02b34ea214ac899c7caa5f19\",\n \"signing_channel\": {\n \"address\": \"mkYQ8WzhbwkeyFLHaLGnAV423PVTnXFLiU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#c9949c3c51f35e18da91c1dc85d1caf061ddfb17\",\n \"timestamp\": 1634935408,\n \"txid\": \"4e562ddfe2de23eb36d9849100934426afae4329458b276e15d75d7e4fd48d16\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200045350d8a74b416898a0ee03b64c2ea8e1cfb2932734468b7c2c828fc0be4452cd535955c18b4c047e8235274848a02f791e59659247c2a4c164d8d91208a69ead\",\n \"public_key_id\": \"mqzFQxe8hpWstFxN1BWtRsWZBV3qHwotU9\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"6ee33de852431d1ca5ca084429dd64fa982bca87fc6deaedc7fae89ad8296d94\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n Line truncated
|
||||
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream update ea41b9f807c6982cf97a1178838dfef64feaa014 --channel_id=\"20ccc609603f9c6f01d74f2d6a133867d2903fc2\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000025983dbfa63b6de2131f250c8aa08c81fa1c2b75c8614bbc8ed7efcd09f4a37e4000000006a473044022035dd8c46b38449f8e9dd343553e3c7c8980a8463ea586fb618ab307faf29b8ed02204cd801cea4125a0b38f0ff8505bfc500251c0991fe9b5ac06f944094f3db5a290121030bb5d283d077a4d93a13dd43f6ab8886f8f2d39b3e4936fdb1f79baa95bbf19effffffff53a4f1a509fbf2d441f02d25f7050db36e08ecc189dc30ff1449d56ff1d34124010000006b4830450221008bc1812dd520343aac1eb8fd949f143c43fa2d5922c71fb628422988d40ef6bf0220628378190c53883fe6a22ac8a0717aceeaa4a96896f789a9c16fc1891835b9490121037071cf357b535f0733476fc860a2d531c2186b84ad9d57af093118a0fdddca98ffffffff0200e1f50500000000fd2301b7076173747265616d1414a0ea4ff6fe8d8378117af92c98c607f8b941ea4ce801c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb76d6d76a9141fcba83c5371c31a24cb491e9d74db9e397784af88ac32a0d205000000001976a9146ff324c17cf183bd5df4fe6b6b1ec33d83320de388ac00000000\",\n \"inputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mv8AkyC2tGywD9ARYqEkznnjM7gs8LG17A\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n Line truncated
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4005,12 +4365,6 @@
|
||||
"description": "ids of accounts to fund this transaction",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "comment",
|
||||
"type": "str",
|
||||
"description": "add a comment to the support",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "preview",
|
||||
"type": "bool",
|
||||
@@ -4103,7 +4457,7 @@
|
||||
},
|
||||
{
|
||||
"name": "support_sum",
|
||||
"description": "List total staked supports for a claim, grouped by the channel that signed the support.\n\nIf claim_id is a channel claim, you can use --include_channel_content to also include supports for\ncontent claims in the channel.\n\n!!!! NOTE: PAGINATION DOES NOT DO ANYTHING AT THE MOMENT !!!!!",
|
||||
"description": "List total staked supports for a claim, grouped by the channel that signed the support.\n+\n+ If claim_id is a channel claim, you can use --include_channel_content to also include supports for\n+ content claims in the channel.\n\n !!!! NOTE: PAGINATION DOES NOT DO ANYTHING AT THE MOMENT !!!!!",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "claim_id",
|
||||
@@ -4264,7 +4618,7 @@
|
||||
"curl": "curl -d'{\"method\": \"transaction_list\", \"params\": {}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet transaction list",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"transaction_list\", \"params\": {}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2021-10-22 16:43\",\n \"fee\": \"-0.000124\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1634935408,\n \"txid\": \"95f85d786c60e12731c553f7510a8f83bd14a913f6d4dbdca580882ae767c6cb\",\n \"update_info\": [],\n \"value\": \"0.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2021-10-22 16:43\",\n \"fee\": \"0.0\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1634935407,\n \"txid\": \"653d46cb7a84993fd9312f1bb0b5a4f0d40b99525d2ae4130749b271afb74555\",\n \"update_info\": [],\n \"value\": \"10.0\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2021-05-19 03:22\",\n \"fee\": \"-0.000124\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1621405355,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"update_info\": [],\n \"value\": \"0.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2021-05-19 03:22\",\n \"fee\": \"0.0\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1621405354,\n \"txid\": \"7a723b27c9cd2e9283da4916ec02c8aa839bf94785a64e4b012c2716cfaab958\",\n \"update_info\": [],\n \"value\": \"10.0\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
__version__ = "0.105.0"
|
||||
__version__ = "0.101.1"
|
||||
version = tuple(map(int, __version__.split('.'))) # pylint: disable=invalid-name
|
||||
+22
-34
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import asyncio
|
||||
import binascii
|
||||
import logging
|
||||
@@ -71,16 +70,12 @@ class AbstractBlob:
|
||||
'writers',
|
||||
'verified',
|
||||
'writing',
|
||||
'readers',
|
||||
'added_on',
|
||||
'is_mine',
|
||||
'readers'
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self, loop: asyncio.AbstractEventLoop, blob_hash: str, length: typing.Optional[int] = None,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], asyncio.Task]] = None,
|
||||
blob_directory: typing.Optional[str] = None, added_on: typing.Optional[int] = None, is_mine: bool = False,
|
||||
):
|
||||
def __init__(self, loop: asyncio.AbstractEventLoop, blob_hash: str, length: typing.Optional[int] = None,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], asyncio.Task]] = None,
|
||||
blob_directory: typing.Optional[str] = None):
|
||||
self.loop = loop
|
||||
self.blob_hash = blob_hash
|
||||
self.length = length
|
||||
@@ -90,8 +85,6 @@ class AbstractBlob:
|
||||
self.verified: asyncio.Event = asyncio.Event(loop=self.loop)
|
||||
self.writing: asyncio.Event = asyncio.Event(loop=self.loop)
|
||||
self.readers: typing.List[typing.BinaryIO] = []
|
||||
self.added_on = added_on or time.time()
|
||||
self.is_mine = is_mine
|
||||
|
||||
if not is_valid_blobhash(blob_hash):
|
||||
raise InvalidBlobHashError(blob_hash)
|
||||
@@ -187,21 +180,20 @@ class AbstractBlob:
|
||||
|
||||
@classmethod
|
||||
async def create_from_unencrypted(
|
||||
cls, loop: asyncio.AbstractEventLoop, blob_dir: typing.Optional[str], key: bytes, iv: bytes,
|
||||
unencrypted: bytes, blob_num: int, added_on: int, is_mine: bool,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], None]] = None,
|
||||
) -> BlobInfo:
|
||||
cls, loop: asyncio.AbstractEventLoop, blob_dir: typing.Optional[str], key: bytes, iv: bytes,
|
||||
unencrypted: bytes, blob_num: int,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], None]] = None) -> BlobInfo:
|
||||
"""
|
||||
Create an encrypted BlobFile from plaintext bytes
|
||||
"""
|
||||
|
||||
blob_bytes, blob_hash = encrypt_blob_bytes(key, iv, unencrypted)
|
||||
length = len(blob_bytes)
|
||||
blob = cls(loop, blob_hash, length, blob_completed_callback, blob_dir, added_on, is_mine)
|
||||
blob = cls(loop, blob_hash, length, blob_completed_callback, blob_dir)
|
||||
writer = blob.get_blob_writer()
|
||||
writer.write(blob_bytes)
|
||||
await blob.verified.wait()
|
||||
return BlobInfo(blob_num, length, binascii.hexlify(iv).decode(), blob_hash, added_on, is_mine)
|
||||
return BlobInfo(blob_num, length, binascii.hexlify(iv).decode(), blob_hash)
|
||||
|
||||
def save_verified_blob(self, verified_bytes: bytes):
|
||||
if self.verified.is_set():
|
||||
@@ -256,13 +248,11 @@ class BlobBuffer(AbstractBlob):
|
||||
"""
|
||||
An in-memory only blob
|
||||
"""
|
||||
def __init__(
|
||||
self, loop: asyncio.AbstractEventLoop, blob_hash: str, length: typing.Optional[int] = None,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], asyncio.Task]] = None,
|
||||
blob_directory: typing.Optional[str] = None, added_on: typing.Optional[int] = None, is_mine: bool = False
|
||||
):
|
||||
def __init__(self, loop: asyncio.AbstractEventLoop, blob_hash: str, length: typing.Optional[int] = None,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], asyncio.Task]] = None,
|
||||
blob_directory: typing.Optional[str] = None):
|
||||
self._verified_bytes: typing.Optional[BytesIO] = None
|
||||
super().__init__(loop, blob_hash, length, blob_completed_callback, blob_directory, added_on, is_mine)
|
||||
super().__init__(loop, blob_hash, length, blob_completed_callback, blob_directory)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _reader_context(self) -> typing.ContextManager[typing.BinaryIO]:
|
||||
@@ -299,12 +289,10 @@ class BlobFile(AbstractBlob):
|
||||
"""
|
||||
A blob existing on the local file system
|
||||
"""
|
||||
def __init__(
|
||||
self, loop: asyncio.AbstractEventLoop, blob_hash: str, length: typing.Optional[int] = None,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], asyncio.Task]] = None,
|
||||
blob_directory: typing.Optional[str] = None, added_on: typing.Optional[int] = None, is_mine: bool = False
|
||||
):
|
||||
super().__init__(loop, blob_hash, length, blob_completed_callback, blob_directory, added_on, is_mine)
|
||||
def __init__(self, loop: asyncio.AbstractEventLoop, blob_hash: str, length: typing.Optional[int] = None,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], asyncio.Task]] = None,
|
||||
blob_directory: typing.Optional[str] = None):
|
||||
super().__init__(loop, blob_hash, length, blob_completed_callback, blob_directory)
|
||||
if not blob_directory or not os.path.isdir(blob_directory):
|
||||
raise OSError(f"invalid blob directory '{blob_directory}'")
|
||||
self.file_path = os.path.join(self.blob_directory, self.blob_hash)
|
||||
@@ -355,12 +343,12 @@ class BlobFile(AbstractBlob):
|
||||
|
||||
@classmethod
|
||||
async def create_from_unencrypted(
|
||||
cls, loop: asyncio.AbstractEventLoop, blob_dir: typing.Optional[str], key: bytes, iv: bytes,
|
||||
unencrypted: bytes, blob_num: int, added_on: float, is_mine: bool,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], asyncio.Task]] = None
|
||||
) -> BlobInfo:
|
||||
cls, loop: asyncio.AbstractEventLoop, blob_dir: typing.Optional[str], key: bytes, iv: bytes,
|
||||
unencrypted: bytes, blob_num: int,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'],
|
||||
asyncio.Task]] = None) -> BlobInfo:
|
||||
if not blob_dir or not os.path.isdir(blob_dir):
|
||||
raise OSError(f"cannot create blob in directory: '{blob_dir}'")
|
||||
return await super().create_from_unencrypted(
|
||||
loop, blob_dir, key, iv, unencrypted, blob_num, added_on, is_mine, blob_completed_callback
|
||||
loop, blob_dir, key, iv, unencrypted, blob_num, blob_completed_callback
|
||||
)
|
||||
@@ -7,19 +7,13 @@ class BlobInfo:
|
||||
'blob_num',
|
||||
'length',
|
||||
'iv',
|
||||
'added_on',
|
||||
'is_mine'
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self, blob_num: int, length: int, iv: str,
|
||||
blob_hash: typing.Optional[str] = None, added_on=0, is_mine=False):
|
||||
def __init__(self, blob_num: int, length: int, iv: str, blob_hash: typing.Optional[str] = None):
|
||||
self.blob_hash = blob_hash
|
||||
self.blob_num = blob_num
|
||||
self.length = length
|
||||
self.iv = iv
|
||||
self.added_on = added_on
|
||||
self.is_mine = is_mine
|
||||
|
||||
def as_dict(self) -> typing.Dict:
|
||||
d = {
|
||||
|
||||
@@ -36,30 +36,30 @@ class BlobManager:
|
||||
self.config.blob_lru_cache_size)
|
||||
self.connection_manager = ConnectionManager(loop)
|
||||
|
||||
def _get_blob(self, blob_hash: str, length: typing.Optional[int] = None, is_mine: bool = False):
|
||||
def _get_blob(self, blob_hash: str, length: typing.Optional[int] = None):
|
||||
if self.config.save_blobs or (
|
||||
is_valid_blobhash(blob_hash) and os.path.isfile(os.path.join(self.blob_dir, blob_hash))):
|
||||
return BlobFile(
|
||||
self.loop, blob_hash, length, self.blob_completed, self.blob_dir, is_mine=is_mine
|
||||
self.loop, blob_hash, length, self.blob_completed, self.blob_dir
|
||||
)
|
||||
return BlobBuffer(
|
||||
self.loop, blob_hash, length, self.blob_completed, self.blob_dir, is_mine=is_mine
|
||||
self.loop, blob_hash, length, self.blob_completed, self.blob_dir
|
||||
)
|
||||
|
||||
def get_blob(self, blob_hash, length: typing.Optional[int] = None, is_mine: bool = False):
|
||||
def get_blob(self, blob_hash, length: typing.Optional[int] = None):
|
||||
if blob_hash in self.blobs:
|
||||
if self.config.save_blobs and isinstance(self.blobs[blob_hash], BlobBuffer):
|
||||
buffer = self.blobs.pop(blob_hash)
|
||||
if blob_hash in self.completed_blob_hashes:
|
||||
self.completed_blob_hashes.remove(blob_hash)
|
||||
self.blobs[blob_hash] = self._get_blob(blob_hash, length, is_mine)
|
||||
self.blobs[blob_hash] = self._get_blob(blob_hash, length)
|
||||
if buffer.is_readable():
|
||||
with buffer.reader_context() as reader:
|
||||
self.blobs[blob_hash].write_blob(reader.read())
|
||||
if length and self.blobs[blob_hash].length is None:
|
||||
self.blobs[blob_hash].set_length(length)
|
||||
else:
|
||||
self.blobs[blob_hash] = self._get_blob(blob_hash, length, is_mine)
|
||||
self.blobs[blob_hash] = self._get_blob(blob_hash, length)
|
||||
return self.blobs[blob_hash]
|
||||
|
||||
def is_blob_verified(self, blob_hash: str, length: typing.Optional[int] = None) -> bool:
|
||||
@@ -105,13 +105,9 @@ class BlobManager:
|
||||
if isinstance(blob, BlobFile):
|
||||
if blob.blob_hash not in self.completed_blob_hashes:
|
||||
self.completed_blob_hashes.add(blob.blob_hash)
|
||||
return self.loop.create_task(self.storage.add_blobs(
|
||||
(blob.blob_hash, blob.length, blob.added_on, blob.is_mine), finished=True)
|
||||
)
|
||||
return self.loop.create_task(self.storage.add_blobs((blob.blob_hash, blob.length), finished=True))
|
||||
else:
|
||||
return self.loop.create_task(self.storage.add_blobs(
|
||||
(blob.blob_hash, blob.length, blob.added_on, blob.is_mine), finished=False)
|
||||
)
|
||||
return self.loop.create_task(self.storage.add_blobs((blob.blob_hash, blob.length), finished=False))
|
||||
|
||||
def check_completed_blobs(self, blob_hashes: typing.List[str]) -> typing.List[str]:
|
||||
"""Returns of the blobhashes_to_check, which are valid"""
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DiskSpaceManager:
|
||||
|
||||
def __init__(self, config, db, blob_manager, cleaning_interval=30 * 60, analytics=None):
|
||||
self.config = config
|
||||
self.db = db
|
||||
self.blob_manager = blob_manager
|
||||
self.cleaning_interval = cleaning_interval
|
||||
self.running = False
|
||||
self.task = None
|
||||
self.analytics = analytics
|
||||
self._used_space_bytes = None
|
||||
|
||||
async def get_free_space_mb(self, is_network_blob=False):
|
||||
limit_mb = self.config.network_storage_limit if is_network_blob else self.config.blob_storage_limit
|
||||
space_used_mb = await self.get_space_used_mb()
|
||||
space_used_mb = space_used_mb['network_storage'] if is_network_blob else space_used_mb['content_storage']
|
||||
return max(0, limit_mb - space_used_mb)
|
||||
|
||||
async def get_space_used_bytes(self):
|
||||
self._used_space_bytes = await self.db.get_stored_blob_disk_usage()
|
||||
return self._used_space_bytes
|
||||
|
||||
async def get_space_used_mb(self, cached=True):
|
||||
cached = cached and self._used_space_bytes is not None
|
||||
space_used_bytes = self._used_space_bytes if cached else await self.get_space_used_bytes()
|
||||
return {key: int(value/1024.0/1024.0) for key, value in space_used_bytes.items()}
|
||||
|
||||
async def clean(self):
|
||||
await self._clean(False)
|
||||
await self._clean(True)
|
||||
|
||||
async def _clean(self, is_network_blob=False):
|
||||
space_used_bytes = await self.get_space_used_bytes()
|
||||
if is_network_blob:
|
||||
space_used_bytes = space_used_bytes['network_storage']
|
||||
else:
|
||||
space_used_bytes = space_used_bytes['content_storage'] + space_used_bytes['private_storage']
|
||||
storage_limit_mb = self.config.network_storage_limit if is_network_blob else self.config.blob_storage_limit
|
||||
storage_limit = storage_limit_mb*1024*1024 if storage_limit_mb else None
|
||||
if self.analytics:
|
||||
asyncio.create_task(
|
||||
self.analytics.send_disk_space_used(space_used_bytes, storage_limit, is_network_blob)
|
||||
)
|
||||
if not storage_limit:
|
||||
return 0
|
||||
delete = []
|
||||
available = storage_limit - space_used_bytes
|
||||
if available > 0:
|
||||
return 0
|
||||
for blob_hash, file_size, _ in await self.db.get_stored_blobs(is_mine=False, is_network_blob=is_network_blob):
|
||||
delete.append(blob_hash)
|
||||
available += file_size
|
||||
if available > 0:
|
||||
break
|
||||
if delete:
|
||||
await self.db.stop_all_files()
|
||||
await self.blob_manager.delete_blobs(delete, delete_from_db=True)
|
||||
return len(delete)
|
||||
|
||||
async def cleaning_loop(self):
|
||||
while self.running:
|
||||
await asyncio.sleep(self.cleaning_interval)
|
||||
await self.clean()
|
||||
|
||||
async def start(self):
|
||||
self.running = True
|
||||
self.task = asyncio.create_task(self.cleaning_loop())
|
||||
self.task.add_done_callback(lambda _: log.info("Stopping blob cleanup service."))
|
||||
|
||||
async def stop(self):
|
||||
if self.running:
|
||||
self.running = False
|
||||
self.task.cancel()
|
||||
@@ -3,7 +3,6 @@ import typing
|
||||
import logging
|
||||
from lbry.utils import cache_concurrent
|
||||
from lbry.blob_exchange.client import request_blob
|
||||
from lbry.dht.node import get_kademlia_peers_from_hosts
|
||||
if typing.TYPE_CHECKING:
|
||||
from lbry.conf import Config
|
||||
from lbry.dht.node import Node
|
||||
@@ -88,6 +87,7 @@ class BlobDownloader:
|
||||
if blob.get_is_verified():
|
||||
return blob
|
||||
self.is_running.set()
|
||||
tried_for_this_blob: typing.Set['KademliaPeer'] = set()
|
||||
try:
|
||||
while not blob.get_is_verified() and self.is_running.is_set():
|
||||
batch: typing.Set['KademliaPeer'] = set(self.connections.keys())
|
||||
@@ -101,6 +101,8 @@ class BlobDownloader:
|
||||
for peer in sorted(batch, key=lambda peer: self.scores.get(peer, 0), reverse=True):
|
||||
if peer in self.ignored:
|
||||
continue
|
||||
if peer in tried_for_this_blob:
|
||||
continue
|
||||
if peer in self.active_connections:
|
||||
if peer not in re_add:
|
||||
re_add.add(peer)
|
||||
@@ -110,6 +112,7 @@ class BlobDownloader:
|
||||
log.debug("request %s from %s:%i", blob_hash[:8], peer.address, peer.tcp_port)
|
||||
t = self.loop.create_task(self.request_blob_from_peer(blob, peer, connection_id))
|
||||
self.active_connections[peer] = t
|
||||
tried_for_this_blob.add(peer)
|
||||
if not re_add:
|
||||
self.peer_queue.put_nowait(list(batch))
|
||||
await self.new_peer_or_finished()
|
||||
@@ -130,14 +133,11 @@ class BlobDownloader:
|
||||
protocol.close()
|
||||
|
||||
|
||||
async def download_blob(loop, config: 'Config', blob_manager: 'BlobManager', dht_node: 'Node',
|
||||
async def download_blob(loop, config: 'Config', blob_manager: 'BlobManager', node: 'Node',
|
||||
blob_hash: str) -> 'AbstractBlob':
|
||||
search_queue = asyncio.Queue(loop=loop, maxsize=config.max_connections_per_download)
|
||||
search_queue.put_nowait(blob_hash)
|
||||
peer_queue, accumulate_task = dht_node.accumulate_peers(search_queue)
|
||||
fixed_peers = None if not config.fixed_peers else await get_kademlia_peers_from_hosts(config.fixed_peers)
|
||||
if fixed_peers:
|
||||
loop.call_later(config.fixed_peer_delay, peer_queue.put_nowait, fixed_peers)
|
||||
peer_queue, accumulate_task = node.accumulate_peers(search_queue)
|
||||
downloader = BlobDownloader(loop, config, blob_manager, peer_queue)
|
||||
try:
|
||||
return await downloader.download_blob(blob_hash)
|
||||
|
||||
+5
-7
@@ -203,7 +203,7 @@ class MaxKeyFee(Setting[dict]):
|
||||
)
|
||||
parser.add_argument(
|
||||
self.no_cli_name,
|
||||
help="Disable maximum key fee check.",
|
||||
help=f"Disable maximum key fee check.",
|
||||
dest=self.name,
|
||||
const=None,
|
||||
action="store_const",
|
||||
@@ -613,7 +613,7 @@ class Config(CLIConfig):
|
||||
"ports or have firewall rules you likely want to disable this.", True
|
||||
)
|
||||
udp_port = Integer("UDP port for communicating on the LBRY DHT", 4444, previous_names=['dht_node_port'])
|
||||
tcp_port = Integer("TCP port to listen for incoming blob requests", 4444, previous_names=['peer_port'])
|
||||
tcp_port = Integer("TCP port to listen for incoming blob requests", 3333, previous_names=['peer_port'])
|
||||
prometheus_port = Integer("Port to expose prometheus metrics (off by default)", 0)
|
||||
network_interface = String("Interface to use for the DHT and blob exchange", '0.0.0.0')
|
||||
|
||||
@@ -634,8 +634,6 @@ class Config(CLIConfig):
|
||||
|
||||
# blob announcement and download
|
||||
save_blobs = Toggle("Save encrypted blob files for hosting, otherwise download blobs to memory only.", True)
|
||||
network_storage_limit = Integer("Disk space in MB to be allocated for helping the P2P network. 0 = disable", 0)
|
||||
blob_storage_limit = Integer("Disk space in MB to be allocated for blob storage. 0 = no limit", 0)
|
||||
blob_lru_cache_size = Integer(
|
||||
"LRU cache size for decrypted downloaded blobs used to minimize re-downloading the same blobs when "
|
||||
"replying to a range request. Set to 0 to disable.", 32
|
||||
@@ -693,19 +691,19 @@ class Config(CLIConfig):
|
||||
('spv19.lbry.com', 50001),
|
||||
])
|
||||
known_dht_nodes = Servers("Known nodes for bootstrapping connection to the DHT", [
|
||||
('dht.lbry.grin.io', 4444), # Grin
|
||||
('dht.lbry.madiator.com', 4444), # Madiator
|
||||
('lbrynet1.lbry.com', 4444), # US EAST
|
||||
('lbrynet2.lbry.com', 4444), # US WEST
|
||||
('lbrynet3.lbry.com', 4444), # EU
|
||||
('lbrynet4.lbry.com', 4444) # ASIA
|
||||
])
|
||||
|
||||
comment_server = String("Comment server API URL", "https://comments.lbry.com/api/v2")
|
||||
|
||||
# blockchain
|
||||
blockchain_name = String("Blockchain name - lbrycrd_main, lbrycrd_regtest, or lbrycrd_testnet", 'lbrycrd_main')
|
||||
|
||||
# daemon
|
||||
save_files = Toggle("Save downloaded files when calling `get` by default", False)
|
||||
save_files = Toggle("Save downloaded files when calling `get` by default", True)
|
||||
components_to_skip = Strings("components which will be skipped during start-up of daemon", [])
|
||||
share_usage_data = Toggle(
|
||||
"Whether to share usage stats and diagnostic info with LBRY.", False,
|
||||
|
||||
+4
-14
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import asyncio
|
||||
import typing
|
||||
import binascii
|
||||
import socket
|
||||
from lbry.utils import resolve_host
|
||||
from lbry.dht import constants
|
||||
@@ -31,10 +32,6 @@ class Node:
|
||||
self._refresh_task: asyncio.Task = None
|
||||
self._storage = storage
|
||||
|
||||
@property
|
||||
def stored_blob_hashes(self):
|
||||
return self.protocol.data_store.keys()
|
||||
|
||||
async def refresh_node(self, force_once=False):
|
||||
while True:
|
||||
# remove peers with expired blob announcements from the datastore
|
||||
@@ -83,7 +80,7 @@ class Node:
|
||||
await fut
|
||||
|
||||
async def announce_blob(self, blob_hash: str) -> typing.List[bytes]:
|
||||
hash_value = bytes.fromhex(blob_hash)
|
||||
hash_value = binascii.unhexlify(blob_hash.encode())
|
||||
assert len(hash_value) == constants.HASH_LENGTH
|
||||
peers = await self.peer_search(hash_value)
|
||||
|
||||
@@ -98,7 +95,7 @@ class Node:
|
||||
stored_to = [node_id for node_id, contacted in stored_to_tup if contacted]
|
||||
if stored_to:
|
||||
log.debug(
|
||||
"Stored %s to %i of %i attempted peers", hash_value.hex()[:8],
|
||||
"Stored %s to %i of %i attempted peers", binascii.hexlify(hash_value).decode()[:8],
|
||||
len(stored_to), len(peers)
|
||||
)
|
||||
else:
|
||||
@@ -226,7 +223,7 @@ class Node:
|
||||
# prioritize peers who reply to a dht ping first
|
||||
# this minimizes attempting to make tcp connections that won't work later to dead or unreachable peers
|
||||
|
||||
async for results in self.get_iterative_value_finder(bytes.fromhex(blob_hash)):
|
||||
async for results in self.get_iterative_value_finder(binascii.unhexlify(blob_hash.encode())):
|
||||
to_put = []
|
||||
for peer in results:
|
||||
if peer.address == self.protocol.external_ip and self.protocol.peer_port == peer.tcp_port:
|
||||
@@ -261,10 +258,3 @@ class Node:
|
||||
) -> typing.Tuple[asyncio.Queue, asyncio.Task]:
|
||||
queue = peer_queue or asyncio.Queue(loop=self.loop)
|
||||
return queue, self.loop.create_task(self._accumulate_peers_for_value(search_queue, queue))
|
||||
|
||||
|
||||
async def get_kademlia_peers_from_hosts(peer_list: typing.List[typing.Tuple[str, int]]) -> typing.List['KademliaPeer']:
|
||||
peer_address_list = [(await resolve_host(url, port, proto='tcp'), port) for url, port in peer_list]
|
||||
kademlia_peer_list = [make_kademlia_peer(None, address, None, tcp_port=port, allow_localhost=True)
|
||||
for address, port in peer_address_list]
|
||||
return kademlia_peer_list
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
import typing
|
||||
import asyncio
|
||||
import logging
|
||||
from binascii import hexlify
|
||||
from dataclasses import dataclass, field
|
||||
from functools import lru_cache
|
||||
from lbry.utils import is_valid_public_ipv4 as _is_valid_public_ipv4, LRUCache
|
||||
@@ -153,7 +154,7 @@ class KademliaPeer:
|
||||
def __post_init__(self):
|
||||
if self._node_id is not None:
|
||||
if not len(self._node_id) == constants.HASH_LENGTH:
|
||||
raise ValueError("invalid node_id: {}".format(self._node_id.hex()))
|
||||
raise ValueError("invalid node_id: {}".format(hexlify(self._node_id).decode()))
|
||||
if self.udp_port is not None and not 1024 <= self.udp_port <= 65535:
|
||||
raise ValueError(f"invalid udp port: {self.address}:{self.udp_port}")
|
||||
if self.tcp_port is not None and not 1024 <= self.tcp_port <= 65535:
|
||||
|
||||
@@ -16,12 +16,6 @@ class DictDataStore:
|
||||
self._peer_manager = peer_manager
|
||||
self.completed_blobs: typing.Set[str] = set()
|
||||
|
||||
def keys(self):
|
||||
return self._data_store.keys()
|
||||
|
||||
def __len__(self):
|
||||
return self._data_store.__len__()
|
||||
|
||||
def removed_expired_peers(self):
|
||||
now = self.loop.time()
|
||||
keys = list(self._data_store.keys())
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
from binascii import hexlify
|
||||
from itertools import chain
|
||||
from collections import defaultdict
|
||||
import typing
|
||||
@@ -197,7 +198,7 @@ class IterativeFinder:
|
||||
added += 1
|
||||
log.debug("running %d probes", len(self.running_probes))
|
||||
if not added and not self.running_probes:
|
||||
log.debug("search for %s exhausted", self.key.hex()[:8])
|
||||
log.debug("search for %s exhausted", hexlify(self.key)[:8])
|
||||
self.search_exhausted()
|
||||
|
||||
def _schedule_probe(self, peer: 'KademliaPeer'):
|
||||
@@ -270,7 +271,7 @@ class IterativeNodeFinder(IterativeFinder):
|
||||
self.yielded_peers: typing.Set['KademliaPeer'] = set()
|
||||
|
||||
async def send_probe(self, peer: 'KademliaPeer') -> FindNodeResponse:
|
||||
log.debug("probing %s:%d %s", peer.address, peer.udp_port, peer.node_id.hex()[:8] if peer.node_id else '')
|
||||
log.debug("probing %s:%d %s", peer.address, peer.udp_port, hexlify(peer.node_id)[:8] if peer.node_id else '')
|
||||
response = await self.protocol.get_rpc_peer(peer).find_node(self.key)
|
||||
return FindNodeResponse(self.key, response)
|
||||
|
||||
@@ -346,6 +347,7 @@ class IterativeValueFinder(IterativeFinder):
|
||||
already_known + len(parsed.found_compact_addresses))
|
||||
if len(self.discovered_peers[peer]) != already_known + len(parsed.found_compact_addresses):
|
||||
log.warning("misbehaving peer %s:%i returned duplicate peers for blob", peer.address, peer.udp_port)
|
||||
parsed.found_compact_addresses.clear()
|
||||
elif len(parsed.found_compact_addresses) >= constants.K and self.peer_pages[peer] < parsed.pages:
|
||||
# the peer returned a full page and indicates it has more
|
||||
self.peer_pages[peer] += 1
|
||||
|
||||
@@ -4,6 +4,7 @@ import functools
|
||||
import hashlib
|
||||
import asyncio
|
||||
import typing
|
||||
import binascii
|
||||
import random
|
||||
from asyncio.protocols import DatagramProtocol
|
||||
from asyncio.transports import DatagramTransport
|
||||
@@ -96,7 +97,7 @@ class KademliaRPC:
|
||||
if not rpc_contact.tcp_port or peer.compact_address_tcp() != rpc_contact.compact_address_tcp()
|
||||
]
|
||||
# if we don't have k storing peers to return and we have this hash locally, include our contact information
|
||||
if len(peers) < constants.K and key.hex() in self.protocol.data_store.completed_blobs:
|
||||
if len(peers) < constants.K and binascii.hexlify(key).decode() in self.protocol.data_store.completed_blobs:
|
||||
peers.append(self.compact_address())
|
||||
if not peers:
|
||||
response[PAGE_KEY] = 0
|
||||
@@ -414,8 +415,8 @@ class KademliaProtocol(DatagramProtocol):
|
||||
self._wakeup_routing_task.clear()
|
||||
|
||||
def _handle_rpc(self, sender_contact: 'KademliaPeer', message: RequestDatagram):
|
||||
assert sender_contact.node_id != self.node_id, (sender_contact.node_id.hex()[:8],
|
||||
self.node_id.hex()[:8])
|
||||
assert sender_contact.node_id != self.node_id, (binascii.hexlify(sender_contact.node_id)[:8].decode(),
|
||||
binascii.hexlify(self.node_id)[:8].decode())
|
||||
method = message.method
|
||||
if method not in [b'ping', b'store', b'findNode', b'findValue']:
|
||||
raise AttributeError('Invalid method: %s' % message.method.decode())
|
||||
@@ -555,12 +556,12 @@ class KademliaProtocol(DatagramProtocol):
|
||||
address[0], address[1], OLD_PROTOCOL_ERRORS[error_datagram.response]
|
||||
)
|
||||
|
||||
def datagram_received(self, datagram: bytes, address: typing.Tuple[str, int]) -> None: # pylint: disable=arguments-renamed
|
||||
def datagram_received(self, datagram: bytes, address: typing.Tuple[str, int]) -> None: # pylint: disable=arguments-differ
|
||||
try:
|
||||
message = decode_datagram(datagram)
|
||||
except (ValueError, TypeError, DecodeError):
|
||||
self.peer_manager.report_failure(address[0], address[1])
|
||||
log.warning("Couldn't decode dht datagram from %s: %s", address, datagram.hex())
|
||||
log.warning("Couldn't decode dht datagram from %s: %s", address, binascii.hexlify(datagram).decode())
|
||||
return
|
||||
|
||||
if isinstance(message, RequestDatagram):
|
||||
@@ -602,7 +603,7 @@ class KademliaProtocol(DatagramProtocol):
|
||||
if len(data) > constants.MSG_SIZE_LIMIT:
|
||||
log.warning("cannot send datagram larger than %i bytes (packet is %i bytes)",
|
||||
constants.MSG_SIZE_LIMIT, len(data))
|
||||
log.debug("Packet is too large to send: %s", data[:3500].hex())
|
||||
log.debug("Packet is too large to send: %s", binascii.hexlify(data[:3500]).decode())
|
||||
raise ValueError(
|
||||
f"cannot send datagram larger than {constants.MSG_SIZE_LIMIT} bytes (packet is {len(data)} bytes)"
|
||||
)
|
||||
@@ -662,13 +663,13 @@ class KademliaProtocol(DatagramProtocol):
|
||||
res = await self.get_rpc_peer(peer).store(hash_value)
|
||||
if res != b"OK":
|
||||
raise ValueError(res)
|
||||
log.debug("Stored %s to %s", hash_value.hex()[:8], peer)
|
||||
log.debug("Stored %s to %s", binascii.hexlify(hash_value).decode()[:8], peer)
|
||||
return peer.node_id, True
|
||||
|
||||
try:
|
||||
return await __store()
|
||||
except asyncio.TimeoutError:
|
||||
log.debug("Timeout while storing blob_hash %s at %s", hash_value.hex()[:8], peer)
|
||||
log.debug("Timeout while storing blob_hash %s at %s", binascii.hexlify(hash_value).decode()[:8], peer)
|
||||
return peer.node_id, False
|
||||
except ValueError as err:
|
||||
log.error("Unexpected response: %s", err)
|
||||
|
||||
@@ -50,7 +50,7 @@ class KBucket:
|
||||
self.peers.append(peer)
|
||||
return True
|
||||
else:
|
||||
for i, _ in enumerate(self.peers):
|
||||
for i in range(len(self.peers)):
|
||||
local_peer = self.peers[i]
|
||||
if local_peer.node_id == peer.node_id:
|
||||
self.peers.remove(local_peer)
|
||||
|
||||
@@ -181,7 +181,7 @@ def decode_datagram(datagram: bytes) -> typing.Union[RequestDatagram, ResponseDa
|
||||
def make_compact_ip(address: str) -> bytearray:
|
||||
compact_ip = reduce(lambda buff, x: buff + bytearray([int(x)]), address.split('.'), bytearray())
|
||||
if len(compact_ip) != 4:
|
||||
raise ValueError("invalid IPv4 length")
|
||||
raise ValueError(f"invalid IPv4 length")
|
||||
return compact_ip
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ def make_compact_address(node_id: bytes, address: str, port: int) -> bytearray:
|
||||
if not 0 < port < 65536:
|
||||
raise ValueError(f'Invalid port: {port}')
|
||||
if len(node_id) != constants.HASH_BITS // 8:
|
||||
raise ValueError("invalid node node_id length")
|
||||
raise ValueError(f"invalid node node_id length")
|
||||
return compact_ip + port.to_bytes(2, 'big') + node_id
|
||||
|
||||
|
||||
@@ -201,5 +201,5 @@ def decode_compact_address(compact_address: bytes) -> typing.Tuple[bytes, str, i
|
||||
if not 0 < port < 65536:
|
||||
raise ValueError(f'Invalid port: {port}')
|
||||
if len(node_id) != constants.HASH_BITS // 8:
|
||||
raise ValueError("invalid node node_id length")
|
||||
raise ValueError(f"invalid node node_id length")
|
||||
return node_id, address, port
|
||||
+1
-12
@@ -34,11 +34,6 @@ Code | Name | Message
|
||||
**11x** | InputValue(ValueError) | Invalid argument value provided to command.
|
||||
111 | GenericInputValue | The value '{value}' for argument '{argument}' is not valid.
|
||||
112 | InputValueIsNone | None or null is not valid value for argument '{argument}'.
|
||||
113 | ConflictingInputValue | Only '{first_argument}' or '{second_argument}' is allowed, not both.
|
||||
114 | InputStringIsBlank | {argument} cannot be blank.
|
||||
115 | EmptyPublishedFile | Cannot publish empty file: {file_path}
|
||||
116 | MissingPublishedFile | File does not exist: {file_path}
|
||||
117 | InvalidStreamURL | Invalid LBRY stream URL: '{url}' -- When an URL cannot be downloaded, such as '@Channel/' or a collection
|
||||
**2xx** | Configuration | Configuration errors.
|
||||
201 | ConfigWrite | Cannot write configuration file '{path}'. -- When writing the default config fails on startup, such as due to permission issues.
|
||||
202 | ConfigRead | Cannot find provided configuration file '{path}'. -- Can't open the config file user provided via command line args.
|
||||
@@ -56,22 +51,16 @@ Code | Name | Message
|
||||
405 | ChannelKeyNotFound | Channel signing key not found.
|
||||
406 | ChannelKeyInvalid | Channel signing key is out of date. -- For example, channel was updated but you don't have the updated key.
|
||||
407 | DataDownload | Failed to download blob. *generic*
|
||||
408 | PrivateKeyNotFound | Couldn't find private key for {key} '{value}'.
|
||||
410 | Resolve | Failed to resolve '{url}'.
|
||||
411 | ResolveTimeout | Failed to resolve '{url}' within the timeout.
|
||||
411 | ResolveCensored | Resolve of '{url}' was censored by channel with claim id '{censor_id}'.
|
||||
420 | KeyFeeAboveMaxAllowed | {message}
|
||||
421 | InvalidPassword | Password is invalid.
|
||||
422 | IncompatibleWalletServer | '{server}:{port}' has an incompatibly old version.
|
||||
423 | TooManyClaimSearchParameters | {key} cant have more than {limit} items.
|
||||
424 | AlreadyPurchased | You already have a purchase for claim_id '{claim_id_hex}'. Use --allow-duplicate-purchase flag to override.
|
||||
423 | TooManyClaimSearchParameters | {key} cant be set for more than {limit} items.
|
||||
431 | ServerPaymentInvalidAddress | Invalid address from wallet server: '{address}' - skipping payment round.
|
||||
432 | ServerPaymentWalletLocked | Cannot spend funds with locked wallet, skipping payment round.
|
||||
433 | ServerPaymentFeeAboveMaxAllowed | Daily server fee of {daily_fee} exceeds maximum configured of {max_fee} LBC.
|
||||
434 | WalletNotLoaded | Wallet {wallet_id} is not loaded.
|
||||
435 | WalletAlreadyLoaded | Wallet {wallet_path} is already loaded.
|
||||
436 | WalletNotFound | Wallet not found at {wallet_path}.
|
||||
437 | WalletAlreadyExists | Wallet {wallet_path} already exists, use `wallet_add` to load it.
|
||||
**5xx** | Blob | **Blobs**
|
||||
500 | BlobNotFound | Blob not found.
|
||||
501 | BlobPermissionDenied | Permission denied to read blob.
|
||||
|
||||
+2
-88
@@ -76,45 +76,6 @@ class InputValueIsNoneError(InputValueError):
|
||||
super().__init__(f"None or null is not valid value for argument '{argument}'.")
|
||||
|
||||
|
||||
class ConflictingInputValueError(InputValueError):
|
||||
|
||||
def __init__(self, first_argument, second_argument):
|
||||
self.first_argument = first_argument
|
||||
self.second_argument = second_argument
|
||||
super().__init__(f"Only '{first_argument}' or '{second_argument}' is allowed, not both.")
|
||||
|
||||
|
||||
class InputStringIsBlankError(InputValueError):
|
||||
|
||||
def __init__(self, argument):
|
||||
self.argument = argument
|
||||
super().__init__(f"{argument} cannot be blank.")
|
||||
|
||||
|
||||
class EmptyPublishedFileError(InputValueError):
|
||||
|
||||
def __init__(self, file_path):
|
||||
self.file_path = file_path
|
||||
super().__init__(f"Cannot publish empty file: {file_path}")
|
||||
|
||||
|
||||
class MissingPublishedFileError(InputValueError):
|
||||
|
||||
def __init__(self, file_path):
|
||||
self.file_path = file_path
|
||||
super().__init__(f"File does not exist: {file_path}")
|
||||
|
||||
|
||||
class InvalidStreamURLError(InputValueError):
|
||||
"""
|
||||
When an URL cannot be downloaded, such as '@Channel/' or a collection
|
||||
"""
|
||||
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
super().__init__(f"Invalid LBRY stream URL: '{url}'")
|
||||
|
||||
|
||||
class ConfigurationError(BaseError):
|
||||
"""
|
||||
Configuration errors.
|
||||
@@ -238,14 +199,6 @@ class DataDownloadError(WalletError):
|
||||
super().__init__("Failed to download blob. *generic*")
|
||||
|
||||
|
||||
class PrivateKeyNotFoundError(WalletError):
|
||||
|
||||
def __init__(self, key, value):
|
||||
self.key = key
|
||||
self.value = value
|
||||
super().__init__(f"Couldn't find private key for {key} '{value}'.")
|
||||
|
||||
|
||||
class ResolveError(WalletError):
|
||||
|
||||
def __init__(self, url):
|
||||
@@ -262,10 +215,9 @@ class ResolveTimeoutError(WalletError):
|
||||
|
||||
class ResolveCensoredError(WalletError):
|
||||
|
||||
def __init__(self, url, censor_id, censor_row):
|
||||
def __init__(self, url, censor_id):
|
||||
self.url = url
|
||||
self.censor_id = censor_id
|
||||
self.censor_row = censor_row
|
||||
super().__init__(f"Resolve of '{url}' was censored by channel with claim id '{censor_id}'.")
|
||||
|
||||
|
||||
@@ -295,17 +247,7 @@ class TooManyClaimSearchParametersError(WalletError):
|
||||
def __init__(self, key, limit):
|
||||
self.key = key
|
||||
self.limit = limit
|
||||
super().__init__(f"{key} cant have more than {limit} items.")
|
||||
|
||||
|
||||
class AlreadyPurchasedError(WalletError):
|
||||
"""
|
||||
allow-duplicate-purchase flag to override.
|
||||
"""
|
||||
|
||||
def __init__(self, claim_id_hex):
|
||||
self.claim_id_hex = claim_id_hex
|
||||
super().__init__(f"You already have a purchase for claim_id '{claim_id_hex}'. Use")
|
||||
super().__init__(f"{key} cant be set for more than {limit} items.")
|
||||
|
||||
|
||||
class ServerPaymentInvalidAddressError(WalletError):
|
||||
@@ -329,34 +271,6 @@ class ServerPaymentFeeAboveMaxAllowedError(WalletError):
|
||||
super().__init__(f"Daily server fee of {daily_fee} exceeds maximum configured of {max_fee} LBC.")
|
||||
|
||||
|
||||
class WalletNotLoadedError(WalletError):
|
||||
|
||||
def __init__(self, wallet_id):
|
||||
self.wallet_id = wallet_id
|
||||
super().__init__(f"Wallet {wallet_id} is not loaded.")
|
||||
|
||||
|
||||
class WalletAlreadyLoadedError(WalletError):
|
||||
|
||||
def __init__(self, wallet_path):
|
||||
self.wallet_path = wallet_path
|
||||
super().__init__(f"Wallet {wallet_path} is already loaded.")
|
||||
|
||||
|
||||
class WalletNotFoundError(WalletError):
|
||||
|
||||
def __init__(self, wallet_path):
|
||||
self.wallet_path = wallet_path
|
||||
super().__init__(f"Wallet not found at {wallet_path}.")
|
||||
|
||||
|
||||
class WalletAlreadyExistsError(WalletError):
|
||||
|
||||
def __init__(self, wallet_path):
|
||||
self.wallet_path = wallet_path
|
||||
super().__init__(f"Wallet {wallet_path} already exists, use `wallet_add` to load it.")
|
||||
|
||||
|
||||
class BlobError(BaseError):
|
||||
"""
|
||||
**Blobs**
|
||||
|
||||
@@ -63,7 +63,7 @@ class ErrorClass:
|
||||
@staticmethod
|
||||
def get_fields(args):
|
||||
if len(args) > 1:
|
||||
return ''.join(f'\n{INDENT*2}self.{field} = {field}' for field in args[1:])
|
||||
return f''.join(f'\n{INDENT*2}self.{field} = {field}' for field in args[1:])
|
||||
return ''
|
||||
|
||||
@staticmethod
|
||||
|
||||
+23
-4
@@ -101,7 +101,7 @@ class ArgumentParser(argparse.ArgumentParser):
|
||||
self._optionals.title = 'Options'
|
||||
if group_name is None:
|
||||
self.epilog = (
|
||||
"Run 'lbrynet COMMAND --help' for more information on a command or group."
|
||||
f"Run 'lbrynet COMMAND --help' for more information on a command or group."
|
||||
)
|
||||
else:
|
||||
self.epilog = (
|
||||
@@ -190,6 +190,10 @@ def get_argument_parser():
|
||||
'--no-logging', dest='no_logging', action="store_true",
|
||||
help='Disable all logging of any kind.'
|
||||
)
|
||||
start.add_argument(
|
||||
'--show-stack-trace', dest='show_stack_trace', action="store_true",
|
||||
help='Show full stack trace on error.'
|
||||
)
|
||||
start.add_argument(
|
||||
'--verbose', nargs="*",
|
||||
help=('Enable debug output for lbry logger and event loop. Optionally specify loggers for which debug output '
|
||||
@@ -226,9 +230,6 @@ def get_argument_parser():
|
||||
def ensure_directory_exists(path: str):
|
||||
if not os.path.isdir(path):
|
||||
pathlib.Path(path).mkdir(parents=True, exist_ok=True)
|
||||
use_effective_ids = os.access in os.supports_effective_ids
|
||||
if not os.access(path, os.W_OK, effective_ids=use_effective_ids):
|
||||
raise PermissionError(f"The following directory is not writable: {path}")
|
||||
|
||||
|
||||
LOG_MODULES = 'lbry', 'aioupnp'
|
||||
@@ -258,10 +259,28 @@ def setup_logging(logger: logging.Logger, args: argparse.Namespace, conf: Config
|
||||
logger.getChild('lbry').setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
def make_stack_trace_supressing_record_factory(original_factory):
|
||||
def factory(*args, **kwargs):
|
||||
record = original_factory(*args, **kwargs)
|
||||
if record.exc_info:
|
||||
record.msg += f" ({record.exc_info[0].__name__}: {record.exc_info[1]})"
|
||||
record.exc_info = None
|
||||
record.exc_text = None
|
||||
return record
|
||||
return factory
|
||||
|
||||
|
||||
def warning_error_handler(loop, context):
|
||||
logging.warning("Uncaught exception: %s", context)
|
||||
|
||||
|
||||
def run_daemon(args: argparse.Namespace, conf: Config):
|
||||
loop = asyncio.get_event_loop()
|
||||
if args.verbose is not None:
|
||||
loop.set_debug(True)
|
||||
elif not args.show_stack_trace:
|
||||
loop.set_exception_handler(warning_error_handler)
|
||||
logging.setLogRecordFactory(make_stack_trace_supressing_record_factory(logging.getLogRecordFactory()))
|
||||
if not args.no_logging:
|
||||
setup_logging(logging.getLogger(), args, conf)
|
||||
daemon = Daemon(conf)
|
||||
|
||||
@@ -18,7 +18,6 @@ DOWNLOAD_STARTED = 'Download Started'
|
||||
DOWNLOAD_ERRORED = 'Download Errored'
|
||||
DOWNLOAD_FINISHED = 'Download Finished'
|
||||
HEARTBEAT = 'Heartbeat'
|
||||
DISK_SPACE = 'Disk Space'
|
||||
CLAIM_ACTION = 'Claim Action' # publish/create/update/abandon
|
||||
NEW_CHANNEL = 'New Channel'
|
||||
CREDITS_SENT = 'Credits Sent'
|
||||
@@ -170,15 +169,6 @@ class AnalyticsManager:
|
||||
})
|
||||
)
|
||||
|
||||
async def send_disk_space_used(self, storage_used, storage_limit, is_from_network_quota):
|
||||
await self.track(
|
||||
self._event(DISK_SPACE, {
|
||||
'used': storage_used,
|
||||
'limit': storage_limit,
|
||||
'from_network_quota': is_from_network_quota
|
||||
})
|
||||
)
|
||||
|
||||
async def send_server_startup(self):
|
||||
await self.track(self._event(SERVER_STARTUP))
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import logging
|
||||
import time
|
||||
import hashlib
|
||||
import binascii
|
||||
|
||||
import ecdsa
|
||||
from lbry import utils
|
||||
from lbry.crypto.hash import sha256
|
||||
from lbry.wallet.transaction import Output
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_encoded_signature(signature):
|
||||
signature = signature.encode() if isinstance(signature, str) else signature
|
||||
r = int(signature[:int(len(signature) / 2)], 16)
|
||||
s = int(signature[int(len(signature) / 2):], 16)
|
||||
return ecdsa.util.sigencode_der(r, s, len(signature) * 4)
|
||||
|
||||
|
||||
def cid2hash(claim_id: str) -> bytes:
|
||||
return binascii.unhexlify(claim_id.encode())[::-1]
|
||||
|
||||
|
||||
def is_comment_signed_by_channel(comment: dict, channel: Output, sign_comment_id=False):
|
||||
if isinstance(channel, Output):
|
||||
try:
|
||||
signing_field = comment['comment_id'] if sign_comment_id else comment['comment']
|
||||
return verify(channel, signing_field.encode(), comment, cid2hash(comment['channel_id']))
|
||||
except KeyError:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def verify(channel, data, signature, channel_hash=None):
|
||||
pieces = [
|
||||
signature['signing_ts'].encode(),
|
||||
channel_hash or channel.claim_hash,
|
||||
data
|
||||
]
|
||||
return Output.is_signature_valid(
|
||||
get_encoded_signature(signature['signature']),
|
||||
sha256(b''.join(pieces)),
|
||||
channel.claim.channel.public_key_bytes
|
||||
)
|
||||
|
||||
|
||||
def sign_comment(comment: dict, channel: Output, sign_comment_id=False):
|
||||
signing_field = comment['comment_id'] if sign_comment_id else comment['comment']
|
||||
comment.update(sign(channel, signing_field.encode()))
|
||||
|
||||
|
||||
def sign(channel, data):
|
||||
timestamp = str(int(time.time()))
|
||||
pieces = [timestamp.encode(), channel.claim_hash, data]
|
||||
digest = sha256(b''.join(pieces))
|
||||
signature = channel.private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
|
||||
return {
|
||||
'signature': binascii.hexlify(signature).decode(),
|
||||
'signing_ts': timestamp
|
||||
}
|
||||
|
||||
|
||||
def sign_reaction(reaction: dict, channel: Output):
|
||||
signing_field = reaction['channel_name']
|
||||
reaction.update(sign(channel, signing_field.encode()))
|
||||
|
||||
|
||||
async def jsonrpc_post(url: str, method: str, params: dict = None, **kwargs) -> any:
|
||||
params = params or {}
|
||||
params.update(kwargs)
|
||||
json_body = {'jsonrpc': '2.0', 'id': 1, 'method': method, 'params': params}
|
||||
async with utils.aiohttp_request('POST', url, json=json_body) as response:
|
||||
try:
|
||||
result = await response.json()
|
||||
return result['result'] if 'result' in result else result
|
||||
except Exception as cte:
|
||||
log.exception('Unable to decode response from server: %s', cte)
|
||||
return await response.text()
|
||||
@@ -4,7 +4,6 @@ import asyncio
|
||||
import logging
|
||||
import binascii
|
||||
import typing
|
||||
|
||||
import base58
|
||||
|
||||
from aioupnp import __version__ as aioupnp_version
|
||||
@@ -16,9 +15,7 @@ from lbry.dht.node import Node
|
||||
from lbry.dht.peer import is_valid_public_ipv4
|
||||
from lbry.dht.blob_announcer import BlobAnnouncer
|
||||
from lbry.blob.blob_manager import BlobManager
|
||||
from lbry.blob.disk_space_manager import DiskSpaceManager
|
||||
from lbry.blob_exchange.server import BlobServer
|
||||
from lbry.stream.background_downloader import BackgroundDownloader
|
||||
from lbry.stream.stream_manager import StreamManager
|
||||
from lbry.file.file_manager import FileManager
|
||||
from lbry.extras.daemon.component import Component
|
||||
@@ -43,8 +40,6 @@ WALLET_SERVER_PAYMENTS_COMPONENT = "wallet_server_payments"
|
||||
DHT_COMPONENT = "dht"
|
||||
HASH_ANNOUNCER_COMPONENT = "hash_announcer"
|
||||
FILE_MANAGER_COMPONENT = "file_manager"
|
||||
DISK_SPACE_COMPONENT = "disk_space"
|
||||
BACKGROUND_DOWNLOADER_COMPONENT = "background_downloader"
|
||||
PEER_PROTOCOL_SERVER_COMPONENT = "peer_protocol_server"
|
||||
UPNP_COMPONENT = "upnp"
|
||||
EXCHANGE_RATE_MANAGER_COMPONENT = "exchange_rate_manager"
|
||||
@@ -64,7 +59,7 @@ class DatabaseComponent(Component):
|
||||
|
||||
@staticmethod
|
||||
def get_current_db_revision():
|
||||
return 15
|
||||
return 14
|
||||
|
||||
@property
|
||||
def revision_filename(self):
|
||||
@@ -380,98 +375,6 @@ class FileManagerComponent(Component):
|
||||
self.file_manager.stop()
|
||||
|
||||
|
||||
class BackgroundDownloaderComponent(Component):
|
||||
component_name = BACKGROUND_DOWNLOADER_COMPONENT
|
||||
depends_on = [DATABASE_COMPONENT, BLOB_COMPONENT, DISK_SPACE_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
super().__init__(component_manager)
|
||||
self.background_task: typing.Optional[asyncio.Task] = None
|
||||
self.download_loop_delay_seconds = 60
|
||||
self.ongoing_download: typing.Optional[asyncio.Task] = None
|
||||
self.space_manager: typing.Optional[DiskSpaceManager] = None
|
||||
self.blob_manager: typing.Optional[BlobManager] = None
|
||||
self.background_downloader: typing.Optional[BackgroundDownloader] = None
|
||||
self.dht_node: typing.Optional[Node] = None
|
||||
self.space_available: typing.Optional[int] = None
|
||||
|
||||
@property
|
||||
def is_busy(self):
|
||||
return bool(self.ongoing_download and not self.ongoing_download.done())
|
||||
|
||||
@property
|
||||
def component(self) -> 'BackgroundDownloaderComponent':
|
||||
return self
|
||||
|
||||
async def get_status(self):
|
||||
return {'running': self.background_task is not None and not self.background_task.done(),
|
||||
'available_free_space_mb': self.space_available,
|
||||
'ongoing_download': self.is_busy}
|
||||
|
||||
async def download_blobs_in_background(self):
|
||||
while True:
|
||||
self.space_available = await self.space_manager.get_free_space_mb(True)
|
||||
if not self.is_busy and self.space_available > 10:
|
||||
blob_hash = next((key.hex() for key in self.dht_node.stored_blob_hashes if
|
||||
key.hex() not in self.blob_manager.completed_blob_hashes), None)
|
||||
if blob_hash:
|
||||
self.ongoing_download = asyncio.create_task(self.background_downloader.download_blobs(blob_hash))
|
||||
await asyncio.sleep(self.download_loop_delay_seconds)
|
||||
|
||||
async def start(self):
|
||||
self.space_manager: DiskSpaceManager = self.component_manager.get_component(DISK_SPACE_COMPONENT)
|
||||
if not self.component_manager.has_component(DHT_COMPONENT):
|
||||
return
|
||||
self.dht_node = self.component_manager.get_component(DHT_COMPONENT)
|
||||
self.blob_manager = self.component_manager.get_component(BLOB_COMPONENT)
|
||||
storage = self.component_manager.get_component(DATABASE_COMPONENT)
|
||||
self.background_downloader = BackgroundDownloader(self.conf, storage, self.blob_manager, self.dht_node)
|
||||
self.background_task = asyncio.create_task(self.download_blobs_in_background())
|
||||
|
||||
async def stop(self):
|
||||
if self.ongoing_download and not self.ongoing_download.done():
|
||||
self.ongoing_download.cancel()
|
||||
if self.background_task:
|
||||
self.background_task.cancel()
|
||||
|
||||
|
||||
class DiskSpaceComponent(Component):
|
||||
component_name = DISK_SPACE_COMPONENT
|
||||
depends_on = [DATABASE_COMPONENT, BLOB_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
super().__init__(component_manager)
|
||||
self.disk_space_manager: typing.Optional[DiskSpaceManager] = None
|
||||
|
||||
@property
|
||||
def component(self) -> typing.Optional[DiskSpaceManager]:
|
||||
return self.disk_space_manager
|
||||
|
||||
async def get_status(self):
|
||||
if self.disk_space_manager:
|
||||
space_used = await self.disk_space_manager.get_space_used_mb(cached=True)
|
||||
return {
|
||||
'total_used_mb': space_used['total'],
|
||||
'published_blobs_storage_used_mb': space_used['private_storage'],
|
||||
'content_blobs_storage_used_mb': space_used['content_storage'],
|
||||
'seed_blobs_storage_used_mb': space_used['network_storage'],
|
||||
'running': self.disk_space_manager.running,
|
||||
}
|
||||
return {'space_used': '0', 'network_seeding_space_used': '0', 'running': False}
|
||||
|
||||
async def start(self):
|
||||
db = self.component_manager.get_component(DATABASE_COMPONENT)
|
||||
blob_manager = self.component_manager.get_component(BLOB_COMPONENT)
|
||||
self.disk_space_manager = DiskSpaceManager(
|
||||
self.conf, db, blob_manager,
|
||||
analytics=self.component_manager.analytics_manager
|
||||
)
|
||||
await self.disk_space_manager.start()
|
||||
|
||||
async def stop(self):
|
||||
await self.disk_space_manager.stop()
|
||||
|
||||
|
||||
class TorrentComponent(Component):
|
||||
component_name = LIBTORRENT_COMPONENT
|
||||
|
||||
|
||||
+485
-202
File diff suppressed because it is too large.
Load diff
@@ -123,7 +123,7 @@ class JSONResponseEncoder(JSONEncoder):
|
||||
self.ledger = ledger
|
||||
self.include_protobuf = include_protobuf
|
||||
|
||||
def default(self, obj): # pylint: disable=method-hidden,arguments-renamed,too-many-return-statements
|
||||
def default(self, obj): # pylint: disable=method-hidden,arguments-differ,too-many-return-statements
|
||||
if isinstance(obj, Account):
|
||||
return self.encode_account(obj)
|
||||
if isinstance(obj, Wallet):
|
||||
|
||||
@@ -35,8 +35,6 @@ def migrate_db(conf, start, end):
|
||||
from .migrate12to13 import do_migration
|
||||
elif current == 13:
|
||||
from .migrate13to14 import do_migration
|
||||
elif current == 14:
|
||||
from .migrate14to15 import do_migration
|
||||
else:
|
||||
raise Exception(f"DB migration of version {current} to {current+1} is not available")
|
||||
try:
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import os
|
||||
import sqlite3
|
||||
|
||||
|
||||
def do_migration(conf):
|
||||
db_path = os.path.join(conf.data_dir, "lbrynet.sqlite")
|
||||
connection = sqlite3.connect(db_path)
|
||||
cursor = connection.cursor()
|
||||
|
||||
cursor.executescript("""
|
||||
alter table blob add column added_on integer not null default 0;
|
||||
alter table blob add column is_mine integer not null default 1;
|
||||
""")
|
||||
|
||||
connection.commit()
|
||||
connection.close()
|
||||
@@ -170,8 +170,8 @@ def get_all_lbry_files(transaction: sqlite3.Connection) -> typing.List[typing.Di
|
||||
def store_stream(transaction: sqlite3.Connection, sd_blob: 'BlobFile', descriptor: 'StreamDescriptor'):
|
||||
# add all blobs, except the last one, which is empty
|
||||
transaction.executemany(
|
||||
"insert or ignore into blob values (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
((blob.blob_hash, blob.length, 0, 0, "pending", 0, 0, blob.added_on, blob.is_mine)
|
||||
"insert or ignore into blob values (?, ?, ?, ?, ?, ?, ?)",
|
||||
((blob.blob_hash, blob.length, 0, 0, "pending", 0, 0)
|
||||
for blob in (descriptor.blobs[:-1] if len(descriptor.blobs) > 1 else descriptor.blobs) + [sd_blob])
|
||||
).fetchall()
|
||||
# associate the blobs to the stream
|
||||
@@ -242,9 +242,7 @@ class SQLiteStorage(SQLiteMixin):
|
||||
should_announce integer not null default 0,
|
||||
status text not null,
|
||||
last_announced_time integer,
|
||||
single_announce integer,
|
||||
added_on integer not null,
|
||||
is_mine integer not null default 0
|
||||
single_announce integer
|
||||
);
|
||||
|
||||
create table if not exists stream (
|
||||
@@ -337,7 +335,6 @@ class SQLiteStorage(SQLiteMixin):
|
||||
tcp_port integer,
|
||||
unique (address, udp_port)
|
||||
);
|
||||
create index if not exists blob_data on blob(blob_hash, blob_length, is_mine);
|
||||
"""
|
||||
|
||||
def __init__(self, conf: Config, path, loop=None, time_getter: typing.Optional[typing.Callable[[], float]] = None):
|
||||
@@ -359,19 +356,19 @@ class SQLiteStorage(SQLiteMixin):
|
||||
|
||||
# # # # # # # # # blob functions # # # # # # # # #
|
||||
|
||||
async def add_blobs(self, *blob_hashes_and_lengths: typing.Tuple[str, int, int, int], finished=False):
|
||||
async def add_blobs(self, *blob_hashes_and_lengths: typing.Tuple[str, int], finished=False):
|
||||
def _add_blobs(transaction: sqlite3.Connection):
|
||||
transaction.executemany(
|
||||
"insert or ignore into blob values (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
"insert or ignore into blob values (?, ?, ?, ?, ?, ?, ?)",
|
||||
(
|
||||
(blob_hash, length, 0, 0, "pending" if not finished else "finished", 0, 0, added_on, is_mine)
|
||||
for blob_hash, length, added_on, is_mine in blob_hashes_and_lengths
|
||||
(blob_hash, length, 0, 0, "pending" if not finished else "finished", 0, 0)
|
||||
for blob_hash, length in blob_hashes_and_lengths
|
||||
)
|
||||
).fetchall()
|
||||
if finished:
|
||||
transaction.executemany(
|
||||
"update blob set status='finished' where blob.blob_hash=?", (
|
||||
(blob_hash, ) for blob_hash, _, _, _ in blob_hashes_and_lengths
|
||||
(blob_hash, ) for blob_hash, _ in blob_hashes_and_lengths
|
||||
)
|
||||
).fetchall()
|
||||
return await self.db.run(_add_blobs)
|
||||
@@ -381,11 +378,6 @@ class SQLiteStorage(SQLiteMixin):
|
||||
"select status from blob where blob_hash=?", blob_hash
|
||||
)
|
||||
|
||||
def set_announce(self, *blob_hashes):
|
||||
return self.db.execute_fetchall(
|
||||
"update blob set should_announce=1 where blob_hash in (?, ?)", blob_hashes
|
||||
)
|
||||
|
||||
def update_last_announced_blobs(self, blob_hashes: typing.List[str]):
|
||||
def _update_last_announced_blobs(transaction: sqlite3.Connection):
|
||||
last_announced = self.time_getter()
|
||||
@@ -443,59 +435,6 @@ class SQLiteStorage(SQLiteMixin):
|
||||
def get_all_blob_hashes(self):
|
||||
return self.run_and_return_list("select blob_hash from blob")
|
||||
|
||||
async def get_stored_blobs(self, is_mine: bool, is_network_blob=False):
|
||||
is_mine = 1 if is_mine else 0
|
||||
if is_network_blob:
|
||||
return await self.db.execute_fetchall(
|
||||
"select blob.blob_hash, blob.blob_length, blob.added_on "
|
||||
"from blob left join stream_blob using (blob_hash) "
|
||||
"where stream_blob.stream_hash is null and blob.is_mine=? order by blob.added_on asc",
|
||||
(is_mine,)
|
||||
)
|
||||
|
||||
sd_blobs = await self.db.execute_fetchall(
|
||||
"select blob.blob_hash, blob.blob_length, blob.added_on "
|
||||
"from blob join stream on blob.blob_hash=stream.sd_hash join file using (stream_hash) "
|
||||
"where blob.is_mine=? order by blob.added_on asc",
|
||||
(is_mine,)
|
||||
)
|
||||
content_blobs = await self.db.execute_fetchall(
|
||||
"select blob.blob_hash, blob.blob_length, blob.added_on "
|
||||
"from blob join stream_blob using (blob_hash) cross join stream using (stream_hash)"
|
||||
"cross join file using (stream_hash) where blob.is_mine=? order by blob.added_on asc",
|
||||
(is_mine,)
|
||||
)
|
||||
return content_blobs + sd_blobs
|
||||
|
||||
async def get_stored_blob_disk_usage(self):
|
||||
total, network_size, content_size, private_size = await self.db.execute_fetchone("""
|
||||
select coalesce(sum(blob_length), 0) as total,
|
||||
coalesce(sum(case when
|
||||
stream_blob.stream_hash is null
|
||||
then blob_length else 0 end), 0) as network_storage,
|
||||
coalesce(sum(case when
|
||||
stream_blob.blob_hash is not null and is_mine=0
|
||||
then blob_length else 0 end), 0) as content_storage,
|
||||
coalesce(sum(case when
|
||||
is_mine=1
|
||||
then blob_length else 0 end), 0) as private_storage
|
||||
from blob left join stream_blob using (blob_hash)
|
||||
""")
|
||||
return {
|
||||
'network_storage': network_size,
|
||||
'content_storage': content_size,
|
||||
'private_storage': private_size,
|
||||
'total': total
|
||||
}
|
||||
|
||||
async def update_blob_ownership(self, sd_hash, is_mine: bool):
|
||||
is_mine = 1 if is_mine else 0
|
||||
await self.db.execute_fetchall(
|
||||
"update blob set is_mine = ? where blob_hash in ("
|
||||
" select blob_hash from blob natural join stream_blob natural join stream where sd_hash = ?"
|
||||
") OR blob_hash = ?", (is_mine, sd_hash, sd_hash)
|
||||
)
|
||||
|
||||
def sync_missing_blobs(self, blob_files: typing.Set[str]) -> typing.Awaitable[typing.Set[str]]:
|
||||
def _sync_blobs(transaction: sqlite3.Connection) -> typing.Set[str]:
|
||||
finished_blob_hashes = tuple(
|
||||
@@ -631,10 +570,6 @@ class SQLiteStorage(SQLiteMixin):
|
||||
log.debug("update file status %s -> %s", stream_hash, new_status)
|
||||
return self.db.execute_fetchall("update file set status=? where stream_hash=?", (new_status, stream_hash))
|
||||
|
||||
def stop_all_files(self):
|
||||
log.debug("stopping all files")
|
||||
return self.db.execute_fetchall("update file set status=?", ("stopped",))
|
||||
|
||||
async def change_file_download_dir_and_file_name(self, stream_hash: str, download_dir: typing.Optional[str],
|
||||
file_name: typing.Optional[str]):
|
||||
if not file_name or not download_dir:
|
||||
@@ -682,7 +617,7 @@ class SQLiteStorage(SQLiteMixin):
|
||||
).fetchall()
|
||||
download_dir = binascii.hexlify(self.conf.download_dir.encode()).decode()
|
||||
transaction.executemany(
|
||||
"update file set download_directory=? where stream_hash=?",
|
||||
f"update file set download_directory=? where stream_hash=?",
|
||||
((download_dir, stream_hash) for stream_hash in stream_hashes)
|
||||
).fetchall()
|
||||
await self.db.run_with_foreign_keys_disabled(_recover)
|
||||
@@ -926,6 +861,6 @@ class SQLiteStorage(SQLiteMixin):
|
||||
transaction.execute('delete from peer').fetchall()
|
||||
transaction.executemany(
|
||||
'insert into peer(node_id, address, udp_port, tcp_port) values (?, ?, ?, ?)',
|
||||
((binascii.hexlify(p.node_id), p.address, p.udp_port, p.tcp_port) for p in peers)
|
||||
tuple([(binascii.hexlify(p.node_id), p.address, p.udp_port, p.tcp_port) for p in peers])
|
||||
).fetchall()
|
||||
return await self.db.run(_save_kademlia_peers)
|
||||
@@ -5,7 +5,6 @@ from typing import Optional
|
||||
from aiohttp.web import Request
|
||||
from lbry.error import ResolveError, DownloadSDTimeoutError, InsufficientFundsError
|
||||
from lbry.error import ResolveTimeoutError, DownloadDataTimeoutError, KeyFeeAboveMaxAllowedError
|
||||
from lbry.error import InvalidStreamURLError
|
||||
from lbry.stream.managed_stream import ManagedStream
|
||||
from lbry.torrent.torrent_manager import TorrentSource
|
||||
from lbry.utils import cache_concurrent
|
||||
@@ -82,11 +81,8 @@ class FileManager:
|
||||
payment = None
|
||||
try:
|
||||
# resolve the claim
|
||||
try:
|
||||
if not URL.parse(uri).has_stream:
|
||||
raise InvalidStreamURLError(uri)
|
||||
except ValueError:
|
||||
raise InvalidStreamURLError(uri)
|
||||
if not URL.parse(uri).has_stream:
|
||||
raise ResolveError("cannot download a channel claim, specify a /path")
|
||||
try:
|
||||
resolved_result = await asyncio.wait_for(
|
||||
self.wallet_manager.ledger.resolve(
|
||||
@@ -248,7 +244,7 @@ class FileManager:
|
||||
raise error
|
||||
except Exception as err: # forgive data timeout, don't delete stream
|
||||
expected = (DownloadSDTimeoutError, DownloadDataTimeoutError, InsufficientFundsError,
|
||||
KeyFeeAboveMaxAllowedError, ResolveError, InvalidStreamURLError)
|
||||
KeyFeeAboveMaxAllowedError)
|
||||
if isinstance(err, expected):
|
||||
log.warning("Failed to download %s: %s", uri, str(err))
|
||||
elif isinstance(err, asyncio.CancelledError):
|
||||
|
||||
@@ -69,8 +69,8 @@ class VideoFileAnalyzer:
|
||||
version = str(e)
|
||||
if code != 0 or not version.startswith("ffmpeg"):
|
||||
log.warning("Unable to run ffmpeg, but it was requested. Code: %d; Message: %s", code, version)
|
||||
raise FileNotFoundError("Unable to locate or run ffmpeg or ffprobe. Please install FFmpeg "
|
||||
"and ensure that it is callable via PATH or conf.ffmpeg_path")
|
||||
raise FileNotFoundError(f"Unable to locate or run ffmpeg or ffprobe. Please install FFmpeg "
|
||||
f"and ensure that it is callable via PATH or conf.ffmpeg_path")
|
||||
log.debug("Using %s at %s", version.splitlines()[0].split(" Copyright")[0], self._which_ffmpeg)
|
||||
return version
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from google.protobuf.json_format import MessageToDict
|
||||
|
||||
from lbry.crypto.base58 import Base58
|
||||
from lbry.constants import COIN
|
||||
from lbry.error import MissingPublishedFileError, EmptyPublishedFileError
|
||||
|
||||
from lbry.schema.mime_types import guess_media_type
|
||||
from lbry.schema.base import Metadata, BaseMessageList
|
||||
@@ -140,10 +139,10 @@ class Source(Metadata):
|
||||
self.name = os.path.basename(file_path)
|
||||
self.media_type, stream_type = guess_media_type(file_path)
|
||||
if not os.path.isfile(file_path):
|
||||
raise MissingPublishedFileError(file_path)
|
||||
raise Exception(f"File does not exist: {file_path}")
|
||||
self.size = os.path.getsize(file_path)
|
||||
if self.size == 0:
|
||||
raise EmptyPublishedFileError(file_path)
|
||||
raise Exception(f"Cannot publish empty file: {file_path}")
|
||||
self.file_hash_bytes = calculate_sha384_file_hash(file_path)
|
||||
return stream_type
|
||||
|
||||
|
||||
+49
-75
@@ -1,27 +1,23 @@
|
||||
import base64
|
||||
from typing import List, TYPE_CHECKING, Union, Optional
|
||||
import struct
|
||||
from typing import List
|
||||
from binascii import hexlify
|
||||
from itertools import chain
|
||||
|
||||
from lbry.error import ResolveCensoredError
|
||||
from lbry.schema.types.v2.result_pb2 import Outputs as OutputsMessage
|
||||
from lbry.schema.types.v2.result_pb2 import Error as ErrorMessage
|
||||
if TYPE_CHECKING:
|
||||
from lbry.wallet.server.leveldb import ResolveResult
|
||||
|
||||
INVALID = ErrorMessage.Code.Name(ErrorMessage.INVALID)
|
||||
NOT_FOUND = ErrorMessage.Code.Name(ErrorMessage.NOT_FOUND)
|
||||
BLOCKED = ErrorMessage.Code.Name(ErrorMessage.BLOCKED)
|
||||
|
||||
|
||||
def set_reference(reference, claim_hash, rows):
|
||||
if claim_hash:
|
||||
for txo in rows:
|
||||
if claim_hash == txo.claim_hash:
|
||||
reference.tx_hash = txo.tx_hash
|
||||
reference.nout = txo.position
|
||||
reference.height = txo.height
|
||||
return
|
||||
def set_reference(reference, txo_row):
|
||||
if txo_row:
|
||||
reference.tx_hash = txo_row['txo_hash'][:32]
|
||||
reference.nout = struct.unpack('<I', txo_row['txo_hash'][32:])[0]
|
||||
reference.height = txo_row['height']
|
||||
|
||||
|
||||
class Censor:
|
||||
@@ -42,19 +38,19 @@ class Censor:
|
||||
def apply(self, rows):
|
||||
return [row for row in rows if not self.censor(row)]
|
||||
|
||||
def censor(self, row) -> Optional[bytes]:
|
||||
def censor(self, row) -> bool:
|
||||
if self.is_censored(row):
|
||||
censoring_channel_hash = bytes.fromhex(row['censoring_channel_id'])[::-1]
|
||||
self.censored.setdefault(censoring_channel_hash, set())
|
||||
self.censored[censoring_channel_hash].add(row['tx_hash'])
|
||||
return censoring_channel_hash
|
||||
return None
|
||||
return True
|
||||
return False
|
||||
|
||||
def to_message(self, outputs: OutputsMessage, extra_txo_rows: dict):
|
||||
for censoring_channel_hash, count in self.censored.items():
|
||||
blocked = outputs.blocked.add()
|
||||
blocked.count = len(count)
|
||||
set_reference(blocked.channel, censoring_channel_hash, extra_txo_rows)
|
||||
set_reference(blocked.channel, extra_txo_rows.get(censoring_channel_hash))
|
||||
outputs.blocked_total += len(count)
|
||||
|
||||
|
||||
@@ -119,10 +115,10 @@ class Outputs:
|
||||
'expiration_height': claim.expiration_height,
|
||||
'effective_amount': claim.effective_amount,
|
||||
'support_amount': claim.support_amount,
|
||||
# 'trending_group': claim.trending_group,
|
||||
# 'trending_mixed': claim.trending_mixed,
|
||||
# 'trending_local': claim.trending_local,
|
||||
# 'trending_global': claim.trending_global,
|
||||
'trending_group': claim.trending_group,
|
||||
'trending_mixed': claim.trending_mixed,
|
||||
'trending_local': claim.trending_local,
|
||||
'trending_global': claim.trending_global,
|
||||
}
|
||||
if claim.HasField('channel'):
|
||||
txo.channel = tx_map[claim.channel.tx_hash].outputs[claim.channel.nout]
|
||||
@@ -154,79 +150,57 @@ class Outputs:
|
||||
outputs.blocked, outputs.blocked_total
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_grpc(cls, outputs: OutputsMessage) -> 'Outputs':
|
||||
txs = set()
|
||||
for txo_message in chain(outputs.txos, outputs.extra_txos):
|
||||
if txo_message.WhichOneof('meta') == 'error':
|
||||
continue
|
||||
txs.add((hexlify(txo_message.tx_hash[::-1]).decode(), txo_message.height))
|
||||
return cls(
|
||||
outputs.txos, outputs.extra_txos, txs,
|
||||
outputs.offset, outputs.total,
|
||||
outputs.blocked, outputs.blocked_total
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def to_base64(cls, txo_rows, extra_txo_rows, offset=0, total=None, blocked=None) -> str:
|
||||
return base64.b64encode(cls.to_bytes(txo_rows, extra_txo_rows, offset, total, blocked)).decode()
|
||||
|
||||
@classmethod
|
||||
def to_bytes(cls, txo_rows, extra_txo_rows, offset=0, total=None, blocked: Censor = None) -> bytes:
|
||||
extra_txo_rows = {row['claim_hash']: row for row in extra_txo_rows}
|
||||
page = OutputsMessage()
|
||||
page.offset = offset
|
||||
if total is not None:
|
||||
page.total = total
|
||||
if blocked is not None:
|
||||
blocked.to_message(page, extra_txo_rows)
|
||||
for row in extra_txo_rows:
|
||||
txo_message: 'OutputsMessage' = page.extra_txos.add()
|
||||
if not isinstance(row, Exception):
|
||||
if row.channel_hash:
|
||||
set_reference(txo_message.claim.channel, row.channel_hash, extra_txo_rows)
|
||||
if row.reposted_claim_hash:
|
||||
set_reference(txo_message.claim.repost, row.reposted_claim_hash, extra_txo_rows)
|
||||
cls.encode_txo(txo_message, row)
|
||||
|
||||
for row in txo_rows:
|
||||
# cls.row_to_message(row, page.txos.add(), extra_txo_rows)
|
||||
txo_message: 'OutputsMessage' = page.txos.add()
|
||||
cls.encode_txo(txo_message, row)
|
||||
if not isinstance(row, Exception):
|
||||
if row.channel_hash:
|
||||
set_reference(txo_message.claim.channel, row.channel_hash, extra_txo_rows)
|
||||
if row.reposted_claim_hash:
|
||||
set_reference(txo_message.claim.repost, row.reposted_claim_hash, extra_txo_rows)
|
||||
elif isinstance(row, ResolveCensoredError):
|
||||
set_reference(txo_message.error.blocked.channel, row.censor_id, extra_txo_rows)
|
||||
cls.row_to_message(row, page.txos.add(), extra_txo_rows)
|
||||
for row in extra_txo_rows.values():
|
||||
cls.row_to_message(row, page.extra_txos.add(), extra_txo_rows)
|
||||
return page.SerializeToString()
|
||||
|
||||
@classmethod
|
||||
def encode_txo(cls, txo_message, resolve_result: Union['ResolveResult', Exception]):
|
||||
if isinstance(resolve_result, Exception):
|
||||
txo_message.error.text = resolve_result.args[0]
|
||||
if isinstance(resolve_result, ValueError):
|
||||
def row_to_message(cls, txo, txo_message, extra_row_dict: dict):
|
||||
if isinstance(txo, Exception):
|
||||
txo_message.error.text = txo.args[0]
|
||||
if isinstance(txo, ValueError):
|
||||
txo_message.error.code = ErrorMessage.INVALID
|
||||
elif isinstance(resolve_result, LookupError):
|
||||
elif isinstance(txo, LookupError):
|
||||
txo_message.error.code = ErrorMessage.NOT_FOUND
|
||||
elif isinstance(resolve_result, ResolveCensoredError):
|
||||
elif isinstance(txo, ResolveCensoredError):
|
||||
txo_message.error.code = ErrorMessage.BLOCKED
|
||||
set_reference(txo_message.error.blocked.channel, extra_row_dict.get(bytes.fromhex(txo.censor_id)[::-1]))
|
||||
return
|
||||
txo_message.tx_hash = resolve_result.tx_hash
|
||||
txo_message.nout = resolve_result.position
|
||||
txo_message.height = resolve_result.height
|
||||
txo_message.claim.short_url = resolve_result.short_url
|
||||
txo_message.claim.reposted = resolve_result.reposted
|
||||
txo_message.claim.is_controlling = resolve_result.is_controlling
|
||||
txo_message.claim.creation_height = resolve_result.creation_height
|
||||
txo_message.claim.activation_height = resolve_result.activation_height
|
||||
txo_message.claim.expiration_height = resolve_result.expiration_height
|
||||
txo_message.claim.effective_amount = resolve_result.effective_amount
|
||||
txo_message.claim.support_amount = resolve_result.support_amount
|
||||
|
||||
if resolve_result.canonical_url is not None:
|
||||
txo_message.claim.canonical_url = resolve_result.canonical_url
|
||||
if resolve_result.last_takeover_height is not None:
|
||||
txo_message.claim.take_over_height = resolve_result.last_takeover_height
|
||||
if resolve_result.claims_in_channel is not None:
|
||||
txo_message.claim.claims_in_channel = resolve_result.claims_in_channel
|
||||
txo_message.tx_hash = txo['txo_hash'][:32]
|
||||
txo_message.nout, = struct.unpack('<I', txo['txo_hash'][32:])
|
||||
txo_message.height = txo['height']
|
||||
txo_message.claim.short_url = txo['short_url']
|
||||
txo_message.claim.reposted = txo['reposted']
|
||||
if txo['canonical_url'] is not None:
|
||||
txo_message.claim.canonical_url = txo['canonical_url']
|
||||
txo_message.claim.is_controlling = bool(txo['is_controlling'])
|
||||
if txo['last_take_over_height'] is not None:
|
||||
txo_message.claim.take_over_height = txo['last_take_over_height']
|
||||
txo_message.claim.creation_height = txo['creation_height']
|
||||
txo_message.claim.activation_height = txo['activation_height']
|
||||
txo_message.claim.expiration_height = txo['expiration_height']
|
||||
if txo['claims_in_channel'] is not None:
|
||||
txo_message.claim.claims_in_channel = txo['claims_in_channel']
|
||||
txo_message.claim.effective_amount = txo['effective_amount']
|
||||
txo_message.claim.support_amount = txo['support_amount']
|
||||
txo_message.claim.trending_group = txo['trending_group']
|
||||
txo_message.claim.trending_mixed = txo['trending_mixed']
|
||||
txo_message.claim.trending_local = txo['trending_local']
|
||||
txo_message.claim.trending_global = txo['trending_global']
|
||||
set_reference(txo_message.claim.channel, extra_row_dict.get(txo['channel_hash']))
|
||||
set_reference(txo_message.claim.repost, extra_row_dict.get(txo['reposted_claim_hash']))
|
||||
@@ -1,716 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: hub.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
from . import result_pb2 as result__pb2
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='hub.proto',
|
||||
package='pb',
|
||||
syntax='proto3',
|
||||
serialized_options=b'Z$github.com/lbryio/hub/protobuf/go/pb',
|
||||
create_key=_descriptor._internal_create_key,
|
||||
serialized_pb=b'\n\thub.proto\x12\x02pb\x1a\x0cresult.proto\"0\n\x0fInvertibleField\x12\x0e\n\x06invert\x18\x01 \x01(\x08\x12\r\n\x05value\x18\x02 \x03(\t\"\x1a\n\tBoolValue\x12\r\n\x05value\x18\x01 \x01(\x08\"\x1c\n\x0bUInt32Value\x12\r\n\x05value\x18\x01 \x01(\r\"j\n\nRangeField\x12\x1d\n\x02op\x18\x01 \x01(\x0e\x32\x11.pb.RangeField.Op\x12\r\n\x05value\x18\x02 \x03(\t\".\n\x02Op\x12\x06\n\x02\x45Q\x10\x00\x12\x07\n\x03LTE\x10\x01\x12\x07\n\x03GTE\x10\x02\x12\x06\n\x02LT\x10\x03\x12\x06\n\x02GT\x10\x04\"\xa3\x0c\n\rSearchRequest\x12%\n\x08\x63laim_id\x18\x01 \x01(\x0b\x32\x13.pb.InvertibleField\x12\'\n\nchannel_id\x18\x02 \x01(\x0b\x32\x13.pb.InvertibleField\x12\x0c\n\x04text\x18\x03 \x01(\t\x12\r\n\x05limit\x18\x04 \x01(\r\x12\x10\n\x08order_by\x18\x05 \x03(\t\x12\x0e\n\x06offset\x18\x06 \x01(\r\x12\x16\n\x0eis_controlling\x18\x07 \x01(\x08\x12\x1d\n\x15last_take_over_height\x18\x08 \x01(\t\x12\x12\n\nclaim_name\x18\t \x01(\t\x12\x17\n\x0fnormalized_name\x18\n \x01(\t\x12#\n\x0btx_position\x18\x0b \x01(\x0b\x32\x0e.pb.RangeField\x12\x1e\n\x06\x61mount\x18\x0c \x01(\x0b\x32\x0e.pb.RangeField\x12!\n\ttimestamp\x18\r \x01(\x0b\x32\x0e.pb.RangeField\x12*\n\x12\x63reation_timestamp\x18\x0e \x01(\x0b\x32\x0e.pb.RangeField\x12\x1e\n\x06height\x18\x0f \x01(\x0b\x32\x0e.pb.RangeField\x12\'\n\x0f\x63reation_height\x18\x10 \x01(\x0b\x32\x0e.pb.RangeField\x12)\n\x11\x61\x63tivation_height\x18\x11 \x01(\x0b\x32\x0e.pb.RangeField\x12)\n\x11\x65xpiration_height\x18\x12 \x01(\x0b\x32\x0e.pb.RangeField\x12$\n\x0crelease_time\x18\x13 \x01(\x0b\x32\x0e.pb.RangeField\x12\x11\n\tshort_url\x18\x14 \x01(\t\x12\x15\n\rcanonical_url\x18\x15 \x01(\t\x12\r\n\x05title\x18\x16 \x01(\t\x12\x0e\n\x06\x61uthor\x18\x17 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x18 \x01(\t\x12\x12\n\nclaim_type\x18\x19 \x03(\t\x12$\n\x0crepost_count\x18\x1a \x01(\x0b\x32\x0e.pb.RangeField\x12\x13\n\x0bstream_type\x18\x1b \x03(\t\x12\x12\n\nmedia_type\x18\x1c \x03(\t\x12\"\n\nfee_amount\x18\x1d \x01(\x0b\x32\x0e.pb.RangeField\x12\x14\n\x0c\x66\x65\x65_currency\x18\x1e \x01(\t\x12 \n\x08\x64uration\x18\x1f \x01(\x0b\x32\x0e.pb.RangeField\x12\x19\n\x11reposted_claim_id\x18 \x01(\t\x12#\n\x0b\x63\x65nsor_type\x18! \x01(\x0b\x32\x0e.pb.RangeField\x12\x19\n\x11\x63laims_in_channel\x18\" \x01(\t\x12$\n\x0c\x63hannel_join\x18# \x01(\x0b\x32\x0e.pb.RangeField\x12)\n\x12is_signature_valid\x18$ \x01(\x0b\x32\r.pb.BoolValue\x12(\n\x10\x65\x66\x66\x65\x63tive_amount\x18% \x01(\x0b\x32\x0e.pb.RangeField\x12&\n\x0esupport_amount\x18& \x01(\x0b\x32\x0e.pb.RangeField\x12&\n\x0etrending_score\x18\' \x01(\x0b\x32\x0e.pb.RangeField\x12\r\n\x05tx_id\x18+ \x01(\t\x12 \n\x07tx_nout\x18, \x01(\x0b\x32\x0f.pb.UInt32Value\x12\x11\n\tsignature\x18- \x01(\t\x12\x18\n\x10signature_digest\x18. \x01(\t\x12\x18\n\x10public_key_bytes\x18/ \x01(\t\x12\x15\n\rpublic_key_id\x18\x30 \x01(\t\x12\x10\n\x08\x61ny_tags\x18\x31 \x03(\t\x12\x10\n\x08\x61ll_tags\x18\x32 \x03(\t\x12\x10\n\x08not_tags\x18\x33 \x03(\t\x12\x1d\n\x15has_channel_signature\x18\x34 \x01(\x08\x12!\n\nhas_source\x18\x35 \x01(\x0b\x32\r.pb.BoolValue\x12 \n\x18limit_claims_per_channel\x18\x36 \x01(\r\x12\x15\n\rany_languages\x18\x37 \x03(\t\x12\x15\n\rall_languages\x18\x38 \x03(\t\x12\x19\n\x11remove_duplicates\x18\x39 \x01(\x08\x12\x11\n\tno_totals\x18: \x01(\x08\x32\x31\n\x03Hub\x12*\n\x06Search\x12\x11.pb.SearchRequest\x1a\x0b.pb.Outputs\"\x00\x42&Z$github.com/lbryio/hub/protobuf/go/pbb\x06proto3'
|
||||
,
|
||||
dependencies=[result__pb2.DESCRIPTOR,])
|
||||
|
||||
|
||||
|
||||
_RANGEFIELD_OP = _descriptor.EnumDescriptor(
|
||||
name='Op',
|
||||
full_name='pb.RangeField.Op',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
values=[
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='EQ', index=0, number=0,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='LTE', index=1, number=1,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='GTE', index=2, number=2,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='LT', index=3, number=3,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='GT', index=4, number=4,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
],
|
||||
containing_type=None,
|
||||
serialized_options=None,
|
||||
serialized_start=199,
|
||||
serialized_end=245,
|
||||
)
|
||||
_sym_db.RegisterEnumDescriptor(_RANGEFIELD_OP)
|
||||
|
||||
|
||||
_INVERTIBLEFIELD = _descriptor.Descriptor(
|
||||
name='InvertibleField',
|
||||
full_name='pb.InvertibleField',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='invert', full_name='pb.InvertibleField.invert', index=0,
|
||||
number=1, type=8, cpp_type=7, label=1,
|
||||
has_default_value=False, default_value=False,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='value', full_name='pb.InvertibleField.value', index=1,
|
||||
number=2, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=31,
|
||||
serialized_end=79,
|
||||
)
|
||||
|
||||
|
||||
_BOOLVALUE = _descriptor.Descriptor(
|
||||
name='BoolValue',
|
||||
full_name='pb.BoolValue',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='value', full_name='pb.BoolValue.value', index=0,
|
||||
number=1, type=8, cpp_type=7, label=1,
|
||||
has_default_value=False, default_value=False,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=81,
|
||||
serialized_end=107,
|
||||
)
|
||||
|
||||
|
||||
_UINT32VALUE = _descriptor.Descriptor(
|
||||
name='UInt32Value',
|
||||
full_name='pb.UInt32Value',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='value', full_name='pb.UInt32Value.value', index=0,
|
||||
number=1, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=109,
|
||||
serialized_end=137,
|
||||
)
|
||||
|
||||
|
||||
_RANGEFIELD = _descriptor.Descriptor(
|
||||
name='RangeField',
|
||||
full_name='pb.RangeField',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='op', full_name='pb.RangeField.op', index=0,
|
||||
number=1, type=14, cpp_type=8, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='value', full_name='pb.RangeField.value', index=1,
|
||||
number=2, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
_RANGEFIELD_OP,
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=139,
|
||||
serialized_end=245,
|
||||
)
|
||||
|
||||
|
||||
_SEARCHREQUEST = _descriptor.Descriptor(
|
||||
name='SearchRequest',
|
||||
full_name='pb.SearchRequest',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='claim_id', full_name='pb.SearchRequest.claim_id', index=0,
|
||||
number=1, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='channel_id', full_name='pb.SearchRequest.channel_id', index=1,
|
||||
number=2, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='text', full_name='pb.SearchRequest.text', index=2,
|
||||
number=3, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='limit', full_name='pb.SearchRequest.limit', index=3,
|
||||
number=4, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='order_by', full_name='pb.SearchRequest.order_by', index=4,
|
||||
number=5, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='offset', full_name='pb.SearchRequest.offset', index=5,
|
||||
number=6, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='is_controlling', full_name='pb.SearchRequest.is_controlling', index=6,
|
||||
number=7, type=8, cpp_type=7, label=1,
|
||||
has_default_value=False, default_value=False,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='last_take_over_height', full_name='pb.SearchRequest.last_take_over_height', index=7,
|
||||
number=8, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='claim_name', full_name='pb.SearchRequest.claim_name', index=8,
|
||||
number=9, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='normalized_name', full_name='pb.SearchRequest.normalized_name', index=9,
|
||||
number=10, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='tx_position', full_name='pb.SearchRequest.tx_position', index=10,
|
||||
number=11, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='amount', full_name='pb.SearchRequest.amount', index=11,
|
||||
number=12, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='timestamp', full_name='pb.SearchRequest.timestamp', index=12,
|
||||
number=13, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='creation_timestamp', full_name='pb.SearchRequest.creation_timestamp', index=13,
|
||||
number=14, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='height', full_name='pb.SearchRequest.height', index=14,
|
||||
number=15, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='creation_height', full_name='pb.SearchRequest.creation_height', index=15,
|
||||
number=16, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='activation_height', full_name='pb.SearchRequest.activation_height', index=16,
|
||||
number=17, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='expiration_height', full_name='pb.SearchRequest.expiration_height', index=17,
|
||||
number=18, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='release_time', full_name='pb.SearchRequest.release_time', index=18,
|
||||
number=19, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='short_url', full_name='pb.SearchRequest.short_url', index=19,
|
||||
number=20, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='canonical_url', full_name='pb.SearchRequest.canonical_url', index=20,
|
||||
number=21, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='title', full_name='pb.SearchRequest.title', index=21,
|
||||
number=22, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='author', full_name='pb.SearchRequest.author', index=22,
|
||||
number=23, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='description', full_name='pb.SearchRequest.description', index=23,
|
||||
number=24, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='claim_type', full_name='pb.SearchRequest.claim_type', index=24,
|
||||
number=25, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='repost_count', full_name='pb.SearchRequest.repost_count', index=25,
|
||||
number=26, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='stream_type', full_name='pb.SearchRequest.stream_type', index=26,
|
||||
number=27, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='media_type', full_name='pb.SearchRequest.media_type', index=27,
|
||||
number=28, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='fee_amount', full_name='pb.SearchRequest.fee_amount', index=28,
|
||||
number=29, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='fee_currency', full_name='pb.SearchRequest.fee_currency', index=29,
|
||||
number=30, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='duration', full_name='pb.SearchRequest.duration', index=30,
|
||||
number=31, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='reposted_claim_id', full_name='pb.SearchRequest.reposted_claim_id', index=31,
|
||||
number=32, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='censor_type', full_name='pb.SearchRequest.censor_type', index=32,
|
||||
number=33, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='claims_in_channel', full_name='pb.SearchRequest.claims_in_channel', index=33,
|
||||
number=34, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='channel_join', full_name='pb.SearchRequest.channel_join', index=34,
|
||||
number=35, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='is_signature_valid', full_name='pb.SearchRequest.is_signature_valid', index=35,
|
||||
number=36, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='effective_amount', full_name='pb.SearchRequest.effective_amount', index=36,
|
||||
number=37, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='support_amount', full_name='pb.SearchRequest.support_amount', index=37,
|
||||
number=38, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='trending_score', full_name='pb.SearchRequest.trending_score', index=38,
|
||||
number=39, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='tx_id', full_name='pb.SearchRequest.tx_id', index=39,
|
||||
number=43, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='tx_nout', full_name='pb.SearchRequest.tx_nout', index=40,
|
||||
number=44, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='signature', full_name='pb.SearchRequest.signature', index=41,
|
||||
number=45, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='signature_digest', full_name='pb.SearchRequest.signature_digest', index=42,
|
||||
number=46, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='public_key_bytes', full_name='pb.SearchRequest.public_key_bytes', index=43,
|
||||
number=47, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='public_key_id', full_name='pb.SearchRequest.public_key_id', index=44,
|
||||
number=48, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='any_tags', full_name='pb.SearchRequest.any_tags', index=45,
|
||||
number=49, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='all_tags', full_name='pb.SearchRequest.all_tags', index=46,
|
||||
number=50, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='not_tags', full_name='pb.SearchRequest.not_tags', index=47,
|
||||
number=51, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='has_channel_signature', full_name='pb.SearchRequest.has_channel_signature', index=48,
|
||||
number=52, type=8, cpp_type=7, label=1,
|
||||
has_default_value=False, default_value=False,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='has_source', full_name='pb.SearchRequest.has_source', index=49,
|
||||
number=53, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='limit_claims_per_channel', full_name='pb.SearchRequest.limit_claims_per_channel', index=50,
|
||||
number=54, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='any_languages', full_name='pb.SearchRequest.any_languages', index=51,
|
||||
number=55, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='all_languages', full_name='pb.SearchRequest.all_languages', index=52,
|
||||
number=56, type=9, cpp_type=9, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='remove_duplicates', full_name='pb.SearchRequest.remove_duplicates', index=53,
|
||||
number=57, type=8, cpp_type=7, label=1,
|
||||
has_default_value=False, default_value=False,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='no_totals', full_name='pb.SearchRequest.no_totals', index=54,
|
||||
number=58, type=8, cpp_type=7, label=1,
|
||||
has_default_value=False, default_value=False,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=248,
|
||||
serialized_end=1819,
|
||||
)
|
||||
|
||||
_RANGEFIELD.fields_by_name['op'].enum_type = _RANGEFIELD_OP
|
||||
_RANGEFIELD_OP.containing_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['claim_id'].message_type = _INVERTIBLEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['channel_id'].message_type = _INVERTIBLEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['tx_position'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['amount'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['timestamp'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['creation_timestamp'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['height'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['creation_height'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['activation_height'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['expiration_height'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['release_time'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['repost_count'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['fee_amount'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['duration'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['censor_type'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['channel_join'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['is_signature_valid'].message_type = _BOOLVALUE
|
||||
_SEARCHREQUEST.fields_by_name['effective_amount'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['support_amount'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['trending_score'].message_type = _RANGEFIELD
|
||||
_SEARCHREQUEST.fields_by_name['tx_nout'].message_type = _UINT32VALUE
|
||||
_SEARCHREQUEST.fields_by_name['has_source'].message_type = _BOOLVALUE
|
||||
DESCRIPTOR.message_types_by_name['InvertibleField'] = _INVERTIBLEFIELD
|
||||
DESCRIPTOR.message_types_by_name['BoolValue'] = _BOOLVALUE
|
||||
DESCRIPTOR.message_types_by_name['UInt32Value'] = _UINT32VALUE
|
||||
DESCRIPTOR.message_types_by_name['RangeField'] = _RANGEFIELD
|
||||
DESCRIPTOR.message_types_by_name['SearchRequest'] = _SEARCHREQUEST
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
InvertibleField = _reflection.GeneratedProtocolMessageType('InvertibleField', (_message.Message,), {
|
||||
'DESCRIPTOR' : _INVERTIBLEFIELD,
|
||||
'__module__' : 'hub_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.InvertibleField)
|
||||
})
|
||||
_sym_db.RegisterMessage(InvertibleField)
|
||||
|
||||
BoolValue = _reflection.GeneratedProtocolMessageType('BoolValue', (_message.Message,), {
|
||||
'DESCRIPTOR' : _BOOLVALUE,
|
||||
'__module__' : 'hub_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.BoolValue)
|
||||
})
|
||||
_sym_db.RegisterMessage(BoolValue)
|
||||
|
||||
UInt32Value = _reflection.GeneratedProtocolMessageType('UInt32Value', (_message.Message,), {
|
||||
'DESCRIPTOR' : _UINT32VALUE,
|
||||
'__module__' : 'hub_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.UInt32Value)
|
||||
})
|
||||
_sym_db.RegisterMessage(UInt32Value)
|
||||
|
||||
RangeField = _reflection.GeneratedProtocolMessageType('RangeField', (_message.Message,), {
|
||||
'DESCRIPTOR' : _RANGEFIELD,
|
||||
'__module__' : 'hub_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.RangeField)
|
||||
})
|
||||
_sym_db.RegisterMessage(RangeField)
|
||||
|
||||
SearchRequest = _reflection.GeneratedProtocolMessageType('SearchRequest', (_message.Message,), {
|
||||
'DESCRIPTOR' : _SEARCHREQUEST,
|
||||
'__module__' : 'hub_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.SearchRequest)
|
||||
})
|
||||
_sym_db.RegisterMessage(SearchRequest)
|
||||
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
|
||||
_HUB = _descriptor.ServiceDescriptor(
|
||||
name='Hub',
|
||||
full_name='pb.Hub',
|
||||
file=DESCRIPTOR,
|
||||
index=0,
|
||||
serialized_options=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
serialized_start=1821,
|
||||
serialized_end=1870,
|
||||
methods=[
|
||||
_descriptor.MethodDescriptor(
|
||||
name='Search',
|
||||
full_name='pb.Hub.Search',
|
||||
index=0,
|
||||
containing_service=None,
|
||||
input_type=_SEARCHREQUEST,
|
||||
output_type=result__pb2._OUTPUTS,
|
||||
serialized_options=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
),
|
||||
])
|
||||
_sym_db.RegisterServiceDescriptor(_HUB)
|
||||
|
||||
DESCRIPTOR.services_by_name['Hub'] = _HUB
|
||||
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
@@ -1,67 +0,0 @@
|
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
||||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
|
||||
from . import hub_pb2 as hub__pb2
|
||||
from . import result_pb2 as result__pb2
|
||||
|
||||
|
||||
class HubStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.Search = channel.unary_unary(
|
||||
'/pb.Hub/Search',
|
||||
request_serializer=hub__pb2.SearchRequest.SerializeToString,
|
||||
response_deserializer=result__pb2.Outputs.FromString,
|
||||
)
|
||||
|
||||
|
||||
class HubServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def Search(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_HubServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'Search': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Search,
|
||||
request_deserializer=hub__pb2.SearchRequest.FromString,
|
||||
response_serializer=result__pb2.Outputs.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'pb.Hub', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class Hub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def Search(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/pb.Hub/Search',
|
||||
hub__pb2.SearchRequest.SerializeToString,
|
||||
result__pb2.Outputs.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
@@ -1,11 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: result.proto
|
||||
"""Generated protocol buffer code."""
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
@@ -17,10 +19,9 @@ DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='result.proto',
|
||||
package='pb',
|
||||
syntax='proto3',
|
||||
serialized_options=b'Z$github.com/lbryio/hub/protobuf/go/pb',
|
||||
create_key=_descriptor._internal_create_key,
|
||||
serialized_pb=b'\n\x0cresult.proto\x12\x02pb\"\x97\x01\n\x07Outputs\x12\x18\n\x04txos\x18\x01 \x03(\x0b\x32\n.pb.Output\x12\x1e\n\nextra_txos\x18\x02 \x03(\x0b\x32\n.pb.Output\x12\r\n\x05total\x18\x03 \x01(\r\x12\x0e\n\x06offset\x18\x04 \x01(\r\x12\x1c\n\x07\x62locked\x18\x05 \x03(\x0b\x32\x0b.pb.Blocked\x12\x15\n\rblocked_total\x18\x06 \x01(\r\"{\n\x06Output\x12\x0f\n\x07tx_hash\x18\x01 \x01(\x0c\x12\x0c\n\x04nout\x18\x02 \x01(\r\x12\x0e\n\x06height\x18\x03 \x01(\r\x12\x1e\n\x05\x63laim\x18\x07 \x01(\x0b\x32\r.pb.ClaimMetaH\x00\x12\x1a\n\x05\x65rror\x18\x0f \x01(\x0b\x32\t.pb.ErrorH\x00\x42\x06\n\x04meta\"\xe6\x02\n\tClaimMeta\x12\x1b\n\x07\x63hannel\x18\x01 \x01(\x0b\x32\n.pb.Output\x12\x1a\n\x06repost\x18\x02 \x01(\x0b\x32\n.pb.Output\x12\x11\n\tshort_url\x18\x03 \x01(\t\x12\x15\n\rcanonical_url\x18\x04 \x01(\t\x12\x16\n\x0eis_controlling\x18\x05 \x01(\x08\x12\x18\n\x10take_over_height\x18\x06 \x01(\r\x12\x17\n\x0f\x63reation_height\x18\x07 \x01(\r\x12\x19\n\x11\x61\x63tivation_height\x18\x08 \x01(\r\x12\x19\n\x11\x65xpiration_height\x18\t \x01(\r\x12\x19\n\x11\x63laims_in_channel\x18\n \x01(\r\x12\x10\n\x08reposted\x18\x0b \x01(\r\x12\x18\n\x10\x65\x66\x66\x65\x63tive_amount\x18\x14 \x01(\x04\x12\x16\n\x0esupport_amount\x18\x15 \x01(\x04\x12\x16\n\x0etrending_score\x18\x16 \x01(\x01\"\x94\x01\n\x05\x45rror\x12\x1c\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x0e.pb.Error.Code\x12\x0c\n\x04text\x18\x02 \x01(\t\x12\x1c\n\x07\x62locked\x18\x03 \x01(\x0b\x32\x0b.pb.Blocked\"A\n\x04\x43ode\x12\x10\n\x0cUNKNOWN_CODE\x10\x00\x12\r\n\tNOT_FOUND\x10\x01\x12\x0b\n\x07INVALID\x10\x02\x12\x0b\n\x07\x42LOCKED\x10\x03\"5\n\x07\x42locked\x12\r\n\x05\x63ount\x18\x01 \x01(\r\x12\x1b\n\x07\x63hannel\x18\x02 \x01(\x0b\x32\n.pb.OutputB&Z$github.com/lbryio/hub/protobuf/go/pbb\x06proto3'
|
||||
serialized_pb=_b('\n\x0cresult.proto\x12\x02pb\"\x97\x01\n\x07Outputs\x12\x18\n\x04txos\x18\x01 \x03(\x0b\x32\n.pb.Output\x12\x1e\n\nextra_txos\x18\x02 \x03(\x0b\x32\n.pb.Output\x12\r\n\x05total\x18\x03 \x01(\r\x12\x0e\n\x06offset\x18\x04 \x01(\r\x12\x1c\n\x07\x62locked\x18\x05 \x03(\x0b\x32\x0b.pb.Blocked\x12\x15\n\rblocked_total\x18\x06 \x01(\r\"{\n\x06Output\x12\x0f\n\x07tx_hash\x18\x01 \x01(\x0c\x12\x0c\n\x04nout\x18\x02 \x01(\r\x12\x0e\n\x06height\x18\x03 \x01(\r\x12\x1e\n\x05\x63laim\x18\x07 \x01(\x0b\x32\r.pb.ClaimMetaH\x00\x12\x1a\n\x05\x65rror\x18\x0f \x01(\x0b\x32\t.pb.ErrorH\x00\x42\x06\n\x04meta\"\xaf\x03\n\tClaimMeta\x12\x1b\n\x07\x63hannel\x18\x01 \x01(\x0b\x32\n.pb.Output\x12\x1a\n\x06repost\x18\x02 \x01(\x0b\x32\n.pb.Output\x12\x11\n\tshort_url\x18\x03 \x01(\t\x12\x15\n\rcanonical_url\x18\x04 \x01(\t\x12\x16\n\x0eis_controlling\x18\x05 \x01(\x08\x12\x18\n\x10take_over_height\x18\x06 \x01(\r\x12\x17\n\x0f\x63reation_height\x18\x07 \x01(\r\x12\x19\n\x11\x61\x63tivation_height\x18\x08 \x01(\r\x12\x19\n\x11\x65xpiration_height\x18\t \x01(\r\x12\x19\n\x11\x63laims_in_channel\x18\n \x01(\r\x12\x10\n\x08reposted\x18\x0b \x01(\r\x12\x18\n\x10\x65\x66\x66\x65\x63tive_amount\x18\x14 \x01(\x04\x12\x16\n\x0esupport_amount\x18\x15 \x01(\x04\x12\x16\n\x0etrending_group\x18\x16 \x01(\r\x12\x16\n\x0etrending_mixed\x18\x17 \x01(\x02\x12\x16\n\x0etrending_local\x18\x18 \x01(\x02\x12\x17\n\x0ftrending_global\x18\x19 \x01(\x02\"\x94\x01\n\x05\x45rror\x12\x1c\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x0e.pb.Error.Code\x12\x0c\n\x04text\x18\x02 \x01(\t\x12\x1c\n\x07\x62locked\x18\x03 \x01(\x0b\x32\x0b.pb.Blocked\"A\n\x04\x43ode\x12\x10\n\x0cUNKNOWN_CODE\x10\x00\x12\r\n\tNOT_FOUND\x10\x01\x12\x0b\n\x07INVALID\x10\x02\x12\x0b\n\x07\x42LOCKED\x10\x03\"5\n\x07\x42locked\x12\r\n\x05\x63ount\x18\x01 \x01(\r\x12\x1b\n\x07\x63hannel\x18\x02 \x01(\x0b\x32\n.pb.Outputb\x06proto3')
|
||||
)
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
|
||||
|
||||
@@ -29,33 +30,28 @@ _ERROR_CODE = _descriptor.EnumDescriptor(
|
||||
full_name='pb.Error.Code',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
values=[
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='UNKNOWN_CODE', index=0, number=0,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
options=None,
|
||||
type=None),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='NOT_FOUND', index=1, number=1,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
options=None,
|
||||
type=None),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='INVALID', index=2, number=2,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
options=None,
|
||||
type=None),
|
||||
_descriptor.EnumValueDescriptor(
|
||||
name='BLOCKED', index=3, number=3,
|
||||
serialized_options=None,
|
||||
type=None,
|
||||
create_key=_descriptor._internal_create_key),
|
||||
options=None,
|
||||
type=None),
|
||||
],
|
||||
containing_type=None,
|
||||
serialized_options=None,
|
||||
serialized_start=744,
|
||||
serialized_end=809,
|
||||
options=None,
|
||||
serialized_start=817,
|
||||
serialized_end=882,
|
||||
)
|
||||
_sym_db.RegisterEnumDescriptor(_ERROR_CODE)
|
||||
|
||||
@@ -66,7 +62,6 @@ _OUTPUTS = _descriptor.Descriptor(
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='txos', full_name='pb.Outputs.txos', index=0,
|
||||
@@ -74,49 +69,49 @@ _OUTPUTS = _descriptor.Descriptor(
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='extra_txos', full_name='pb.Outputs.extra_txos', index=1,
|
||||
number=2, type=11, cpp_type=10, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='total', full_name='pb.Outputs.total', index=2,
|
||||
number=3, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='offset', full_name='pb.Outputs.offset', index=3,
|
||||
number=4, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='blocked', full_name='pb.Outputs.blocked', index=4,
|
||||
number=5, type=11, cpp_type=10, label=3,
|
||||
has_default_value=False, default_value=[],
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='blocked_total', full_name='pb.Outputs.blocked_total', index=5,
|
||||
number=6, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
@@ -133,59 +128,56 @@ _OUTPUT = _descriptor.Descriptor(
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='tx_hash', full_name='pb.Output.tx_hash', index=0,
|
||||
number=1, type=12, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"",
|
||||
has_default_value=False, default_value=_b(""),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='nout', full_name='pb.Output.nout', index=1,
|
||||
number=2, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='height', full_name='pb.Output.height', index=2,
|
||||
number=3, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='claim', full_name='pb.Output.claim', index=3,
|
||||
number=7, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='error', full_name='pb.Output.error', index=4,
|
||||
number=15, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
_descriptor.OneofDescriptor(
|
||||
name='meta', full_name='pb.Output.meta',
|
||||
index=0, containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[]),
|
||||
index=0, containing_type=None, fields=[]),
|
||||
],
|
||||
serialized_start=174,
|
||||
serialized_end=297,
|
||||
@@ -198,7 +190,6 @@ _CLAIMMETA = _descriptor.Descriptor(
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='channel', full_name='pb.ClaimMeta.channel', index=0,
|
||||
@@ -206,112 +197,133 @@ _CLAIMMETA = _descriptor.Descriptor(
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='repost', full_name='pb.ClaimMeta.repost', index=1,
|
||||
number=2, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='short_url', full_name='pb.ClaimMeta.short_url', index=2,
|
||||
number=3, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='canonical_url', full_name='pb.ClaimMeta.canonical_url', index=3,
|
||||
number=4, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='is_controlling', full_name='pb.ClaimMeta.is_controlling', index=4,
|
||||
number=5, type=8, cpp_type=7, label=1,
|
||||
has_default_value=False, default_value=False,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='take_over_height', full_name='pb.ClaimMeta.take_over_height', index=5,
|
||||
number=6, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='creation_height', full_name='pb.ClaimMeta.creation_height', index=6,
|
||||
number=7, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='activation_height', full_name='pb.ClaimMeta.activation_height', index=7,
|
||||
number=8, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='expiration_height', full_name='pb.ClaimMeta.expiration_height', index=8,
|
||||
number=9, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='claims_in_channel', full_name='pb.ClaimMeta.claims_in_channel', index=9,
|
||||
number=10, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='reposted', full_name='pb.ClaimMeta.reposted', index=10,
|
||||
number=11, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='effective_amount', full_name='pb.ClaimMeta.effective_amount', index=11,
|
||||
number=20, type=4, cpp_type=4, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='support_amount', full_name='pb.ClaimMeta.support_amount', index=12,
|
||||
number=21, type=4, cpp_type=4, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='trending_score', full_name='pb.ClaimMeta.trending_score', index=13,
|
||||
number=22, type=1, cpp_type=5, label=1,
|
||||
name='trending_group', full_name='pb.ClaimMeta.trending_group', index=13,
|
||||
number=22, type=13, cpp_type=3, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='trending_mixed', full_name='pb.ClaimMeta.trending_mixed', index=14,
|
||||
number=23, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='trending_local', full_name='pb.ClaimMeta.trending_local', index=15,
|
||||
number=24, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='trending_global', full_name='pb.ClaimMeta.trending_global', index=16,
|
||||
number=25, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=300,
|
||||
serialized_end=658,
|
||||
serialized_end=731,
|
||||
)
|
||||
|
||||
|
||||
@@ -321,7 +333,6 @@ _ERROR = _descriptor.Descriptor(
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='code', full_name='pb.Error.code', index=0,
|
||||
@@ -329,21 +340,21 @@ _ERROR = _descriptor.Descriptor(
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='text', full_name='pb.Error.text', index=1,
|
||||
number=2, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=b"".decode('utf-8'),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='blocked', full_name='pb.Error.blocked', index=2,
|
||||
number=3, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
@@ -351,14 +362,14 @@ _ERROR = _descriptor.Descriptor(
|
||||
enum_types=[
|
||||
_ERROR_CODE,
|
||||
],
|
||||
serialized_options=None,
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=661,
|
||||
serialized_end=809,
|
||||
serialized_start=734,
|
||||
serialized_end=882,
|
||||
)
|
||||
|
||||
|
||||
@@ -368,7 +379,6 @@ _BLOCKED = _descriptor.Descriptor(
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
create_key=_descriptor._internal_create_key,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='count', full_name='pb.Blocked.count', index=0,
|
||||
@@ -376,28 +386,28 @@ _BLOCKED = _descriptor.Descriptor(
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='channel', full_name='pb.Blocked.channel', index=1,
|
||||
number=2, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
serialized_options=None,
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=811,
|
||||
serialized_end=864,
|
||||
serialized_start=884,
|
||||
serialized_end=937,
|
||||
)
|
||||
|
||||
_OUTPUTS.fields_by_name['txos'].message_type = _OUTPUT
|
||||
@@ -422,43 +432,41 @@ DESCRIPTOR.message_types_by_name['Output'] = _OUTPUT
|
||||
DESCRIPTOR.message_types_by_name['ClaimMeta'] = _CLAIMMETA
|
||||
DESCRIPTOR.message_types_by_name['Error'] = _ERROR
|
||||
DESCRIPTOR.message_types_by_name['Blocked'] = _BLOCKED
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
Outputs = _reflection.GeneratedProtocolMessageType('Outputs', (_message.Message,), {
|
||||
'DESCRIPTOR' : _OUTPUTS,
|
||||
'__module__' : 'result_pb2'
|
||||
Outputs = _reflection.GeneratedProtocolMessageType('Outputs', (_message.Message,), dict(
|
||||
DESCRIPTOR = _OUTPUTS,
|
||||
__module__ = 'result_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.Outputs)
|
||||
})
|
||||
))
|
||||
_sym_db.RegisterMessage(Outputs)
|
||||
|
||||
Output = _reflection.GeneratedProtocolMessageType('Output', (_message.Message,), {
|
||||
'DESCRIPTOR' : _OUTPUT,
|
||||
'__module__' : 'result_pb2'
|
||||
Output = _reflection.GeneratedProtocolMessageType('Output', (_message.Message,), dict(
|
||||
DESCRIPTOR = _OUTPUT,
|
||||
__module__ = 'result_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.Output)
|
||||
})
|
||||
))
|
||||
_sym_db.RegisterMessage(Output)
|
||||
|
||||
ClaimMeta = _reflection.GeneratedProtocolMessageType('ClaimMeta', (_message.Message,), {
|
||||
'DESCRIPTOR' : _CLAIMMETA,
|
||||
'__module__' : 'result_pb2'
|
||||
ClaimMeta = _reflection.GeneratedProtocolMessageType('ClaimMeta', (_message.Message,), dict(
|
||||
DESCRIPTOR = _CLAIMMETA,
|
||||
__module__ = 'result_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.ClaimMeta)
|
||||
})
|
||||
))
|
||||
_sym_db.RegisterMessage(ClaimMeta)
|
||||
|
||||
Error = _reflection.GeneratedProtocolMessageType('Error', (_message.Message,), {
|
||||
'DESCRIPTOR' : _ERROR,
|
||||
'__module__' : 'result_pb2'
|
||||
Error = _reflection.GeneratedProtocolMessageType('Error', (_message.Message,), dict(
|
||||
DESCRIPTOR = _ERROR,
|
||||
__module__ = 'result_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.Error)
|
||||
})
|
||||
))
|
||||
_sym_db.RegisterMessage(Error)
|
||||
|
||||
Blocked = _reflection.GeneratedProtocolMessageType('Blocked', (_message.Message,), {
|
||||
'DESCRIPTOR' : _BLOCKED,
|
||||
'__module__' : 'result_pb2'
|
||||
Blocked = _reflection.GeneratedProtocolMessageType('Blocked', (_message.Message,), dict(
|
||||
DESCRIPTOR = _BLOCKED,
|
||||
__module__ = 'result_pb2'
|
||||
# @@protoc_insertion_point(class_scope:pb.Blocked)
|
||||
})
|
||||
))
|
||||
_sym_db.RegisterMessage(Blocked)
|
||||
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
@@ -1,4 +0,0 @@
|
||||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
||||
"""Client and server classes corresponding to protobuf-defined services."""
|
||||
import grpc
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from lbry.stream.downloader import StreamDownloader
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BackgroundDownloader:
|
||||
def __init__(self, conf, storage, blob_manager, dht_node=None):
|
||||
self.storage = storage
|
||||
self.blob_manager = blob_manager
|
||||
self.node = dht_node
|
||||
self.conf = conf
|
||||
|
||||
async def download_blobs(self, sd_hash):
|
||||
downloader = StreamDownloader(asyncio.get_running_loop(), self.conf, self.blob_manager, sd_hash)
|
||||
try:
|
||||
await downloader.start(self.node, save_stream=False)
|
||||
for blob_info in downloader.descriptor.blobs[:-1]:
|
||||
await downloader.download_stream_blob(blob_info)
|
||||
except ValueError:
|
||||
return
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception:
|
||||
log.error("Unexpected download error on background downloader")
|
||||
finally:
|
||||
downloader.stop()
|
||||
@@ -4,7 +4,6 @@ import binascii
|
||||
import logging
|
||||
import typing
|
||||
import asyncio
|
||||
import time
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
from cryptography.hazmat.primitives.ciphers.algorithms import AES
|
||||
@@ -153,19 +152,15 @@ class StreamDescriptor:
|
||||
h.update(self.old_sort_json())
|
||||
return h.hexdigest()
|
||||
|
||||
async def make_sd_blob(
|
||||
self, blob_file_obj: typing.Optional[AbstractBlob] = None, old_sort: typing.Optional[bool] = False,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], None]] = None,
|
||||
added_on: float = None, is_mine: bool = False
|
||||
):
|
||||
async def make_sd_blob(self, blob_file_obj: typing.Optional[AbstractBlob] = None,
|
||||
old_sort: typing.Optional[bool] = False,
|
||||
blob_completed_callback: typing.Optional[typing.Callable[['AbstractBlob'], None]] = None):
|
||||
sd_hash = self.calculate_sd_hash() if not old_sort else self.calculate_old_sort_sd_hash()
|
||||
if not old_sort:
|
||||
sd_data = self.as_json()
|
||||
else:
|
||||
sd_data = self.old_sort_json()
|
||||
sd_blob = blob_file_obj or BlobFile(
|
||||
self.loop, sd_hash, len(sd_data), blob_completed_callback, self.blob_dir, added_on, is_mine
|
||||
)
|
||||
sd_blob = blob_file_obj or BlobFile(self.loop, sd_hash, len(sd_data), blob_completed_callback, self.blob_dir)
|
||||
if blob_file_obj:
|
||||
blob_file_obj.set_length(len(sd_data))
|
||||
if not sd_blob.get_is_verified():
|
||||
@@ -257,25 +252,20 @@ class StreamDescriptor:
|
||||
iv_generator = iv_generator or random_iv_generator()
|
||||
key = key or os.urandom(AES.block_size // 8)
|
||||
blob_num = -1
|
||||
added_on = time.time()
|
||||
async for blob_bytes in file_reader(file_path):
|
||||
blob_num += 1
|
||||
blob_info = await BlobFile.create_from_unencrypted(
|
||||
loop, blob_dir, key, next(iv_generator), blob_bytes, blob_num, added_on, True, blob_completed_callback
|
||||
loop, blob_dir, key, next(iv_generator), blob_bytes, blob_num, blob_completed_callback
|
||||
)
|
||||
blobs.append(blob_info)
|
||||
blobs.append(
|
||||
# add the stream terminator
|
||||
BlobInfo(len(blobs), 0, binascii.hexlify(next(iv_generator)).decode(), None, added_on, True)
|
||||
)
|
||||
BlobInfo(len(blobs), 0, binascii.hexlify(next(iv_generator)).decode())) # add the stream terminator
|
||||
file_name = os.path.basename(file_path)
|
||||
suggested_file_name = sanitize_file_name(file_name)
|
||||
descriptor = cls(
|
||||
loop, blob_dir, file_name, binascii.hexlify(key).decode(), suggested_file_name, blobs
|
||||
)
|
||||
sd_blob = await descriptor.make_sd_blob(
|
||||
old_sort=old_sort, blob_completed_callback=blob_completed_callback, added_on=added_on, is_mine=True
|
||||
)
|
||||
sd_blob = await descriptor.make_sd_blob(old_sort=old_sort, blob_completed_callback=blob_completed_callback)
|
||||
descriptor.sd_hash = sd_blob.blob_hash
|
||||
return descriptor
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import typing
|
||||
import logging
|
||||
import binascii
|
||||
|
||||
from lbry.dht.node import get_kademlia_peers_from_hosts
|
||||
from lbry.dht.peer import make_kademlia_peer
|
||||
from lbry.error import DownloadSDTimeoutError
|
||||
from lbry.utils import lru_cache_concurrent
|
||||
from lbry.utils import resolve_host, lru_cache_concurrent
|
||||
from lbry.stream.descriptor import StreamDescriptor
|
||||
from lbry.blob_exchange.downloader import BlobDownloader
|
||||
if typing.TYPE_CHECKING:
|
||||
@@ -48,19 +48,26 @@ class StreamDownloader:
|
||||
self.cached_read_blob = cached_read_blob
|
||||
|
||||
async def add_fixed_peers(self):
|
||||
def _add_fixed_peers(fixed_peers):
|
||||
self.peer_queue.put_nowait(fixed_peers)
|
||||
def _delayed_add_fixed_peers():
|
||||
self.added_fixed_peers = True
|
||||
self.peer_queue.put_nowait([
|
||||
make_kademlia_peer(None, address, None, tcp_port=port, allow_localhost=True)
|
||||
for address, port in addresses
|
||||
])
|
||||
|
||||
if not self.config.fixed_peers:
|
||||
return
|
||||
addresses = [
|
||||
(await resolve_host(url, port, proto='tcp'), port)
|
||||
for url, port in self.config.fixed_peers
|
||||
]
|
||||
if 'dht' in self.config.components_to_skip or not self.node or not \
|
||||
len(self.node.protocol.routing_table.get_peers()) > 0:
|
||||
self.fixed_peers_delay = 0.0
|
||||
else:
|
||||
self.fixed_peers_delay = self.config.fixed_peer_delay
|
||||
fixed_peers = await get_kademlia_peers_from_hosts(self.config.fixed_peers)
|
||||
self.fixed_peers_handle = self.loop.call_later(self.fixed_peers_delay, _add_fixed_peers, fixed_peers)
|
||||
|
||||
self.fixed_peers_handle = self.loop.call_later(self.fixed_peers_delay, _delayed_add_fixed_peers)
|
||||
|
||||
async def load_descriptor(self, connection_id: int = 0):
|
||||
# download or get the sd blob
|
||||
@@ -83,7 +90,7 @@ class StreamDownloader:
|
||||
)
|
||||
log.info("loaded stream manifest %s", self.sd_hash)
|
||||
|
||||
async def start(self, node: typing.Optional['Node'] = None, connection_id: int = 0, save_stream=True):
|
||||
async def start(self, node: typing.Optional['Node'] = None, connection_id: int = 0):
|
||||
# set up peer accumulation
|
||||
self.node = node or self.node # fixme: this shouldnt be set here!
|
||||
if self.node:
|
||||
@@ -102,7 +109,7 @@ class StreamDownloader:
|
||||
self.search_queue.put_nowait(self.descriptor.blobs[0].blob_hash)
|
||||
log.info("added head blob to peer search for stream %s", self.sd_hash)
|
||||
|
||||
if not await self.blob_manager.storage.stream_exists(self.sd_hash) and save_stream:
|
||||
if not await self.blob_manager.storage.stream_exists(self.sd_hash):
|
||||
await self.blob_manager.storage.store_stream(
|
||||
self.blob_manager.get_blob(self.sd_hash, length=self.descriptor.length), self.descriptor
|
||||
)
|
||||
|
||||
@@ -254,7 +254,7 @@ class ManagedStream(ManagedDownloadSource):
|
||||
self.finished_writing.clear()
|
||||
self.started_writing.clear()
|
||||
try:
|
||||
open(output_path, 'wb').close() # pylint: disable=consider-using-with
|
||||
open(output_path, 'wb').close()
|
||||
async for blob_info, decrypted in self._aiter_read_stream(connection_id=self.SAVING_ID):
|
||||
log.info("write blob %i/%i", blob_info.blob_num + 1, len(self.descriptor.blobs) - 1)
|
||||
await self.loop.run_in_executor(None, self._write_decrypted_blob, output_path, decrypted)
|
||||
|
||||
@@ -228,7 +228,6 @@ class StreamManager(SourceManager):
|
||||
while not stream.is_fully_reflected and stream.reflector_progress > 0 and len(sent) > 0:
|
||||
stream.reflector_progress = 0
|
||||
sent = await stream.upload_to_reflector(host, port)
|
||||
return sent
|
||||
|
||||
async def create(self, file_path: str, key: Optional[bytes] = None,
|
||||
iv_generator: Optional[typing.Generator[bytes, None, None]] = None) -> ManagedStream:
|
||||
@@ -237,7 +236,7 @@ class StreamManager(SourceManager):
|
||||
blob_completed_callback=self.blob_manager.blob_completed
|
||||
)
|
||||
await self.storage.store_stream(
|
||||
self.blob_manager.get_blob(descriptor.sd_hash, is_mine=True), descriptor
|
||||
self.blob_manager.get_blob(descriptor.sd_hash), descriptor
|
||||
)
|
||||
row_id = await self.storage.save_published_file(
|
||||
descriptor.stream_hash, os.path.basename(file_path), os.path.dirname(file_path), 0
|
||||
|
||||
+13
-36
@@ -18,7 +18,7 @@ from lbry.wallet import WalletManager, Wallet, Ledger, Account, Transaction
|
||||
from lbry.conf import Config
|
||||
from lbry.wallet.util import satoshis_to_coins
|
||||
from lbry.wallet.orchstr8 import Conductor
|
||||
from lbry.wallet.orchstr8.node import LBCWalletNode, WalletNode, HubNode
|
||||
from lbry.wallet.orchstr8.node import BlockchainNode, WalletNode
|
||||
|
||||
from lbry.extras.daemon.daemon import Daemon, jsonrpc_dumps_pretty
|
||||
from lbry.extras.daemon.components import Component, WalletComponent
|
||||
@@ -222,8 +222,7 @@ class IntegrationTestCase(AsyncioTestCase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.conductor: Optional[Conductor] = None
|
||||
self.blockchain: Optional[LBCWalletNode] = None
|
||||
self.hub: Optional[HubNode] = None
|
||||
self.blockchain: Optional[BlockchainNode] = None
|
||||
self.wallet_node: Optional[WalletNode] = None
|
||||
self.manager: Optional[WalletManager] = None
|
||||
self.ledger: Optional[Ledger] = None
|
||||
@@ -232,18 +231,13 @@ class IntegrationTestCase(AsyncioTestCase):
|
||||
|
||||
async def asyncSetUp(self):
|
||||
self.conductor = Conductor(seed=self.SEED)
|
||||
await self.conductor.start_lbcd()
|
||||
self.addCleanup(self.conductor.stop_lbcd)
|
||||
await self.conductor.start_lbcwallet()
|
||||
self.addCleanup(self.conductor.stop_lbcwallet)
|
||||
await self.conductor.start_blockchain()
|
||||
self.addCleanup(self.conductor.stop_blockchain)
|
||||
await self.conductor.start_spv()
|
||||
self.addCleanup(self.conductor.stop_spv)
|
||||
await self.conductor.start_wallet()
|
||||
self.addCleanup(self.conductor.stop_wallet)
|
||||
await self.conductor.start_hub()
|
||||
self.addCleanup(self.conductor.stop_hub)
|
||||
self.blockchain = self.conductor.lbcwallet_node
|
||||
self.hub = self.conductor.hub_node
|
||||
self.blockchain = self.conductor.blockchain_node
|
||||
self.wallet_node = self.conductor.wallet_node
|
||||
self.manager = self.wallet_node.manager
|
||||
self.ledger = self.wallet_node.ledger
|
||||
@@ -322,7 +316,7 @@ class ExchangeRateManagerComponent(Component):
|
||||
|
||||
class CommandTestCase(IntegrationTestCase):
|
||||
|
||||
VERBOSITY = logging.INFO
|
||||
VERBOSITY = logging.WARN
|
||||
blob_lru_cache_size = 0
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -339,14 +333,13 @@ class CommandTestCase(IntegrationTestCase):
|
||||
self.skip_libtorrent = True
|
||||
|
||||
async def asyncSetUp(self):
|
||||
await super().asyncSetUp()
|
||||
|
||||
logging.getLogger('lbry.blob_exchange').setLevel(self.VERBOSITY)
|
||||
logging.getLogger('lbry.daemon').setLevel(self.VERBOSITY)
|
||||
logging.getLogger('lbry.stream').setLevel(self.VERBOSITY)
|
||||
logging.getLogger('lbry.wallet').setLevel(self.VERBOSITY)
|
||||
|
||||
await super().asyncSetUp()
|
||||
|
||||
self.daemon = await self.add_daemon(self.wallet_node)
|
||||
|
||||
await self.account.ensure_address_gap()
|
||||
@@ -360,7 +353,6 @@ class CommandTestCase(IntegrationTestCase):
|
||||
self.server_config = Config(
|
||||
data_dir=server_tmp_dir,
|
||||
wallet_dir=server_tmp_dir,
|
||||
save_files=True,
|
||||
download_dir=server_tmp_dir
|
||||
)
|
||||
self.server_config.transaction_cache_size = 10000
|
||||
@@ -403,7 +395,6 @@ class CommandTestCase(IntegrationTestCase):
|
||||
# needed during instantiation to access known_hubs path
|
||||
data_dir=wallet_node.data_path,
|
||||
wallet_dir=wallet_node.data_path,
|
||||
save_files=True,
|
||||
download_dir=wallet_node.data_path
|
||||
)
|
||||
conf.upload_dir = upload_dir # not a real conf setting
|
||||
@@ -493,15 +484,13 @@ class CommandTestCase(IntegrationTestCase):
|
||||
""" Synchronous version of `out` method. """
|
||||
return json.loads(jsonrpc_dumps_pretty(value, ledger=self.ledger))['result']
|
||||
|
||||
async def confirm_and_render(self, awaitable, confirm, return_tx=False) -> Transaction:
|
||||
async def confirm_and_render(self, awaitable, confirm) -> Transaction:
|
||||
tx = await awaitable
|
||||
if confirm:
|
||||
await self.ledger.wait(tx)
|
||||
await self.generate(1)
|
||||
await self.ledger.wait(tx, self.blockchain.block_expected)
|
||||
if not return_tx:
|
||||
return self.sout(tx)
|
||||
return tx
|
||||
return self.sout(tx)
|
||||
|
||||
def create_upload_file(self, data, prefix=None, suffix=None):
|
||||
file_path = tempfile.mktemp(prefix=prefix or "tmp", suffix=suffix or "", dir=self.daemon.conf.upload_dir)
|
||||
@@ -512,19 +501,19 @@ class CommandTestCase(IntegrationTestCase):
|
||||
|
||||
async def stream_create(
|
||||
self, name='hovercraft', bid='1.0', file_path=None,
|
||||
data=b'hi!', confirm=True, prefix=None, suffix=None, return_tx=False, **kwargs):
|
||||
data=b'hi!', confirm=True, prefix=None, suffix=None, **kwargs):
|
||||
if file_path is None and data is not None:
|
||||
file_path = self.create_upload_file(data=data, prefix=prefix, suffix=suffix)
|
||||
return await self.confirm_and_render(
|
||||
self.daemon.jsonrpc_stream_create(name, bid, file_path=file_path, **kwargs), confirm, return_tx
|
||||
self.daemon.jsonrpc_stream_create(name, bid, file_path=file_path, **kwargs), confirm
|
||||
)
|
||||
|
||||
async def stream_update(
|
||||
self, claim_id, data=None, prefix=None, suffix=None, confirm=True, return_tx=False, **kwargs):
|
||||
self, claim_id, data=None, prefix=None, suffix=None, confirm=True, **kwargs):
|
||||
if data is not None:
|
||||
file_path = self.create_upload_file(data=data, prefix=prefix, suffix=suffix)
|
||||
return await self.confirm_and_render(
|
||||
self.daemon.jsonrpc_stream_update(claim_id, file_path=file_path, **kwargs), confirm, return_tx
|
||||
self.daemon.jsonrpc_stream_update(claim_id, file_path=file_path, **kwargs), confirm
|
||||
)
|
||||
return await self.confirm_and_render(
|
||||
self.daemon.jsonrpc_stream_update(claim_id, **kwargs), confirm
|
||||
@@ -618,21 +607,12 @@ class CommandTestCase(IntegrationTestCase):
|
||||
await asyncio.wait([self.ledger.wait(tx, self.blockchain.block_expected) for tx in txs])
|
||||
return self.sout(txs)
|
||||
|
||||
async def blob_clean(self):
|
||||
return await self.out(self.daemon.jsonrpc_blob_clean())
|
||||
|
||||
async def status(self):
|
||||
return await self.out(self.daemon.jsonrpc_status())
|
||||
|
||||
async def resolve(self, uri, **kwargs):
|
||||
return (await self.out(self.daemon.jsonrpc_resolve(uri, **kwargs)))[uri]
|
||||
|
||||
async def claim_search(self, **kwargs):
|
||||
return (await self.out(self.daemon.jsonrpc_claim_search(**kwargs)))['items']
|
||||
|
||||
async def get_claim_by_claim_id(self, claim_id):
|
||||
return await self.out(self.ledger.get_claim_by_claim_id(claim_id))
|
||||
|
||||
async def file_list(self, *args, **kwargs):
|
||||
return (await self.out(self.daemon.jsonrpc_file_list(*args, **kwargs)))['items']
|
||||
|
||||
@@ -657,9 +637,6 @@ class CommandTestCase(IntegrationTestCase):
|
||||
async def transaction_list(self, *args, **kwargs):
|
||||
return (await self.out(self.daemon.jsonrpc_transaction_list(*args, **kwargs)))['items']
|
||||
|
||||
async def blob_list(self, *args, **kwargs):
|
||||
return (await self.out(self.daemon.jsonrpc_blob_list(*args, **kwargs)))['items']
|
||||
|
||||
@staticmethod
|
||||
def get_claim_id(tx):
|
||||
return tx['outputs'][0]['claim_id']
|
||||
|
||||
+3
-3
@@ -155,7 +155,7 @@ def async_timed_cache(duration: int):
|
||||
async def _inner(*args, **kwargs) -> typing.Any:
|
||||
loop = asyncio.get_running_loop()
|
||||
time_now = loop.time()
|
||||
key = (args, tuple(kwargs.items()))
|
||||
key = tuple([args, tuple([tuple([k, kwargs[k]]) for k in kwargs])])
|
||||
if key in cache and (time_now - cache[key][1] < duration):
|
||||
return cache[key][0]
|
||||
to_cache = await func(*args, **kwargs)
|
||||
@@ -173,7 +173,7 @@ def cache_concurrent(async_fn):
|
||||
|
||||
@functools.wraps(async_fn)
|
||||
async def wrapper(*args, **kwargs):
|
||||
key = (args, tuple(kwargs.items()))
|
||||
key = tuple([args, tuple([tuple([k, kwargs[k]]) for k in kwargs])])
|
||||
cache[key] = cache.get(key) or asyncio.create_task(async_fn(*args, **kwargs))
|
||||
try:
|
||||
return await cache[key]
|
||||
@@ -342,7 +342,7 @@ def lru_cache_concurrent(cache_size: typing.Optional[int] = None,
|
||||
|
||||
@functools.wraps(async_fn)
|
||||
async def _inner(*args, **kwargs):
|
||||
key = (args, tuple(kwargs.items()))
|
||||
key = tuple([args, tuple([tuple([k, kwargs[k]]) for k in kwargs])])
|
||||
if key in lru_cache:
|
||||
return lru_cache.get(key)
|
||||
|
||||
|
||||
+5
-10
@@ -1,13 +1,8 @@
|
||||
__lbcd__ = 'lbcd'
|
||||
__lbcctl__ = 'lbcctl'
|
||||
__lbcwallet__ = 'lbcwallet'
|
||||
__lbcd_url__ = (
|
||||
'https://github.com/lbryio/lbcd/releases/download/' +
|
||||
'v0.22.100-beta-rc4/lbcd_0.22.100-beta-rc4_TARGET_PLATFORM.tar.gz'
|
||||
)
|
||||
__lbcwallet_url__ = (
|
||||
'https://github.com/lbryio/lbcwallet/releases/download/' +
|
||||
'v0.12.100-alpha-rc2/lbcwallet_0.12.100-alpha-rc2_TARGET_PLATFORM.tar.gz'
|
||||
__node_daemon__ = 'lbrycrdd'
|
||||
__node_cli__ = 'lbrycrd-cli'
|
||||
__node_bin__ = ''
|
||||
__node_url__ = (
|
||||
'https://github.com/lbryio/lbrycrd/releases/download/v0.17.4.6/lbrycrd-linux-1746.zip'
|
||||
)
|
||||
__spvserver__ = 'lbry.wallet.server.coin.LBCRegTest'
|
||||
|
||||
|
||||
Binary file not shown.
@@ -250,7 +250,7 @@ class Account:
|
||||
generator_name = address_generator.get('name', HierarchicalDeterministic.name)
|
||||
self.address_generator = self.address_generators[generator_name]
|
||||
self.receiving, self.change = self.address_generator.from_dict(self, address_generator)
|
||||
self.address_managers = {am.chain_number: am for am in (self.receiving, self.change)}
|
||||
self.address_managers = {am.chain_number: am for am in {self.receiving, self.change}}
|
||||
self.channel_keys = channel_keys
|
||||
ledger.add_account(self)
|
||||
wallet.add_account(self)
|
||||
|
||||
@@ -46,11 +46,9 @@ class _KeyBase:
|
||||
if len(raw_serkey) != 33:
|
||||
raise ValueError('raw_serkey must have length 33')
|
||||
|
||||
return (
|
||||
ver_bytes + bytes((self.depth,))
|
||||
+ self.parent_fingerprint() + self.n.to_bytes(4, 'big')
|
||||
+ self.chain_code + raw_serkey
|
||||
)
|
||||
return (ver_bytes + bytes((self.depth,))
|
||||
+ self.parent_fingerprint() + self.n.to_bytes(4, 'big')
|
||||
+ self.chain_code + raw_serkey)
|
||||
|
||||
def identifier(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -82,10 +82,10 @@ class AIOSQLite:
|
||||
"read_count", "Number of database reads", namespace="daemon_database"
|
||||
)
|
||||
acquire_write_lock_metric = Histogram(
|
||||
'write_lock_acquired', 'Time to acquire the write lock', namespace="daemon_database", buckets=HISTOGRAM_BUCKETS
|
||||
f'write_lock_acquired', 'Time to acquire the write lock', namespace="daemon_database", buckets=HISTOGRAM_BUCKETS
|
||||
)
|
||||
held_write_lock_metric = Histogram(
|
||||
'write_lock_held', 'Length of time the write lock is held for', namespace="daemon_database",
|
||||
f'write_lock_held', 'Length of time the write lock is held for', namespace="daemon_database",
|
||||
buckets=HISTOGRAM_BUCKETS
|
||||
)
|
||||
|
||||
@@ -506,7 +506,7 @@ def _get_spendable_utxos(transaction: sqlite3.Connection, accounts: List, decode
|
||||
amount_to_reserve: int, reserved_amount: int, floor: int, ceiling: int,
|
||||
fee_per_byte: int) -> int:
|
||||
accounts_fmt = ",".join(["?"] * len(accounts))
|
||||
txo_query = """
|
||||
txo_query = f"""
|
||||
SELECT tx.txid, txo.txoid, tx.raw, tx.height, txo.position as nout, tx.is_verified, txo.amount FROM txo
|
||||
INNER JOIN account_address USING (address)
|
||||
LEFT JOIN txi USING (txoid)
|
||||
|
||||
+6
-23
@@ -556,7 +556,7 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
log.info("Sync finished for address %s: %d/%d", address, len(pending_synced_history), len(to_request))
|
||||
|
||||
assert len(pending_synced_history) == len(remote_history), \
|
||||
f"{len(pending_synced_history)} vs {len(remote_history)} for {address}"
|
||||
f"{len(pending_synced_history)} vs {len(remote_history)}"
|
||||
synced_history = ""
|
||||
for remote_i, i in zip(range(len(remote_history)), sorted(pending_synced_history.keys())):
|
||||
assert i == remote_i, f"{i} vs {remote_i}"
|
||||
@@ -768,13 +768,9 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
include_is_my_output=False,
|
||||
include_sent_supports=False,
|
||||
include_sent_tips=False,
|
||||
include_received_tips=False,
|
||||
hub_server=False) -> Tuple[List[Output], dict, int, int]:
|
||||
include_received_tips=False) -> Tuple[List[Output], dict, int, int]:
|
||||
encoded_outputs = await query
|
||||
if hub_server:
|
||||
outputs = Outputs.from_grpc(encoded_outputs)
|
||||
else:
|
||||
outputs = Outputs.from_base64(encoded_outputs or b'') # TODO: why is the server returning None?
|
||||
outputs = Outputs.from_base64(encoded_outputs or b'') # TODO: why is the server returning None?
|
||||
txs: List[Transaction] = []
|
||||
if len(outputs.txs) > 0:
|
||||
async for tx in self.request_transactions(tuple(outputs.txs), cached=True):
|
||||
@@ -891,24 +887,11 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
claim_search(**kwargs), accounts,
|
||||
include_purchase_receipt=include_purchase_receipt,
|
||||
include_is_my_output=include_is_my_output,
|
||||
hub_server=new_sdk_server is not None
|
||||
)
|
||||
|
||||
# async def get_claim_by_claim_id(self, accounts, claim_id, **kwargs) -> Output:
|
||||
# return await self.network.get_claim_by_id(claim_id)
|
||||
|
||||
async def get_claim_by_claim_id(self, claim_id, accounts=None, include_purchase_receipt=False,
|
||||
include_is_my_output=False):
|
||||
accounts = accounts or []
|
||||
# return await self.network.get_claim_by_id(claim_id)
|
||||
inflated = await self._inflate_outputs(
|
||||
self.network.get_claim_by_id(claim_id), accounts,
|
||||
include_purchase_receipt=include_purchase_receipt,
|
||||
include_is_my_output=include_is_my_output,
|
||||
)
|
||||
txos = inflated[0]
|
||||
if txos:
|
||||
return txos[0]
|
||||
async def get_claim_by_claim_id(self, accounts, claim_id, **kwargs) -> Output:
|
||||
for claim in (await self.claim_search(accounts, claim_id=claim_id, **kwargs))[0]:
|
||||
return claim
|
||||
|
||||
async def _report_state(self):
|
||||
try:
|
||||
|
||||
@@ -3,13 +3,11 @@ import json
|
||||
import typing
|
||||
import logging
|
||||
import asyncio
|
||||
from distutils.util import strtobool
|
||||
|
||||
from binascii import unhexlify
|
||||
from decimal import Decimal
|
||||
from typing import List, Type, MutableSequence, MutableMapping, Optional
|
||||
|
||||
from lbry.error import KeyFeeAboveMaxAllowedError, WalletNotLoadedError
|
||||
from lbry.error import KeyFeeAboveMaxAllowedError
|
||||
from lbry.conf import Config, NOT_SET
|
||||
|
||||
from .dewies import dewies_to_lbc
|
||||
@@ -97,7 +95,7 @@ class WalletManager:
|
||||
for wallet in self.wallets:
|
||||
if wallet.id == wallet_id:
|
||||
return wallet
|
||||
raise WalletNotLoadedError(wallet_id)
|
||||
raise ValueError(f"Couldn't find wallet: {wallet_id}.")
|
||||
|
||||
@staticmethod
|
||||
def get_balance(wallet):
|
||||
@@ -183,7 +181,6 @@ class WalletManager:
|
||||
}[config.blockchain_name]
|
||||
|
||||
ledger_config = {
|
||||
'use_go_hub': not strtobool(os.environ.get('ENABLE_LEGACY_SEARCH') or 'yes'),
|
||||
'auto_connect': True,
|
||||
'explicit_servers': [],
|
||||
'hub_timeout': config.hub_timeout,
|
||||
@@ -236,7 +233,6 @@ class WalletManager:
|
||||
|
||||
async def reset(self):
|
||||
self.ledger.config = {
|
||||
'use_go_hub': not strtobool(os.environ.get('ENABLE_LEGACY_SEARCH') or 'yes'),
|
||||
'auto_connect': True,
|
||||
'explicit_servers': [],
|
||||
'default_servers': Config.lbryum_servers.default,
|
||||
|
||||
+9
-20
@@ -7,9 +7,6 @@ from time import perf_counter
|
||||
from collections import defaultdict
|
||||
from typing import Dict, Optional, Tuple
|
||||
import aiohttp
|
||||
import grpc
|
||||
from lbry.schema.types.v2 import hub_pb2_grpc
|
||||
from lbry.schema.types.v2.hub_pb2 import SearchRequest
|
||||
|
||||
from lbry import __version__
|
||||
from lbry.utils import resolve_host
|
||||
@@ -238,7 +235,7 @@ class Network:
|
||||
log.exception("error looking up dns for spv server %s:%i", server, port)
|
||||
|
||||
# accumulate the dns results
|
||||
if self.config.get('explicit_servers', []):
|
||||
if self.config['explicit_servers']:
|
||||
hubs = self.config['explicit_servers']
|
||||
elif self.known_hubs:
|
||||
hubs = self.known_hubs
|
||||
@@ -254,7 +251,7 @@ class Network:
|
||||
sent_ping_timestamps = {}
|
||||
_, ip_to_hostnames = await self.resolve_spv_dns()
|
||||
n = len(ip_to_hostnames)
|
||||
log.info("%i possible spv servers to try (%i urls in config)", n, len(self.config.get('explicit_servers', [])))
|
||||
log.info("%i possible spv servers to try (%i urls in config)", n, len(self.config['explicit_servers']))
|
||||
pongs = {}
|
||||
known_hubs = self.known_hubs
|
||||
try:
|
||||
@@ -299,8 +296,8 @@ class Network:
|
||||
if (pong is not None and self.jurisdiction is not None) and \
|
||||
(pong.country_name != self.jurisdiction):
|
||||
continue
|
||||
client = ClientSession(network=self, server=(host, port), timeout=self.config.get('hub_timeout', 30),
|
||||
concurrency=self.config.get('concurrent_hub_requests', 30))
|
||||
client = ClientSession(network=self, server=(host, port), timeout=self.config['hub_timeout'],
|
||||
concurrency=self.config['concurrent_hub_requests'])
|
||||
try:
|
||||
await client.create_connection()
|
||||
log.warning("Connected to spv server %s:%i", host, port)
|
||||
@@ -465,12 +462,6 @@ class Network:
|
||||
def get_server_features(self):
|
||||
return self.rpc('server.features', (), restricted=True)
|
||||
|
||||
# def get_claims_by_ids(self, claim_ids):
|
||||
# return self.rpc('blockchain.claimtrie.getclaimsbyids', claim_ids)
|
||||
|
||||
def get_claim_by_id(self, claim_id):
|
||||
return self.rpc('blockchain.claimtrie.getclaimbyid', [claim_id])
|
||||
|
||||
def resolve(self, urls, session_override=None):
|
||||
return self.rpc('blockchain.claimtrie.resolve', urls, False, session_override)
|
||||
|
||||
@@ -484,13 +475,11 @@ class Network:
|
||||
return result['result']
|
||||
|
||||
async def new_claim_search(self, server, **kwargs):
|
||||
async with grpc.aio.insecure_channel(server) as channel:
|
||||
stub = hub_pb2_grpc.HubStub(channel)
|
||||
try:
|
||||
response = await stub.Search(SearchRequest(**kwargs))
|
||||
except grpc.aio.AioRpcError as error:
|
||||
raise RPCError(error.code(), error.details())
|
||||
return response
|
||||
kwargs['protobuf'] = True
|
||||
message = {"method": "claim_search", "params": kwargs}
|
||||
async with self.aiohttp_session.post(server, json=message) as r:
|
||||
result = await r.json()
|
||||
return result['result']
|
||||
|
||||
async def sum_supports(self, server, **kwargs):
|
||||
message = {"method": "support_sum", "params": kwargs}
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
__hub_url__ = (
|
||||
"https://github.com/lbryio/hub/releases/download/leveldb-hub/hub"
|
||||
)
|
||||
from .node import Conductor
|
||||
from .service import ConductorService
|
||||
@@ -5,9 +5,7 @@ import aiohttp
|
||||
|
||||
from lbry import wallet
|
||||
from lbry.wallet.orchstr8.node import (
|
||||
Conductor,
|
||||
get_lbcd_node_from_ledger,
|
||||
get_lbcwallet_node_from_ledger
|
||||
Conductor, get_blockchain_node_from_ledger
|
||||
)
|
||||
from lbry.wallet.orchstr8.service import ConductorService
|
||||
|
||||
@@ -18,11 +16,10 @@ def get_argument_parser():
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest='command', help='sub-command help')
|
||||
|
||||
subparsers.add_parser("download", help="Download lbcd and lbcwallet node binaries.")
|
||||
subparsers.add_parser("download", help="Download blockchain node binary.")
|
||||
|
||||
start = subparsers.add_parser("start", help="Start orchstr8 service.")
|
||||
start.add_argument("--lbcd", help="Hostname to start lbcd node.")
|
||||
start.add_argument("--lbcwallet", help="Hostname to start lbcwallet node.")
|
||||
start.add_argument("--blockchain", help="Hostname to start blockchain node.")
|
||||
start.add_argument("--spv", help="Hostname to start SPV server.")
|
||||
start.add_argument("--wallet", help="Hostname to start wallet daemon.")
|
||||
|
||||
@@ -50,8 +47,7 @@ def main():
|
||||
|
||||
if command == 'download':
|
||||
logging.getLogger('blockchain').setLevel(logging.INFO)
|
||||
get_lbcd_node_from_ledger(wallet).ensure()
|
||||
get_lbcwallet_node_from_ledger(wallet).ensure()
|
||||
get_blockchain_node_from_ledger(wallet).ensure()
|
||||
|
||||
elif command == 'generate':
|
||||
loop.run_until_complete(run_remote_command(
|
||||
@@ -61,12 +57,9 @@ def main():
|
||||
elif command == 'start':
|
||||
|
||||
conductor = Conductor()
|
||||
if getattr(args, 'lbcd', False):
|
||||
conductor.lbcd_node.hostname = args.lbcd
|
||||
loop.run_until_complete(conductor.start_lbcd())
|
||||
if getattr(args, 'lbcwallet', False):
|
||||
conductor.lbcwallet_node.hostname = args.lbcwallet
|
||||
loop.run_until_complete(conductor.start_lbcwallet())
|
||||
if getattr(args, 'blockchain', False):
|
||||
conductor.blockchain_node.hostname = args.blockchain
|
||||
loop.run_until_complete(conductor.start_blockchain())
|
||||
if getattr(args, 'spv', False):
|
||||
conductor.spv_node.hostname = args.spv
|
||||
loop.run_until_complete(conductor.start_spv())
|
||||
|
||||
+72
-402
@@ -8,9 +8,6 @@ import logging
|
||||
import tempfile
|
||||
import subprocess
|
||||
import importlib
|
||||
import platform
|
||||
from distutils.util import strtobool
|
||||
|
||||
from binascii import hexlify
|
||||
from typing import Type, Optional
|
||||
import urllib.request
|
||||
@@ -21,7 +18,7 @@ from lbry.wallet.server.server import Server
|
||||
from lbry.wallet.server.env import Env
|
||||
from lbry.wallet import Wallet, Ledger, RegTestLedger, WalletManager, Account, BlockHeightEvent
|
||||
from lbry.conf import KnownHubsList, Config
|
||||
from lbry.wallet.orchstr8 import __hub_url__
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -32,18 +29,11 @@ def get_spvserver_from_ledger(ledger_module):
|
||||
return getattr(spvserver_module, regtest_class_name)
|
||||
|
||||
|
||||
def get_lbcd_node_from_ledger(ledger_module):
|
||||
return LBCDNode(
|
||||
ledger_module.__lbcd_url__,
|
||||
ledger_module.__lbcd__,
|
||||
ledger_module.__lbcctl__
|
||||
)
|
||||
|
||||
def get_lbcwallet_node_from_ledger(ledger_module):
|
||||
return LBCWalletNode(
|
||||
ledger_module.__lbcwallet_url__,
|
||||
ledger_module.__lbcwallet__,
|
||||
ledger_module.__lbcctl__
|
||||
def get_blockchain_node_from_ledger(ledger_module):
|
||||
return BlockchainNode(
|
||||
ledger_module.__node_url__,
|
||||
os.path.join(ledger_module.__node_bin__, ledger_module.__node_daemon__),
|
||||
os.path.join(ledger_module.__node_bin__, ledger_module.__node_cli__)
|
||||
)
|
||||
|
||||
|
||||
@@ -53,52 +43,38 @@ class Conductor:
|
||||
self.manager_module = WalletManager
|
||||
self.spv_module = get_spvserver_from_ledger(lbry.wallet)
|
||||
|
||||
self.lbcd_node = get_lbcd_node_from_ledger(lbry.wallet)
|
||||
self.lbcwallet_node = get_lbcwallet_node_from_ledger(lbry.wallet)
|
||||
self.blockchain_node = get_blockchain_node_from_ledger(lbry.wallet)
|
||||
self.spv_node = SPVNode(self.spv_module)
|
||||
self.wallet_node = WalletNode(
|
||||
self.manager_module, RegTestLedger, default_seed=seed
|
||||
)
|
||||
self.hub_node = HubNode(__hub_url__, "hub", self.spv_node)
|
||||
|
||||
self.lbcd_started = False
|
||||
self.lbcwallet_started = False
|
||||
self.blockchain_started = False
|
||||
self.spv_started = False
|
||||
self.wallet_started = False
|
||||
self.hub_started = False
|
||||
|
||||
self.log = log.getChild('conductor')
|
||||
|
||||
async def start_lbcd(self):
|
||||
if not self.lbcd_started:
|
||||
asyncio.create_task(self.lbcd_node.start())
|
||||
await self.lbcd_node.running.wait()
|
||||
self.lbcd_started = True
|
||||
async def start_blockchain(self):
|
||||
if not self.blockchain_started:
|
||||
asyncio.create_task(self.blockchain_node.start())
|
||||
await self.blockchain_node.running.wait()
|
||||
await self.blockchain_node.generate(200)
|
||||
self.blockchain_started = True
|
||||
|
||||
async def stop_lbcd(self, cleanup=True):
|
||||
if self.lbcd_started:
|
||||
await self.lbcd_node.stop(cleanup)
|
||||
self.lbcd_started = False
|
||||
|
||||
async def start_hub(self):
|
||||
if not self.hub_started:
|
||||
asyncio.create_task(self.hub_node.start())
|
||||
await self.lbcwallet_node.running.wait()
|
||||
self.hub_started = True
|
||||
|
||||
async def stop_hub(self, cleanup=True):
|
||||
if self.hub_started:
|
||||
await self.hub_node.stop(cleanup)
|
||||
self.hub_started = False
|
||||
async def stop_blockchain(self):
|
||||
if self.blockchain_started:
|
||||
await self.blockchain_node.stop(cleanup=True)
|
||||
self.blockchain_started = False
|
||||
|
||||
async def start_spv(self):
|
||||
if not self.spv_started:
|
||||
await self.spv_node.start(self.lbcwallet_node)
|
||||
await self.spv_node.start(self.blockchain_node)
|
||||
self.spv_started = True
|
||||
|
||||
async def stop_spv(self, cleanup=True):
|
||||
async def stop_spv(self):
|
||||
if self.spv_started:
|
||||
await self.spv_node.stop(cleanup)
|
||||
await self.spv_node.stop(cleanup=True)
|
||||
self.spv_started = False
|
||||
|
||||
async def start_wallet(self):
|
||||
@@ -106,31 +82,13 @@ class Conductor:
|
||||
await self.wallet_node.start(self.spv_node)
|
||||
self.wallet_started = True
|
||||
|
||||
async def stop_wallet(self, cleanup=True):
|
||||
async def stop_wallet(self):
|
||||
if self.wallet_started:
|
||||
await self.wallet_node.stop(cleanup)
|
||||
await self.wallet_node.stop(cleanup=True)
|
||||
self.wallet_started = False
|
||||
|
||||
async def start_lbcwallet(self, clean=True):
|
||||
if not self.lbcwallet_started:
|
||||
asyncio.create_task(self.lbcwallet_node.start())
|
||||
await self.lbcwallet_node.running.wait()
|
||||
if clean:
|
||||
mining_addr = await self.lbcwallet_node.get_new_address()
|
||||
self.lbcwallet_node.mining_addr = mining_addr
|
||||
await self.lbcwallet_node.generate(200)
|
||||
# unlock the wallet for the next 1 hour
|
||||
await self.lbcwallet_node.wallet_passphrase("password", 3600)
|
||||
self.lbcwallet_started = True
|
||||
|
||||
async def stop_lbcwallet(self, cleanup=True):
|
||||
if self.lbcwallet_started:
|
||||
await self.lbcwallet_node.stop(cleanup)
|
||||
self.lbcwallet_started = False
|
||||
|
||||
async def start(self):
|
||||
await self.start_lbcd()
|
||||
await self.start_lbcwallet()
|
||||
await self.start_blockchain()
|
||||
await self.start_spv()
|
||||
await self.start_wallet()
|
||||
|
||||
@@ -138,8 +96,7 @@ class Conductor:
|
||||
all_the_stops = [
|
||||
self.stop_wallet,
|
||||
self.stop_spv,
|
||||
self.stop_lbcwallet,
|
||||
self.stop_lbcd
|
||||
self.stop_blockchain
|
||||
]
|
||||
for stop in all_the_stops:
|
||||
try:
|
||||
@@ -147,11 +104,6 @@ class Conductor:
|
||||
except Exception as e:
|
||||
log.exception('Exception raised while stopping services:', exc_info=e)
|
||||
|
||||
async def clear_mempool(self):
|
||||
await self.stop_lbcwallet(cleanup=False)
|
||||
await self.stop_lbcd(cleanup=False)
|
||||
await self.start_lbcd()
|
||||
await self.start_lbcwallet(clean=False)
|
||||
|
||||
class WalletNode:
|
||||
|
||||
@@ -172,15 +124,13 @@ class WalletNode:
|
||||
|
||||
async def start(self, spv_node: 'SPVNode', seed=None, connect=True, config=None):
|
||||
wallets_dir = os.path.join(self.data_path, 'wallets')
|
||||
os.mkdir(wallets_dir)
|
||||
wallet_file_name = os.path.join(wallets_dir, 'my_wallet.json')
|
||||
if not os.path.isdir(wallets_dir):
|
||||
os.mkdir(wallets_dir)
|
||||
with open(wallet_file_name, 'w') as wallet_file:
|
||||
wallet_file.write('{"version": 1, "accounts": []}\n')
|
||||
with open(wallet_file_name, 'w') as wallet_file:
|
||||
wallet_file.write('{"version": 1, "accounts": []}\n')
|
||||
self.manager = self.manager_class.from_config({
|
||||
'ledgers': {
|
||||
self.ledger_class.get_id(): {
|
||||
'use_go_hub': not strtobool(os.environ.get('ENABLE_LEGACY_SEARCH') or 'yes'),
|
||||
'api_port': self.port,
|
||||
'explicit_servers': [(spv_node.hostname, spv_node.port)],
|
||||
'default_servers': Config.lbryum_servers.default,
|
||||
@@ -230,16 +180,15 @@ class SPVNode:
|
||||
self.session_timeout = 600
|
||||
self.rpc_port = '0' # disabled by default
|
||||
self.stopped = False
|
||||
self.index_name = uuid4().hex
|
||||
|
||||
async def start(self, lbcwallet_node: 'LBCWalletNode', extraconf=None):
|
||||
async def start(self, blockchain_node: 'BlockchainNode', extraconf=None):
|
||||
self.data_path = tempfile.mkdtemp()
|
||||
conf = {
|
||||
'DESCRIPTION': '',
|
||||
'PAYMENT_ADDRESS': '',
|
||||
'DAILY_FEE': '0',
|
||||
'DB_DIRECTORY': self.data_path,
|
||||
'DAEMON_URL': lbcwallet_node.rpc_url,
|
||||
'DAEMON_URL': blockchain_node.rpc_url,
|
||||
'REORG_LIMIT': '100',
|
||||
'HOST': self.hostname,
|
||||
'TCP_PORT': str(self.port),
|
||||
@@ -248,7 +197,7 @@ class SPVNode:
|
||||
'MAX_QUERY_WORKERS': '0',
|
||||
'INDIVIDUAL_TAG_INDEXES': '',
|
||||
'RPC_PORT': self.rpc_port,
|
||||
'ES_INDEX_PREFIX': self.index_name,
|
||||
'ES_INDEX_PREFIX': uuid4().hex,
|
||||
'ES_MODE': 'writer',
|
||||
}
|
||||
if extraconf:
|
||||
@@ -256,7 +205,7 @@ class SPVNode:
|
||||
# TODO: don't use os.environ
|
||||
os.environ.update(conf)
|
||||
self.server = Server(Env(self.coin_class))
|
||||
self.server.bp.mempool.refresh_secs = self.server.bp.prefetcher.polling_delay = 0.5
|
||||
self.server.mempool.refresh_secs = self.server.bp.prefetcher.polling_delay = 0.5
|
||||
await self.server.start()
|
||||
|
||||
async def stop(self, cleanup=True):
|
||||
@@ -274,19 +223,18 @@ class SPVNode:
|
||||
shutil.rmtree(self.data_path, ignore_errors=True)
|
||||
|
||||
|
||||
class LBCDProcess(asyncio.SubprocessProtocol):
|
||||
class BlockchainProcess(asyncio.SubprocessProtocol):
|
||||
|
||||
IGNORE_OUTPUT = [
|
||||
b'keypool keep',
|
||||
b'keypool reserve',
|
||||
b'keypool return',
|
||||
b'Block submitted',
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
self.ready = asyncio.Event()
|
||||
self.stopped = asyncio.Event()
|
||||
self.log = log.getChild('lbcd')
|
||||
self.log = log.getChild('blockchain')
|
||||
|
||||
def pipe_data_received(self, fd, data):
|
||||
if self.log and not any(ignore in data for ignore in self.IGNORE_OUTPUT):
|
||||
@@ -297,7 +245,7 @@ class LBCDProcess(asyncio.SubprocessProtocol):
|
||||
if b'Error:' in data:
|
||||
self.ready.set()
|
||||
raise SystemError(data.decode())
|
||||
if b'RPCS: RPC server listening on' in data:
|
||||
if b'Done loading' in data:
|
||||
self.ready.set()
|
||||
|
||||
def process_exited(self):
|
||||
@@ -305,34 +253,10 @@ class LBCDProcess(asyncio.SubprocessProtocol):
|
||||
self.ready.set()
|
||||
|
||||
|
||||
class WalletProcess(asyncio.SubprocessProtocol):
|
||||
class BlockchainNode:
|
||||
|
||||
IGNORE_OUTPUT = [
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
self.ready = asyncio.Event()
|
||||
self.stopped = asyncio.Event()
|
||||
self.log = log.getChild('lbcwallet')
|
||||
self.transport: Optional[asyncio.transports.SubprocessTransport] = None
|
||||
|
||||
def pipe_data_received(self, fd, data):
|
||||
if self.log and not any(ignore in data for ignore in self.IGNORE_OUTPUT):
|
||||
if b'Error:' in data:
|
||||
self.log.error(data.decode())
|
||||
else:
|
||||
self.log.info(data.decode())
|
||||
if b'Error:' in data:
|
||||
self.ready.set()
|
||||
raise SystemError(data.decode())
|
||||
if b'WLLT: Finished rescan' in data:
|
||||
self.ready.set()
|
||||
|
||||
def process_exited(self):
|
||||
self.stopped.set()
|
||||
self.ready.set()
|
||||
|
||||
class LBCDNode:
|
||||
P2SH_SEGWIT_ADDRESS = "p2sh-segwit"
|
||||
BECH32_ADDRESS = "bech32"
|
||||
|
||||
def __init__(self, url, daemon, cli):
|
||||
self.latest_release_url = url
|
||||
@@ -340,22 +264,28 @@ class LBCDNode:
|
||||
self.bin_dir = os.path.join(self.project_dir, 'bin')
|
||||
self.daemon_bin = os.path.join(self.bin_dir, daemon)
|
||||
self.cli_bin = os.path.join(self.bin_dir, cli)
|
||||
self.log = log.getChild('lbcd')
|
||||
self.data_path = tempfile.mkdtemp()
|
||||
self.log = log.getChild('blockchain')
|
||||
self.data_path = None
|
||||
self.protocol = None
|
||||
self.transport = None
|
||||
self.block_expected = 0
|
||||
self.hostname = 'localhost'
|
||||
self.peerport = 29246
|
||||
self.rpcport = 29245
|
||||
self.peerport = 9246 + 2 # avoid conflict with default peer port
|
||||
self.rpcport = 9245 + 2 # avoid conflict with default rpc port
|
||||
self.rpcuser = 'rpcuser'
|
||||
self.rpcpassword = 'rpcpassword'
|
||||
self.stopped = True
|
||||
self.stopped = False
|
||||
self.restart_ready = asyncio.Event()
|
||||
self.restart_ready.set()
|
||||
self.running = asyncio.Event()
|
||||
|
||||
@property
|
||||
def rpc_url(self):
|
||||
return f'http://{self.rpcuser}:{self.rpcpassword}@{self.hostname}:{self.rpcport}/'
|
||||
|
||||
def is_expected_block(self, e: BlockHeightEvent):
|
||||
return self.block_expected == e.height
|
||||
|
||||
@property
|
||||
def exists(self):
|
||||
return (
|
||||
@@ -364,12 +294,6 @@ class LBCDNode:
|
||||
)
|
||||
|
||||
def download(self):
|
||||
uname = platform.uname()
|
||||
target_os = str.lower(uname.system)
|
||||
target_arch = str.replace(uname.machine, 'x86_64', 'amd64')
|
||||
target_platform = target_os + '_' + target_arch
|
||||
self.latest_release_url = str.replace(self.latest_release_url, 'TARGET_PLATFORM', target_platform)
|
||||
|
||||
downloaded_file = os.path.join(
|
||||
self.bin_dir,
|
||||
self.latest_release_url[self.latest_release_url.rfind('/')+1:]
|
||||
@@ -404,34 +328,34 @@ class LBCDNode:
|
||||
|
||||
async def start(self):
|
||||
assert self.ensure()
|
||||
self.data_path = tempfile.mkdtemp()
|
||||
loop = asyncio.get_event_loop()
|
||||
asyncio.get_child_watcher().attach_loop(loop)
|
||||
command = [
|
||||
self.daemon_bin,
|
||||
'--notls',
|
||||
f'--datadir={self.data_path}',
|
||||
'--regtest', f'--listen=127.0.0.1:{self.peerport}', f'--rpclisten=127.0.0.1:{self.rpcport}',
|
||||
'--txindex', f'--rpcuser={self.rpcuser}', f'--rpcpass={self.rpcpassword}'
|
||||
f'-datadir={self.data_path}', '-printtoconsole', '-regtest', '-server', '-txindex',
|
||||
f'-rpcuser={self.rpcuser}', f'-rpcpassword={self.rpcpassword}', f'-rpcport={self.rpcport}',
|
||||
f'-port={self.peerport}'
|
||||
]
|
||||
self.log.info(' '.join(command))
|
||||
while self.stopped:
|
||||
while not self.stopped:
|
||||
if self.running.is_set():
|
||||
await asyncio.sleep(1)
|
||||
continue
|
||||
await self.restart_ready.wait()
|
||||
try:
|
||||
self.transport, self.protocol = await loop.subprocess_exec(
|
||||
LBCDProcess, *command
|
||||
BlockchainProcess, *command
|
||||
)
|
||||
await self.protocol.ready.wait()
|
||||
assert not self.protocol.stopped.is_set()
|
||||
self.running.set()
|
||||
self.stopped = False
|
||||
except asyncio.CancelledError:
|
||||
self.running.clear()
|
||||
raise
|
||||
except Exception as e:
|
||||
self.running.clear()
|
||||
log.exception('failed to start lbcd', exc_info=e)
|
||||
log.exception('failed to start lbrycrdd', exc_info=e)
|
||||
|
||||
async def stop(self, cleanup=True):
|
||||
self.stopped = True
|
||||
@@ -440,147 +364,26 @@ class LBCDNode:
|
||||
await self.protocol.stopped.wait()
|
||||
self.transport.close()
|
||||
finally:
|
||||
self.log.info("Done shutting down " + self.daemon_bin)
|
||||
if cleanup:
|
||||
self.cleanup()
|
||||
self.running.clear()
|
||||
|
||||
async def clear_mempool(self):
|
||||
self.restart_ready.clear()
|
||||
self.transport.terminate()
|
||||
await self.protocol.stopped.wait()
|
||||
self.transport.close()
|
||||
self.running.clear()
|
||||
os.remove(os.path.join(self.data_path, 'regtest', 'mempool.dat'))
|
||||
self.restart_ready.set()
|
||||
await self.running.wait()
|
||||
|
||||
def cleanup(self):
|
||||
assert self.stopped
|
||||
shutil.rmtree(self.data_path, ignore_errors=True)
|
||||
|
||||
|
||||
class LBCWalletNode:
|
||||
P2SH_SEGWIT_ADDRESS = "p2sh-segwit"
|
||||
BECH32_ADDRESS = "bech32"
|
||||
|
||||
def __init__(self, url, lbcwallet, cli):
|
||||
self.latest_release_url = url
|
||||
self.project_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
self.bin_dir = os.path.join(self.project_dir, 'bin')
|
||||
self.lbcwallet_bin = os.path.join(self.bin_dir, lbcwallet)
|
||||
self.cli_bin = os.path.join(self.bin_dir, cli)
|
||||
self.log = log.getChild('lbcwallet')
|
||||
self.protocol = None
|
||||
self.transport = None
|
||||
self.hostname = 'localhost'
|
||||
self.lbcd_rpcport = 29245
|
||||
self.lbcwallet_rpcport = 29244
|
||||
self.rpcuser = 'rpcuser'
|
||||
self.rpcpassword = 'rpcpassword'
|
||||
self.data_path = tempfile.mkdtemp()
|
||||
self.stopped = True
|
||||
self.running = asyncio.Event()
|
||||
self.block_expected = 0
|
||||
self.mining_addr = ''
|
||||
|
||||
@property
|
||||
def rpc_url(self):
|
||||
# FIXME: somehow the hub/sdk doesn't learn the blocks through the Walet RPC port, why?
|
||||
# return f'http://{self.rpcuser}:{self.rpcpassword}@{self.hostname}:{self.lbcwallet_rpcport}/'
|
||||
return f'http://{self.rpcuser}:{self.rpcpassword}@{self.hostname}:{self.lbcd_rpcport}/'
|
||||
|
||||
def is_expected_block(self, e: BlockHeightEvent):
|
||||
return self.block_expected == e.height
|
||||
|
||||
@property
|
||||
def exists(self):
|
||||
return (
|
||||
os.path.exists(self.lbcwallet_bin)
|
||||
)
|
||||
|
||||
def download(self):
|
||||
uname = platform.uname()
|
||||
target_os = str.lower(uname.system)
|
||||
target_arch = str.replace(uname.machine, 'x86_64', 'amd64')
|
||||
target_platform = target_os + '_' + target_arch
|
||||
self.latest_release_url = str.replace(self.latest_release_url, 'TARGET_PLATFORM', target_platform)
|
||||
|
||||
downloaded_file = os.path.join(
|
||||
self.bin_dir,
|
||||
self.latest_release_url[self.latest_release_url.rfind('/')+1:]
|
||||
)
|
||||
|
||||
if not os.path.exists(self.bin_dir):
|
||||
os.mkdir(self.bin_dir)
|
||||
|
||||
if not os.path.exists(downloaded_file):
|
||||
self.log.info('Downloading: %s', self.latest_release_url)
|
||||
with urllib.request.urlopen(self.latest_release_url) as response:
|
||||
with open(downloaded_file, 'wb') as out_file:
|
||||
shutil.copyfileobj(response, out_file)
|
||||
|
||||
self.log.info('Extracting: %s', downloaded_file)
|
||||
|
||||
if downloaded_file.endswith('.zip'):
|
||||
with zipfile.ZipFile(downloaded_file) as dotzip:
|
||||
dotzip.extractall(self.bin_dir)
|
||||
# zipfile bug https://bugs.python.org/issue15795
|
||||
os.chmod(self.lbcwallet_bin, 0o755)
|
||||
|
||||
elif downloaded_file.endswith('.tar.gz'):
|
||||
with tarfile.open(downloaded_file) as tar:
|
||||
tar.extractall(self.bin_dir)
|
||||
|
||||
return self.exists
|
||||
|
||||
def ensure(self):
|
||||
return self.exists or self.download()
|
||||
|
||||
async def start(self):
|
||||
assert self.ensure()
|
||||
loop = asyncio.get_event_loop()
|
||||
asyncio.get_child_watcher().attach_loop(loop)
|
||||
|
||||
command = [
|
||||
self.lbcwallet_bin,
|
||||
'--noservertls', '--noclienttls',
|
||||
'--regtest',
|
||||
f'--rpcconnect=127.0.0.1:{self.lbcd_rpcport}', f'--rpclisten=127.0.0.1:{self.lbcwallet_rpcport}',
|
||||
'--createtemp', f'--appdata={self.data_path}',
|
||||
f'--username={self.rpcuser}', f'--password={self.rpcpassword}'
|
||||
]
|
||||
self.log.info(' '.join(command))
|
||||
while self.stopped:
|
||||
if self.running.is_set():
|
||||
await asyncio.sleep(1)
|
||||
continue
|
||||
try:
|
||||
self.transport, self.protocol = await loop.subprocess_exec(
|
||||
WalletProcess, *command
|
||||
)
|
||||
self.protocol.transport = self.transport
|
||||
await self.protocol.ready.wait()
|
||||
assert not self.protocol.stopped.is_set()
|
||||
self.running.set()
|
||||
self.stopped = False
|
||||
except asyncio.CancelledError:
|
||||
self.running.clear()
|
||||
raise
|
||||
except Exception as e:
|
||||
self.running.clear()
|
||||
log.exception('failed to start lbcwallet', exc_info=e)
|
||||
|
||||
def cleanup(self):
|
||||
assert self.stopped
|
||||
shutil.rmtree(self.data_path, ignore_errors=True)
|
||||
|
||||
async def stop(self, cleanup=True):
|
||||
self.stopped = True
|
||||
try:
|
||||
self.transport.terminate()
|
||||
await self.protocol.stopped.wait()
|
||||
self.transport.close()
|
||||
finally:
|
||||
self.log.info("Done shutting down " + self.lbcwallet_bin)
|
||||
if cleanup:
|
||||
self.cleanup()
|
||||
self.running.clear()
|
||||
|
||||
async def _cli_cmnd(self, *args):
|
||||
cmnd_args = [
|
||||
self.cli_bin,
|
||||
f'--rpcuser={self.rpcuser}', f'--rpcpass={self.rpcpassword}', '--notls', '--regtest', '--wallet'
|
||||
self.cli_bin, f'-datadir={self.data_path}', '-regtest',
|
||||
f'-rpcuser={self.rpcuser}', f'-rpcpassword={self.rpcpassword}', f'-rpcport={self.rpcport}'
|
||||
] + list(args)
|
||||
self.log.info(' '.join(cmnd_args))
|
||||
loop = asyncio.get_event_loop()
|
||||
@@ -597,14 +400,7 @@ class LBCWalletNode:
|
||||
|
||||
def generate(self, blocks):
|
||||
self.block_expected += blocks
|
||||
return self._cli_cmnd('generatetoaddress', str(blocks), self.mining_addr)
|
||||
|
||||
def generate_to_address(self, blocks, addr):
|
||||
self.block_expected += blocks
|
||||
return self._cli_cmnd('generatetoaddress', str(blocks), addr)
|
||||
|
||||
def wallet_passphrase(self, passphrase, timeout):
|
||||
return self._cli_cmnd('walletpassphrase', passphrase, str(timeout))
|
||||
return self._cli_cmnd('generate', str(blocks))
|
||||
|
||||
def invalidate_block(self, blockhash):
|
||||
return self._cli_cmnd('invalidateblock', blockhash)
|
||||
@@ -621,7 +417,7 @@ class LBCWalletNode:
|
||||
def get_raw_change_address(self):
|
||||
return self._cli_cmnd('getrawchangeaddress')
|
||||
|
||||
def get_new_address(self, address_type='legacy'):
|
||||
def get_new_address(self, address_type):
|
||||
return self._cli_cmnd('getnewaddress', "", address_type)
|
||||
|
||||
async def get_balance(self):
|
||||
@@ -637,136 +433,10 @@ class LBCWalletNode:
|
||||
return self._cli_cmnd('createrawtransaction', json.dumps(inputs), json.dumps(outputs))
|
||||
|
||||
async def sign_raw_transaction_with_wallet(self, tx):
|
||||
# the "withwallet" portion should only come into play if we are doing segwit.
|
||||
# and "withwallet" doesn't exist on lbcd yet.
|
||||
result = await self._cli_cmnd('signrawtransaction', tx)
|
||||
return json.loads(result)['hex'].encode()
|
||||
return json.loads(await self._cli_cmnd('signrawtransactionwithwallet', tx))['hex'].encode()
|
||||
|
||||
def decode_raw_transaction(self, tx):
|
||||
return self._cli_cmnd('decoderawtransaction', hexlify(tx.raw).decode())
|
||||
|
||||
def get_raw_transaction(self, txid):
|
||||
return self._cli_cmnd('getrawtransaction', txid, '1')
|
||||
|
||||
|
||||
class HubProcess(asyncio.SubprocessProtocol):
|
||||
def __init__(self):
|
||||
self.ready = asyncio.Event()
|
||||
self.stopped = asyncio.Event()
|
||||
self.log = log.getChild('hub')
|
||||
|
||||
def pipe_data_received(self, fd, data):
|
||||
if self.log:
|
||||
self.log.info(data.decode())
|
||||
if b'error' in data.lower():
|
||||
self.ready.set()
|
||||
raise SystemError(data.decode())
|
||||
if b'listening on' in data:
|
||||
self.ready.set()
|
||||
|
||||
def process_exited(self):
|
||||
self.stopped.set()
|
||||
self.ready.set()
|
||||
|
||||
|
||||
class HubNode:
|
||||
|
||||
def __init__(self, url, daemon, spv_node):
|
||||
self.spv_node = spv_node
|
||||
self.debug = False
|
||||
|
||||
self.latest_release_url = url
|
||||
self.project_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
self.bin_dir = os.path.join(self.project_dir, 'bin')
|
||||
self.daemon_bin = os.path.join(self.bin_dir, daemon)
|
||||
self.cli_bin = os.path.join(self.bin_dir, daemon)
|
||||
self.log = log.getChild('hub')
|
||||
self.transport = None
|
||||
self.protocol = None
|
||||
self.hostname = 'localhost'
|
||||
self.rpcport = 50051 # avoid conflict with default rpc port
|
||||
self.stopped = False
|
||||
self.running = asyncio.Event()
|
||||
|
||||
@property
|
||||
def exists(self):
|
||||
return (
|
||||
os.path.exists(self.cli_bin) and
|
||||
os.path.exists(self.daemon_bin)
|
||||
)
|
||||
|
||||
def download(self):
|
||||
downloaded_file = os.path.join(
|
||||
self.bin_dir,
|
||||
self.latest_release_url[self.latest_release_url.rfind('/')+1:]
|
||||
)
|
||||
|
||||
if not os.path.exists(self.bin_dir):
|
||||
os.mkdir(self.bin_dir)
|
||||
|
||||
if not os.path.exists(downloaded_file):
|
||||
self.log.info('Downloading: %s', self.latest_release_url)
|
||||
with urllib.request.urlopen(self.latest_release_url) as response:
|
||||
with open(downloaded_file, 'wb') as out_file:
|
||||
shutil.copyfileobj(response, out_file)
|
||||
|
||||
self.log.info('Extracting: %s', downloaded_file)
|
||||
|
||||
if downloaded_file.endswith('.zip'):
|
||||
with zipfile.ZipFile(downloaded_file) as dotzip:
|
||||
dotzip.extractall(self.bin_dir)
|
||||
# zipfile bug https://bugs.python.org/issue15795
|
||||
os.chmod(self.cli_bin, 0o755)
|
||||
os.chmod(self.daemon_bin, 0o755)
|
||||
|
||||
elif downloaded_file.endswith('.tar.gz'):
|
||||
with tarfile.open(downloaded_file) as tar:
|
||||
tar.extractall(self.bin_dir)
|
||||
|
||||
os.chmod(self.daemon_bin, 0o755)
|
||||
|
||||
return self.exists
|
||||
|
||||
def ensure(self):
|
||||
return self.exists or self.download()
|
||||
|
||||
async def start(self):
|
||||
assert self.ensure()
|
||||
loop = asyncio.get_event_loop()
|
||||
asyncio.get_child_watcher().attach_loop(loop)
|
||||
command = [
|
||||
self.daemon_bin, 'serve', '--esindex', self.spv_node.index_name + 'claims', '--debug'
|
||||
]
|
||||
self.log.info(' '.join(command))
|
||||
while not self.stopped:
|
||||
if self.running.is_set():
|
||||
await asyncio.sleep(1)
|
||||
continue
|
||||
try:
|
||||
if not self.debug:
|
||||
self.transport, self.protocol = await loop.subprocess_exec(
|
||||
HubProcess, *command
|
||||
)
|
||||
await self.protocol.ready.wait()
|
||||
assert not self.protocol.stopped.is_set()
|
||||
self.running.set()
|
||||
except asyncio.CancelledError:
|
||||
self.running.clear()
|
||||
raise
|
||||
except Exception as e:
|
||||
self.running.clear()
|
||||
log.exception('failed to start hub', exc_info=e)
|
||||
|
||||
async def stop(self, cleanup=True):
|
||||
self.stopped = True
|
||||
try:
|
||||
if not self.debug:
|
||||
self.transport.terminate()
|
||||
await self.protocol.stopped.wait()
|
||||
self.transport.close()
|
||||
finally:
|
||||
if cleanup:
|
||||
self.cleanup()
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
@@ -61,10 +61,8 @@ class ConductorService:
|
||||
#set_logging(
|
||||
# self.stack.ledger_module, logging.DEBUG, WebSocketLogHandler(self.send_message)
|
||||
#)
|
||||
self.stack.lbcd_started or await self.stack.start_lbcd()
|
||||
self.send_message({'type': 'service', 'name': 'lbcd', 'port': self.stack.lbcd_node.port})
|
||||
self.stack.lbcwallet_started or await self.stack.start_lbcwallet()
|
||||
self.send_message({'type': 'service', 'name': 'lbcwallet', 'port': self.stack.lbcwallet_node.port})
|
||||
self.stack.blockchain_started or await self.stack.start_blockchain()
|
||||
self.send_message({'type': 'service', 'name': 'blockchain', 'port': self.stack.blockchain_node.port})
|
||||
self.stack.spv_started or await self.stack.start_spv()
|
||||
self.send_message({'type': 'service', 'name': 'spv', 'port': self.stack.spv_node.port})
|
||||
self.stack.wallet_started or await self.stack.start_wallet()
|
||||
@@ -76,7 +74,7 @@ class ConductorService:
|
||||
async def generate(self, request):
|
||||
data = await request.post()
|
||||
blocks = data.get('blocks', 1)
|
||||
await self.stack.lbcwallet_node.generate(int(blocks))
|
||||
await self.stack.blockchain_node.generate(int(blocks))
|
||||
return json_response({'blocks': blocks})
|
||||
|
||||
async def transfer(self, request):
|
||||
@@ -87,7 +85,7 @@ class ConductorService:
|
||||
if not address:
|
||||
raise ValueError("No address was provided.")
|
||||
amount = data.get('amount', 1)
|
||||
txid = await self.stack.lbcwallet_node.send_to_address(address, amount)
|
||||
txid = await self.stack.blockchain_node.send_to_address(address, amount)
|
||||
if self.stack.wallet_started:
|
||||
await self.stack.wallet_node.ledger.on_transaction.where(
|
||||
lambda e: e.tx.id == txid and e.address == address
|
||||
@@ -100,7 +98,7 @@ class ConductorService:
|
||||
|
||||
async def balance(self, _):
|
||||
return json_response({
|
||||
'balance': await self.stack.lbcwallet_node.get_balance()
|
||||
'balance': await self.stack.blockchain_node.get_balance()
|
||||
})
|
||||
|
||||
async def log(self, request):
|
||||
@@ -131,7 +129,7 @@ class ConductorService:
|
||||
'type': 'status',
|
||||
'height': self.stack.wallet_node.ledger.headers.height,
|
||||
'balance': satoshis_to_coins(await self.stack.wallet_node.account.get_balance()),
|
||||
'miner': await self.stack.lbcwallet_node.get_balance()
|
||||
'miner': await self.stack.blockchain_node.get_balance()
|
||||
})
|
||||
|
||||
def send_message(self, msg):
|
||||
|
||||
@@ -496,17 +496,6 @@ class RPCSession(SessionBase):
|
||||
self.abort()
|
||||
return False
|
||||
|
||||
async def send_notifications(self, notifications) -> bool:
|
||||
"""Send an RPC notification over the network."""
|
||||
message, _ = self.connection.send_batch(notifications)
|
||||
try:
|
||||
await self._send_message(message)
|
||||
return True
|
||||
except asyncio.TimeoutError:
|
||||
self.logger.info("timeout sending address notification to %s", self.peer_address_str(for_log=True))
|
||||
self.abort()
|
||||
return False
|
||||
|
||||
def send_batch(self, raise_errors=False):
|
||||
"""Return a BatchRequest. Intended to be used like so:
|
||||
|
||||
|
||||
+495
-1473
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import traceback
|
||||
import argparse
|
||||
import importlib
|
||||
from lbry.wallet.server.env import Env
|
||||
from lbry.wallet.server.server import Server
|
||||
|
||||
@@ -9,19 +10,27 @@ def get_argument_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lbry-hub"
|
||||
)
|
||||
Env.contribute_to_arg_parser(parser)
|
||||
parser.add_argument("spvserver", type=str, help="Python class path to SPV server implementation.",
|
||||
nargs="?", default="lbry.wallet.server.coin.LBC")
|
||||
return parser
|
||||
|
||||
|
||||
def get_coin_class(spvserver):
|
||||
spvserver_path, coin_class_name = spvserver.rsplit('.', 1)
|
||||
spvserver_module = importlib.import_module(spvserver_path)
|
||||
return getattr(spvserver_module, coin_class_name)
|
||||
|
||||
|
||||
def main():
|
||||
parser = get_argument_parser()
|
||||
args = parser.parse_args()
|
||||
coin_class = get_coin_class(args.spvserver)
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)-4s %(name)s:%(lineno)d: %(message)s")
|
||||
logging.info('lbry.server starting')
|
||||
logging.getLogger('aiohttp').setLevel(logging.WARNING)
|
||||
logging.getLogger('elasticsearch').setLevel(logging.WARNING)
|
||||
try:
|
||||
server = Server(Env.from_arg_parser(args))
|
||||
server = Server(Env(coin_class))
|
||||
server.run()
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -14,7 +14,8 @@ from lbry.wallet.server.daemon import Daemon, LBCDaemon
|
||||
from lbry.wallet.server.script import ScriptPubKey, OpCodes
|
||||
from lbry.wallet.server.leveldb import LevelDB
|
||||
from lbry.wallet.server.session import LBRYElectrumX, LBRYSessionManager
|
||||
from lbry.wallet.server.block_processor import BlockProcessor
|
||||
from lbry.wallet.server.db.writer import LBRYLevelDB
|
||||
from lbry.wallet.server.block_processor import LBRYBlockProcessor
|
||||
|
||||
|
||||
Block = namedtuple("Block", "raw header transactions")
|
||||
@@ -38,7 +39,7 @@ class Coin:
|
||||
SESSIONCLS = LBRYElectrumX
|
||||
DESERIALIZER = lib_tx.Deserializer
|
||||
DAEMON = Daemon
|
||||
BLOCK_PROCESSOR = BlockProcessor
|
||||
BLOCK_PROCESSOR = LBRYBlockProcessor
|
||||
SESSION_MANAGER = LBRYSessionManager
|
||||
DB = LevelDB
|
||||
HEADER_VALUES = [
|
||||
@@ -213,11 +214,6 @@ class Coin:
|
||||
txs = cls.DESERIALIZER(raw_block, start=len(header)).read_tx_block()
|
||||
return Block(raw_block, header, txs)
|
||||
|
||||
@classmethod
|
||||
def transaction(cls, raw_tx: bytes):
|
||||
"""Return a Block namedtuple given a raw block and its height."""
|
||||
return cls.DESERIALIZER(raw_tx).read_tx()
|
||||
|
||||
@classmethod
|
||||
def decimal_value(cls, value):
|
||||
"""Return the number of standard coin units as a Decimal given a
|
||||
@@ -241,9 +237,10 @@ class Coin:
|
||||
class LBC(Coin):
|
||||
DAEMON = LBCDaemon
|
||||
SESSIONCLS = LBRYElectrumX
|
||||
BLOCK_PROCESSOR = LBRYBlockProcessor
|
||||
SESSION_MANAGER = LBRYSessionManager
|
||||
DESERIALIZER = DeserializerSegWit
|
||||
DB = LevelDB
|
||||
DB = LBRYLevelDB
|
||||
NAME = "LBRY"
|
||||
SHORTNAME = "LBC"
|
||||
NET = "mainnet"
|
||||
@@ -261,18 +258,6 @@ class LBC(Coin):
|
||||
TX_PER_BLOCK = 1
|
||||
RPC_PORT = 9245
|
||||
REORG_LIMIT = 200
|
||||
|
||||
nOriginalClaimExpirationTime = 262974
|
||||
nExtendedClaimExpirationTime = 2102400
|
||||
nExtendedClaimExpirationForkHeight = 400155
|
||||
nNormalizedNameForkHeight = 539940 # targeting 21 March 2019
|
||||
nMinTakeoverWorkaroundHeight = 496850
|
||||
nMaxTakeoverWorkaroundHeight = 658300 # targeting 30 Oct 2019
|
||||
nWitnessForkHeight = 680770 # targeting 11 Dec 2019
|
||||
nAllClaimsInMerkleForkHeight = 658310 # targeting 30 Oct 2019
|
||||
proportionalDelayFactor = 32
|
||||
maxTakeoverDelay = 4032
|
||||
|
||||
PEERS = [
|
||||
]
|
||||
|
||||
@@ -350,18 +335,6 @@ class LBC(Coin):
|
||||
else:
|
||||
return sha256(script).digest()[:HASHX_LEN]
|
||||
|
||||
@classmethod
|
||||
def get_expiration_height(cls, last_updated_height: int, extended: bool = False) -> int:
|
||||
if extended:
|
||||
return last_updated_height + cls.nExtendedClaimExpirationTime
|
||||
if last_updated_height < cls.nExtendedClaimExpirationForkHeight:
|
||||
return last_updated_height + cls.nOriginalClaimExpirationTime
|
||||
return last_updated_height + cls.nExtendedClaimExpirationTime
|
||||
|
||||
@classmethod
|
||||
def get_delay_for_name(cls, blocks_of_continuous_ownership: int) -> int:
|
||||
return min(blocks_of_continuous_ownership // cls.proportionalDelayFactor, cls.maxTakeoverDelay)
|
||||
|
||||
|
||||
class LBCRegTest(LBC):
|
||||
NET = "regtest"
|
||||
@@ -371,15 +344,6 @@ class LBCRegTest(LBC):
|
||||
P2PKH_VERBYTE = bytes.fromhex("6f")
|
||||
P2SH_VERBYTES = bytes.fromhex("c4")
|
||||
|
||||
nOriginalClaimExpirationTime = 500
|
||||
nExtendedClaimExpirationTime = 600
|
||||
nExtendedClaimExpirationForkHeight = 800
|
||||
nNormalizedNameForkHeight = 250
|
||||
nMinTakeoverWorkaroundHeight = -1
|
||||
nMaxTakeoverWorkaroundHeight = -1
|
||||
nWitnessForkHeight = 150
|
||||
nAllClaimsInMerkleForkHeight = 350
|
||||
|
||||
|
||||
class LBCTestNet(LBCRegTest):
|
||||
NET = "testnet"
|
||||
|
||||
@@ -55,7 +55,7 @@ class Daemon:
|
||||
self.available_rpcs = {}
|
||||
self.connector = aiohttp.TCPConnector()
|
||||
self._block_hash_cache = LRUCacheWithMetrics(100000)
|
||||
self._block_cache = LRUCacheWithMetrics(2 ** 13, metric_name='block', namespace=NAMESPACE)
|
||||
self._block_cache = LRUCacheWithMetrics(2 ** 16, metric_name='block', namespace=NAMESPACE)
|
||||
|
||||
async def close(self):
|
||||
if self.connector:
|
||||
@@ -250,14 +250,14 @@ class Daemon:
|
||||
async def deserialised_block(self, hex_hash):
|
||||
"""Return the deserialised block with the given hex hash."""
|
||||
if hex_hash not in self._block_cache:
|
||||
block = await self._send_single('getblock', (hex_hash, 1))
|
||||
block = await self._send_single('getblock', (hex_hash, True))
|
||||
self._block_cache[hex_hash] = block
|
||||
return block
|
||||
return self._block_cache[hex_hash]
|
||||
|
||||
async def raw_blocks(self, hex_hashes):
|
||||
"""Return the raw binary blocks with the given hex hashes."""
|
||||
params_iterable = ((h, 0) for h in hex_hashes)
|
||||
params_iterable = ((h, False) for h in hex_hashes)
|
||||
blocks = await self._send_vector('getblock', params_iterable)
|
||||
# Convert hex string to bytes
|
||||
return [hex_to_bytes(block) for block in blocks]
|
||||
@@ -334,7 +334,37 @@ class LBCDaemon(Daemon):
|
||||
async def getrawtransaction(self, hex_hash, verbose=False):
|
||||
return await super().getrawtransaction(hex_hash=hex_hash, verbose=verbose)
|
||||
|
||||
@handles_errors
|
||||
async def getclaimbyid(self, claim_id):
|
||||
'''Given a claim id, retrieves claim information.'''
|
||||
return await self._send_single('getclaimbyid', (claim_id,))
|
||||
|
||||
@handles_errors
|
||||
async def getclaimsbyids(self, claim_ids):
|
||||
'''Given a list of claim ids, batches calls to retrieve claim information.'''
|
||||
return await self._send_vector('getclaimbyid', ((claim_id,) for claim_id in claim_ids))
|
||||
|
||||
@handles_errors
|
||||
async def getclaimsforname(self, name):
|
||||
'''Given a name, retrieves all claims matching that name.'''
|
||||
return await self._send_single('getclaimsforname', (name,))
|
||||
|
||||
@handles_errors
|
||||
async def getclaimsfortx(self, txid):
|
||||
'''Given a txid, returns the claims it make.'''
|
||||
return await self._send_single('getclaimsfortx', (txid,)) or []
|
||||
|
||||
@handles_errors
|
||||
async def getnameproof(self, name, block_hash=None):
|
||||
'''Given a name and optional block_hash, returns a name proof and winner, if any.'''
|
||||
return await self._send_single('getnameproof', (name, block_hash,) if block_hash else (name,))
|
||||
|
||||
@handles_errors
|
||||
async def getvalueforname(self, name):
|
||||
'''Given a name, returns the winning claim value.'''
|
||||
return await self._send_single('getvalueforname', (name,))
|
||||
|
||||
@handles_errors
|
||||
async def claimname(self, name, hexvalue, amount):
|
||||
'''Claim a name, used for functional tests only.'''
|
||||
return await self._send_single('claimname', (name, hexvalue, float(amount)))
|
||||
@@ -1,42 +0,0 @@
|
||||
import enum
|
||||
|
||||
|
||||
@enum.unique
|
||||
class DB_PREFIXES(enum.Enum):
|
||||
claim_to_support = b'K'
|
||||
support_to_claim = b'L'
|
||||
|
||||
claim_to_txo = b'E'
|
||||
txo_to_claim = b'G'
|
||||
|
||||
claim_to_channel = b'I'
|
||||
channel_to_claim = b'J'
|
||||
|
||||
claim_short_id_prefix = b'F'
|
||||
effective_amount = b'D'
|
||||
claim_expiration = b'O'
|
||||
|
||||
claim_takeover = b'P'
|
||||
pending_activation = b'Q'
|
||||
activated_claim_and_support = b'R'
|
||||
active_amount = b'S'
|
||||
|
||||
repost = b'V'
|
||||
reposted_claim = b'W'
|
||||
|
||||
undo = b'M'
|
||||
claim_diff = b'Y'
|
||||
|
||||
tx = b'B'
|
||||
block_hash = b'C'
|
||||
header = b'H'
|
||||
tx_num = b'N'
|
||||
tx_count = b'T'
|
||||
tx_hash = b'X'
|
||||
utxo = b'u'
|
||||
hashx_utxo = b'h'
|
||||
hashx_history = b'x'
|
||||
db_state = b's'
|
||||
channel_count = b'Z'
|
||||
support_amount = b'a'
|
||||
block_txs = b'b'
|
||||
@@ -0,0 +1,22 @@
|
||||
class FindShortestID:
|
||||
__slots__ = 'short_id', 'new_id'
|
||||
|
||||
def __init__(self):
|
||||
self.short_id = ''
|
||||
self.new_id = None
|
||||
|
||||
def step(self, other_id, new_id):
|
||||
self.new_id = new_id
|
||||
for i in range(len(self.new_id)):
|
||||
if other_id[i] != self.new_id[i]:
|
||||
if i > len(self.short_id)-1:
|
||||
self.short_id = self.new_id[:i+1]
|
||||
break
|
||||
|
||||
def finalize(self):
|
||||
if self.short_id:
|
||||
return '#'+self.short_id
|
||||
|
||||
|
||||
def register_canonical_functions(connection):
|
||||
connection.create_aggregate("shortest_id", 2, FindShortestID)
|
||||
@@ -1,5 +1,3 @@
|
||||
import typing
|
||||
|
||||
CLAIM_TYPES = {
|
||||
'stream': 1,
|
||||
'channel': 2,
|
||||
@@ -420,28 +418,3 @@ INDEXED_LANGUAGES = [
|
||||
'zh',
|
||||
'zu'
|
||||
]
|
||||
|
||||
|
||||
class ResolveResult(typing.NamedTuple):
|
||||
name: str
|
||||
normalized_name: str
|
||||
claim_hash: bytes
|
||||
tx_num: int
|
||||
position: int
|
||||
tx_hash: bytes
|
||||
height: int
|
||||
amount: int
|
||||
short_url: str
|
||||
is_controlling: bool
|
||||
canonical_url: str
|
||||
creation_height: int
|
||||
activation_height: int
|
||||
expiration_height: int
|
||||
effective_amount: int
|
||||
support_amount: int
|
||||
reposted: int
|
||||
last_takeover_height: typing.Optional[int]
|
||||
claims_in_channel: typing.Optional[int]
|
||||
channel_hash: typing.Optional[bytes]
|
||||
reposted_claim_hash: typing.Optional[bytes]
|
||||
signature_valid: typing.Optional[bool]
|
||||
@@ -1,220 +0,0 @@
|
||||
import struct
|
||||
import rocksdb
|
||||
from typing import Optional
|
||||
from lbry.wallet.server.db import DB_PREFIXES
|
||||
from lbry.wallet.server.db.revertable import RevertableOpStack, RevertablePut, RevertableDelete
|
||||
|
||||
|
||||
class RocksDBStore:
|
||||
def __init__(self, path: str, cache_mb: int, max_open_files: int, secondary_path: str = ''):
|
||||
# Use snappy compression (the default)
|
||||
self.path = path
|
||||
self._max_open_files = max_open_files
|
||||
self.db = rocksdb.DB(path, self.get_options(), secondary_name=secondary_path)
|
||||
# self.multi_get = self.db.multi_get
|
||||
|
||||
def get_options(self):
|
||||
return rocksdb.Options(
|
||||
create_if_missing=True, use_fsync=True, target_file_size_base=33554432,
|
||||
max_open_files=self._max_open_files
|
||||
)
|
||||
|
||||
def get(self, key: bytes, fill_cache: bool = True) -> Optional[bytes]:
|
||||
return self.db.get(key, fill_cache=fill_cache)
|
||||
|
||||
def iterator(self, reverse=False, start=None, stop=None, include_start=True, include_stop=False, prefix=None,
|
||||
include_key=True, include_value=True, fill_cache=True):
|
||||
return RocksDBIterator(
|
||||
self.db, reverse=reverse, start=start, stop=stop, include_start=include_start, include_stop=include_stop,
|
||||
prefix=prefix, include_key=include_key, include_value=include_value
|
||||
)
|
||||
|
||||
def write_batch(self, disable_wal: bool = False, sync: bool = False):
|
||||
return RocksDBWriteBatch(self.db, sync=sync, disable_wal=disable_wal)
|
||||
|
||||
def close(self):
|
||||
self.db.close()
|
||||
self.db = None
|
||||
|
||||
@property
|
||||
def closed(self) -> bool:
|
||||
return self.db is None
|
||||
|
||||
def try_catch_up_with_primary(self):
|
||||
self.db.try_catch_up_with_primary()
|
||||
|
||||
|
||||
class RocksDBWriteBatch:
|
||||
def __init__(self, db: rocksdb.DB, sync: bool = False, disable_wal: bool = False):
|
||||
self.batch = rocksdb.WriteBatch()
|
||||
self.db = db
|
||||
self.sync = sync
|
||||
self.disable_wal = disable_wal
|
||||
|
||||
def __enter__(self):
|
||||
return self.batch
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if not exc_val:
|
||||
self.db.write(self.batch, sync=self.sync, disable_wal=self.disable_wal)
|
||||
|
||||
|
||||
class RocksDBIterator:
|
||||
"""An iterator for RocksDB."""
|
||||
|
||||
__slots__ = [
|
||||
'start',
|
||||
'prefix',
|
||||
'stop',
|
||||
'iterator',
|
||||
'include_key',
|
||||
'include_value',
|
||||
'prev_k',
|
||||
'reverse',
|
||||
'include_start',
|
||||
'include_stop'
|
||||
]
|
||||
|
||||
def __init__(self, db: rocksdb.DB, prefix: bytes = None, start: bool = None, stop: bytes = None,
|
||||
include_key: bool = True, include_value: bool = True, reverse: bool = False,
|
||||
include_start: bool = True, include_stop: bool = False):
|
||||
assert (start is None and stop is None) or (prefix is None), 'cannot use start/stop and prefix'
|
||||
self.start = start
|
||||
self.prefix = prefix
|
||||
self.stop = stop
|
||||
self.iterator = db.iteritems() if not reverse else reversed(db.iteritems())
|
||||
if prefix is not None:
|
||||
self.iterator.seek(prefix)
|
||||
elif start is not None:
|
||||
self.iterator.seek(start)
|
||||
self.include_key = include_key
|
||||
self.include_value = include_value
|
||||
self.prev_k = None
|
||||
self.reverse = reverse
|
||||
self.include_start = include_start
|
||||
self.include_stop = include_stop
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def _check_stop_iteration(self, key: bytes):
|
||||
if self.stop is not None and (key.startswith(self.stop) or self.stop < key[:len(self.stop)]):
|
||||
raise StopIteration
|
||||
elif self.start is not None and self.start > key[:len(self.start)]:
|
||||
raise StopIteration
|
||||
elif self.prefix is not None and not key.startswith(self.prefix):
|
||||
raise StopIteration
|
||||
|
||||
def __next__(self):
|
||||
# TODO: include start/stop on/off
|
||||
# check for needing to stop from previous iteration
|
||||
if self.prev_k is not None:
|
||||
self._check_stop_iteration(self.prev_k)
|
||||
k, v = next(self.iterator)
|
||||
self._check_stop_iteration(k)
|
||||
self.prev_k = k
|
||||
|
||||
if self.include_key and self.include_value:
|
||||
return k, v
|
||||
elif self.include_key:
|
||||
return k
|
||||
return v
|
||||
|
||||
|
||||
class PrefixDB:
|
||||
UNDO_KEY_STRUCT = struct.Struct(b'>Q')
|
||||
|
||||
def __init__(self, db: RocksDBStore, max_undo_depth: int = 200, unsafe_prefixes=None):
|
||||
self._db = db
|
||||
self._op_stack = RevertableOpStack(db.get, unsafe_prefixes=unsafe_prefixes)
|
||||
self._max_undo_depth = max_undo_depth
|
||||
|
||||
def unsafe_commit(self):
|
||||
"""
|
||||
Write staged changes to the database without keeping undo information
|
||||
Changes written cannot be undone
|
||||
"""
|
||||
try:
|
||||
with self._db.write_batch(sync=True) as batch:
|
||||
batch_put = batch.put
|
||||
batch_delete = batch.delete
|
||||
for staged_change in self._op_stack:
|
||||
if staged_change.is_put:
|
||||
batch_put(staged_change.key, staged_change.value)
|
||||
else:
|
||||
batch_delete(staged_change.key)
|
||||
finally:
|
||||
self._op_stack.clear()
|
||||
|
||||
def commit(self, height: int):
|
||||
"""
|
||||
Write changes for a block height to the database and keep undo information so that the changes can be reverted
|
||||
"""
|
||||
undo_ops = self._op_stack.get_undo_ops()
|
||||
delete_undos = []
|
||||
if height > self._max_undo_depth:
|
||||
delete_undos.extend(self._db.iterator(
|
||||
start=DB_PREFIXES.undo.value + self.UNDO_KEY_STRUCT.pack(0),
|
||||
stop=DB_PREFIXES.undo.value + self.UNDO_KEY_STRUCT.pack(height - self._max_undo_depth),
|
||||
include_value=False
|
||||
))
|
||||
try:
|
||||
with self._db.write_batch(sync=True) as batch:
|
||||
batch_put = batch.put
|
||||
batch_delete = batch.delete
|
||||
for staged_change in self._op_stack:
|
||||
if staged_change.is_put:
|
||||
batch_put(staged_change.key, staged_change.value)
|
||||
else:
|
||||
batch_delete(staged_change.key)
|
||||
for undo_to_delete in delete_undos:
|
||||
batch_delete(undo_to_delete)
|
||||
batch_put(DB_PREFIXES.undo.value + self.UNDO_KEY_STRUCT.pack(height), undo_ops)
|
||||
finally:
|
||||
self._op_stack.clear()
|
||||
|
||||
def rollback(self, height: int):
|
||||
"""
|
||||
Revert changes for a block height
|
||||
"""
|
||||
undo_key = DB_PREFIXES.undo.value + self.UNDO_KEY_STRUCT.pack(height)
|
||||
self._op_stack.apply_packed_undo_ops(self._db.get(undo_key))
|
||||
try:
|
||||
with self._db.write_batch(sync=True) as batch:
|
||||
batch_put = batch.put
|
||||
batch_delete = batch.delete
|
||||
for staged_change in self._op_stack:
|
||||
if staged_change.is_put:
|
||||
batch_put(staged_change.key, staged_change.value)
|
||||
else:
|
||||
batch_delete(staged_change.key)
|
||||
batch_delete(undo_key)
|
||||
finally:
|
||||
self._op_stack.clear()
|
||||
|
||||
def get(self, key: bytes, fill_cache: bool = True) -> Optional[bytes]:
|
||||
return self._db.get(key, fill_cache=fill_cache)
|
||||
|
||||
def iterator(self, reverse=False, start=None, stop=None, include_start=True, include_stop=False, prefix=None,
|
||||
include_key=True, include_value=True, fill_cache=True):
|
||||
return self._db.iterator(
|
||||
reverse=reverse, start=start, stop=stop, include_start=include_start, include_stop=include_stop,
|
||||
prefix=prefix, include_key=include_key, include_value=include_value, fill_cache=fill_cache
|
||||
)
|
||||
|
||||
def close(self):
|
||||
if not self._db.closed:
|
||||
self._db.close()
|
||||
|
||||
def try_catch_up_with_primary(self):
|
||||
self._db.try_catch_up_with_primary()
|
||||
|
||||
@property
|
||||
def closed(self):
|
||||
return self._db.closed
|
||||
|
||||
def stage_raw_put(self, key: bytes, value: bytes):
|
||||
self._op_stack.append_op(RevertablePut(key, value))
|
||||
|
||||
def stage_raw_delete(self, key: bytes, value: bytes):
|
||||
self._op_stack.append_op(RevertableDelete(key, value))
|
||||
@@ -8,7 +8,7 @@ INDEX_DEFAULT_SETTINGS = {
|
||||
"number_of_shards": 1,
|
||||
"number_of_replicas": 0,
|
||||
"sort": {
|
||||
"field": ["trending_score", "release_time"],
|
||||
"field": ["trending_mixed", "release_time"],
|
||||
"order": ["desc", "desc"]
|
||||
}}
|
||||
},
|
||||
@@ -30,8 +30,8 @@ INDEX_DEFAULT_SETTINGS = {
|
||||
"height": {"type": "integer"},
|
||||
"claim_type": {"type": "byte"},
|
||||
"censor_type": {"type": "byte"},
|
||||
"trending_score": {"type": "double"},
|
||||
"release_time": {"type": "long"}
|
||||
"trending_mixed": {"type": "float"},
|
||||
"release_time": {"type": "long"},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,32 +53,26 @@ FIELDS = {
|
||||
'duration', 'release_time',
|
||||
'tags', 'languages', 'has_source', 'reposted_claim_type',
|
||||
'reposted_claim_id', 'repost_count',
|
||||
'trending_score', 'tx_num'
|
||||
'trending_group', 'trending_mixed', 'trending_local', 'trending_global',
|
||||
}
|
||||
|
||||
TEXT_FIELDS = {'author', 'canonical_url', 'channel_id', 'description', 'claim_id', 'censoring_channel_id',
|
||||
TEXT_FIELDS = {'author', 'canonical_url', 'channel_id', 'claim_name', 'description', 'claim_id', 'censoring_channel_id',
|
||||
'media_type', 'normalized_name', 'public_key_bytes', 'public_key_id', 'short_url', 'signature',
|
||||
'claim_name', 'signature_digest', 'title', 'tx_id', 'fee_currency', 'reposted_claim_id',
|
||||
'tags'}
|
||||
'signature_digest', 'stream_type', 'title', 'tx_id', 'fee_currency', 'reposted_claim_id', 'tags'}
|
||||
|
||||
RANGE_FIELDS = {
|
||||
'height', 'creation_height', 'activation_height', 'expiration_height',
|
||||
'timestamp', 'creation_timestamp', 'duration', 'release_time', 'fee_amount',
|
||||
'tx_position', 'channel_join', 'repost_count', 'limit_claims_per_channel',
|
||||
'amount', 'effective_amount', 'support_amount',
|
||||
'trending_score', 'censor_type', 'tx_num'
|
||||
'trending_group', 'trending_mixed', 'censor_type',
|
||||
'trending_local', 'trending_global',
|
||||
}
|
||||
|
||||
ALL_FIELDS = RANGE_FIELDS | TEXT_FIELDS | FIELDS
|
||||
|
||||
REPLACEMENTS = {
|
||||
'claim_name': 'normalized_name',
|
||||
'name': 'normalized_name',
|
||||
'txid': 'tx_id',
|
||||
'nout': 'tx_nout',
|
||||
'trending_mixed': 'trending_score',
|
||||
'reposted': 'repost_count',
|
||||
'stream_types': 'stream_type',
|
||||
'media_types': 'media_type',
|
||||
'valid_channel_signature': 'is_signature_valid'
|
||||
'reposted': 'repost_count'
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import time
|
||||
import asyncio
|
||||
import struct
|
||||
from binascii import unhexlify
|
||||
@@ -9,6 +8,8 @@ from typing import Optional, List, Iterable, Union
|
||||
|
||||
from elasticsearch import AsyncElasticsearch, NotFoundError, ConnectionError
|
||||
from elasticsearch.helpers import async_streaming_bulk
|
||||
|
||||
from lbry.crypto.base58 import Base58
|
||||
from lbry.error import ResolveCensoredError, TooManyClaimSearchParametersError
|
||||
from lbry.schema.result import Outputs, Censor
|
||||
from lbry.schema.tags import clean_tags
|
||||
@@ -18,7 +19,6 @@ from lbry.wallet.server.db.common import CLAIM_TYPES, STREAM_TYPES
|
||||
from lbry.wallet.server.db.elasticsearch.constants import INDEX_DEFAULT_SETTINGS, REPLACEMENTS, FIELDS, TEXT_FIELDS, \
|
||||
RANGE_FIELDS, ALL_FIELDS
|
||||
from lbry.wallet.server.util import class_logger
|
||||
from lbry.wallet.server.db.common import ResolveResult
|
||||
|
||||
|
||||
class ChannelResolution(str):
|
||||
@@ -50,7 +50,9 @@ class SearchIndex:
|
||||
self.index = index_prefix + 'claims'
|
||||
self.logger = class_logger(__name__, self.__class__.__name__)
|
||||
self.claim_cache = LRUCache(2 ** 15)
|
||||
self.short_id_cache = LRUCache(2 ** 17)
|
||||
self.search_cache = LRUCache(2 ** 17)
|
||||
self.resolution_cache = LRUCache(2 ** 17)
|
||||
self._elastic_host = elastic_host
|
||||
self._elastic_port = elastic_port
|
||||
|
||||
@@ -89,7 +91,6 @@ class SearchIndex:
|
||||
if index_version != self.VERSION:
|
||||
self.logger.error("es search index has an incompatible version: %s vs %s", index_version, self.VERSION)
|
||||
raise IndexVersionMismatch(index_version, self.VERSION)
|
||||
await self.sync_client.indices.refresh(self.index)
|
||||
return acked
|
||||
|
||||
def stop(self):
|
||||
@@ -102,28 +103,15 @@ class SearchIndex:
|
||||
|
||||
async def _consume_claim_producer(self, claim_producer):
|
||||
count = 0
|
||||
async for op, doc in claim_producer:
|
||||
for op, doc in claim_producer:
|
||||
if op == 'delete':
|
||||
yield {
|
||||
'_index': self.index,
|
||||
'_op_type': 'delete',
|
||||
'_id': doc
|
||||
}
|
||||
yield {'_index': self.index, '_op_type': 'delete', '_id': doc}
|
||||
else:
|
||||
yield {
|
||||
'doc': {key: value for key, value in doc.items() if key in ALL_FIELDS},
|
||||
'_id': doc['claim_id'],
|
||||
'_index': self.index,
|
||||
'_op_type': 'update',
|
||||
'doc_as_upsert': True
|
||||
}
|
||||
yield extract_doc(doc, self.index)
|
||||
count += 1
|
||||
if count % 100 == 0:
|
||||
self.logger.info("Indexing in progress, %d claims.", count)
|
||||
if count:
|
||||
self.logger.info("Indexing done for %d claims.", count)
|
||||
else:
|
||||
self.logger.debug("Indexing done for %d claims.", count)
|
||||
self.logger.info("Indexing done for %d claims.", count)
|
||||
|
||||
async def claim_consumer(self, claim_producer):
|
||||
touched = set()
|
||||
@@ -135,170 +123,22 @@ class SearchIndex:
|
||||
item = item.popitem()[1]
|
||||
touched.add(item['_id'])
|
||||
await self.sync_client.indices.refresh(self.index)
|
||||
self.logger.debug("Indexing done.")
|
||||
self.logger.info("Indexing done.")
|
||||
|
||||
def update_filter_query(self, censor_type, blockdict, channels=False):
|
||||
blockdict = {blocked.hex(): blocker.hex() for blocked, blocker in blockdict.items()}
|
||||
blockdict = {key[::-1].hex(): value[::-1].hex() for key, value in blockdict.items()}
|
||||
if channels:
|
||||
update = expand_query(channel_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
|
||||
else:
|
||||
update = expand_query(claim_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
|
||||
key = 'channel_id' if channels else 'claim_id'
|
||||
update['script'] = {
|
||||
"source": f"ctx._source.censor_type={censor_type}; "
|
||||
f"ctx._source.censoring_channel_id=params[ctx._source.{key}];",
|
||||
"source": f"ctx._source.censor_type={censor_type}; ctx._source.censoring_channel_id=params[ctx._source.{key}]",
|
||||
"lang": "painless",
|
||||
"params": blockdict
|
||||
}
|
||||
return update
|
||||
|
||||
async def update_trending_score(self, params):
|
||||
update_trending_score_script = """
|
||||
double softenLBC(double lbc) { return (Math.pow(lbc, 1.0 / 3.0)); }
|
||||
|
||||
double logsumexp(double x, double y)
|
||||
{
|
||||
double top;
|
||||
if(x > y)
|
||||
top = x;
|
||||
else
|
||||
top = y;
|
||||
double result = top + Math.log(Math.exp(x-top) + Math.exp(y-top));
|
||||
return(result);
|
||||
}
|
||||
|
||||
double logdiffexp(double big, double small)
|
||||
{
|
||||
return big + Math.log(1.0 - Math.exp(small - big));
|
||||
}
|
||||
|
||||
double squash(double x)
|
||||
{
|
||||
if(x < 0.0)
|
||||
return -Math.log(1.0 - x);
|
||||
else
|
||||
return Math.log(x + 1.0);
|
||||
}
|
||||
|
||||
double unsquash(double x)
|
||||
{
|
||||
if(x < 0.0)
|
||||
return 1.0 - Math.exp(-x);
|
||||
else
|
||||
return Math.exp(x) - 1.0;
|
||||
}
|
||||
|
||||
double log_to_squash(double x)
|
||||
{
|
||||
return logsumexp(x, 0.0);
|
||||
}
|
||||
|
||||
double squash_to_log(double x)
|
||||
{
|
||||
//assert x > 0.0;
|
||||
return logdiffexp(x, 0.0);
|
||||
}
|
||||
|
||||
double squashed_add(double x, double y)
|
||||
{
|
||||
// squash(unsquash(x) + unsquash(y)) but avoiding overflow.
|
||||
// Cases where the signs are the same
|
||||
if (x < 0.0 && y < 0.0)
|
||||
return -logsumexp(-x, logdiffexp(-y, 0.0));
|
||||
if (x >= 0.0 && y >= 0.0)
|
||||
return logsumexp(x, logdiffexp(y, 0.0));
|
||||
// Where the signs differ
|
||||
if (x >= 0.0 && y < 0.0)
|
||||
if (Math.abs(x) >= Math.abs(y))
|
||||
return logsumexp(0.0, logdiffexp(x, -y));
|
||||
else
|
||||
return -logsumexp(0.0, logdiffexp(-y, x));
|
||||
if (x < 0.0 && y >= 0.0)
|
||||
{
|
||||
// Addition is commutative, hooray for new math
|
||||
return squashed_add(y, x);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double squashed_multiply(double x, double y)
|
||||
{
|
||||
// squash(unsquash(x)*unsquash(y)) but avoiding overflow.
|
||||
int sign;
|
||||
if(x*y >= 0.0)
|
||||
sign = 1;
|
||||
else
|
||||
sign = -1;
|
||||
return sign*logsumexp(squash_to_log(Math.abs(x))
|
||||
+ squash_to_log(Math.abs(y)), 0.0);
|
||||
}
|
||||
|
||||
// Squashed inflated units
|
||||
double inflateUnits(int height) {
|
||||
double timescale = 576.0; // Half life of 400 = e-folding time of a day
|
||||
// by coincidence, so may as well go with it
|
||||
return log_to_squash(height / timescale);
|
||||
}
|
||||
|
||||
double spikePower(double newAmount) {
|
||||
if (newAmount < 50.0) {
|
||||
return(0.5);
|
||||
} else if (newAmount < 85.0) {
|
||||
return(newAmount / 100.0);
|
||||
} else {
|
||||
return(0.85);
|
||||
}
|
||||
}
|
||||
|
||||
double spikeMass(double oldAmount, double newAmount) {
|
||||
double softenedChange = softenLBC(Math.abs(newAmount - oldAmount));
|
||||
double changeInSoftened = Math.abs(softenLBC(newAmount) - softenLBC(oldAmount));
|
||||
double power = spikePower(newAmount);
|
||||
if (oldAmount > newAmount) {
|
||||
-1.0 * Math.pow(changeInSoftened, power) * Math.pow(softenedChange, 1.0 - power)
|
||||
} else {
|
||||
Math.pow(changeInSoftened, power) * Math.pow(softenedChange, 1.0 - power)
|
||||
}
|
||||
}
|
||||
for (i in params.src.changes) {
|
||||
double units = inflateUnits(i.height);
|
||||
if (ctx._source.trending_score == null) {
|
||||
ctx._source.trending_score = 0.0;
|
||||
}
|
||||
double bigSpike = squashed_multiply(units, squash(spikeMass(i.prev_amount, i.new_amount)));
|
||||
ctx._source.trending_score = squashed_add(ctx._source.trending_score, bigSpike);
|
||||
}
|
||||
"""
|
||||
start = time.perf_counter()
|
||||
|
||||
def producer():
|
||||
for claim_id, claim_updates in params.items():
|
||||
yield {
|
||||
'_id': claim_id,
|
||||
'_index': self.index,
|
||||
'_op_type': 'update',
|
||||
'script': {
|
||||
'lang': 'painless',
|
||||
'source': update_trending_score_script,
|
||||
'params': {'src': {
|
||||
'changes': [
|
||||
{
|
||||
'height': p.height,
|
||||
'prev_amount': p.prev_amount / 1E8,
|
||||
'new_amount': p.new_amount / 1E8,
|
||||
} for p in claim_updates
|
||||
]
|
||||
}}
|
||||
},
|
||||
}
|
||||
if not params:
|
||||
return
|
||||
async for ok, item in async_streaming_bulk(self.sync_client, producer(), raise_on_error=False):
|
||||
if not ok:
|
||||
self.logger.warning("updating trending failed for an item: %s", item)
|
||||
await self.sync_client.indices.refresh(self.index)
|
||||
self.logger.info("updated trending scores in %ims", int((time.perf_counter() - start) * 1000))
|
||||
|
||||
async def apply_filters(self, blocked_streams, blocked_channels, filtered_streams, filtered_channels):
|
||||
if filtered_streams:
|
||||
await self.sync_client.update_by_query(
|
||||
@@ -326,84 +166,56 @@ class SearchIndex:
|
||||
|
||||
def clear_caches(self):
|
||||
self.search_cache.clear()
|
||||
self.short_id_cache.clear()
|
||||
self.claim_cache.clear()
|
||||
self.resolution_cache.clear()
|
||||
|
||||
async def cached_search(self, kwargs):
|
||||
async def session_query(self, query_name, kwargs):
|
||||
offset, total = kwargs.get('offset', 0) if isinstance(kwargs, dict) else 0, 0
|
||||
total_referenced = []
|
||||
cache_item = ResultCacheItem.from_cache(str(kwargs), self.search_cache)
|
||||
if cache_item.result is not None:
|
||||
return cache_item.result
|
||||
async with cache_item.lock:
|
||||
if cache_item.result:
|
||||
if query_name == 'resolve':
|
||||
total_referenced, response, censor = await self.resolve(*kwargs)
|
||||
else:
|
||||
cache_item = ResultCacheItem.from_cache(str(kwargs), self.search_cache)
|
||||
if cache_item.result is not None:
|
||||
return cache_item.result
|
||||
censor = Censor(Censor.SEARCH)
|
||||
if kwargs.get('no_totals'):
|
||||
response, offset, total = await self.search(**kwargs, censor_type=Censor.NOT_CENSORED)
|
||||
else:
|
||||
response, offset, total = await self.search(**kwargs)
|
||||
censor.apply(response)
|
||||
total_referenced.extend(response)
|
||||
|
||||
if censor.censored:
|
||||
response, _, _ = await self.search(**kwargs, censor_type=Censor.NOT_CENSORED)
|
||||
async with cache_item.lock:
|
||||
if cache_item.result:
|
||||
return cache_item.result
|
||||
censor = Censor(Censor.SEARCH)
|
||||
if kwargs.get('no_totals'):
|
||||
response, offset, total = await self.search(**kwargs, censor_type=Censor.NOT_CENSORED)
|
||||
else:
|
||||
response, offset, total = await self.search(**kwargs)
|
||||
censor.apply(response)
|
||||
total_referenced.extend(response)
|
||||
response = [
|
||||
ResolveResult(
|
||||
name=r['claim_name'],
|
||||
normalized_name=r['normalized_name'],
|
||||
claim_hash=r['claim_hash'],
|
||||
tx_num=r['tx_num'],
|
||||
position=r['tx_nout'],
|
||||
tx_hash=r['tx_hash'],
|
||||
height=r['height'],
|
||||
amount=r['amount'],
|
||||
short_url=r['short_url'],
|
||||
is_controlling=r['is_controlling'],
|
||||
canonical_url=r['canonical_url'],
|
||||
creation_height=r['creation_height'],
|
||||
activation_height=r['activation_height'],
|
||||
expiration_height=r['expiration_height'],
|
||||
effective_amount=r['effective_amount'],
|
||||
support_amount=r['support_amount'],
|
||||
last_takeover_height=r['last_take_over_height'],
|
||||
claims_in_channel=r['claims_in_channel'],
|
||||
channel_hash=r['channel_hash'],
|
||||
reposted_claim_hash=r['reposted_claim_hash'],
|
||||
reposted=r['reposted'],
|
||||
signature_valid=r['signature_valid']
|
||||
) for r in response
|
||||
]
|
||||
extra = [
|
||||
ResolveResult(
|
||||
name=r['claim_name'],
|
||||
normalized_name=r['normalized_name'],
|
||||
claim_hash=r['claim_hash'],
|
||||
tx_num=r['tx_num'],
|
||||
position=r['tx_nout'],
|
||||
tx_hash=r['tx_hash'],
|
||||
height=r['height'],
|
||||
amount=r['amount'],
|
||||
short_url=r['short_url'],
|
||||
is_controlling=r['is_controlling'],
|
||||
canonical_url=r['canonical_url'],
|
||||
creation_height=r['creation_height'],
|
||||
activation_height=r['activation_height'],
|
||||
expiration_height=r['expiration_height'],
|
||||
effective_amount=r['effective_amount'],
|
||||
support_amount=r['support_amount'],
|
||||
last_takeover_height=r['last_take_over_height'],
|
||||
claims_in_channel=r['claims_in_channel'],
|
||||
channel_hash=r['channel_hash'],
|
||||
reposted_claim_hash=r['reposted_claim_hash'],
|
||||
reposted=r['reposted'],
|
||||
signature_valid=r['signature_valid']
|
||||
) for r in await self._get_referenced_rows(total_referenced)
|
||||
]
|
||||
result = Outputs.to_base64(
|
||||
response, extra, offset, total, censor
|
||||
)
|
||||
cache_item.result = result
|
||||
return result
|
||||
if censor.censored:
|
||||
response, _, _ = await self.search(**kwargs, censor_type=Censor.NOT_CENSORED)
|
||||
total_referenced.extend(response)
|
||||
result = Outputs.to_base64(
|
||||
response, await self._get_referenced_rows(total_referenced), offset, total, censor
|
||||
)
|
||||
cache_item.result = result
|
||||
return result
|
||||
return Outputs.to_base64(response, await self._get_referenced_rows(total_referenced), offset, total, censor)
|
||||
|
||||
async def resolve(self, *urls):
|
||||
censor = Censor(Censor.RESOLVE)
|
||||
results = [await self.resolve_url(url) for url in urls]
|
||||
# just heat the cache
|
||||
await self.populate_claim_cache(*filter(lambda x: isinstance(x, str), results))
|
||||
results = [self._get_from_cache_or_error(url, result) for url, result in zip(urls, results)]
|
||||
|
||||
censored = [
|
||||
result if not isinstance(result, dict) or not censor.censor(result)
|
||||
else ResolveCensoredError(url, result['censoring_channel_id'])
|
||||
for url, result in zip(urls, results)
|
||||
]
|
||||
return results, censored, censor
|
||||
|
||||
def _get_from_cache_or_error(self, url: str, resolution: Union[LookupError, StreamResolution, ChannelResolution]):
|
||||
cached = self.claim_cache.get(resolution)
|
||||
return cached or (resolution if isinstance(resolution, LookupError) else resolution.lookup_error(url))
|
||||
|
||||
async def get_many(self, *claim_ids):
|
||||
await self.populate_claim_cache(*claim_ids)
|
||||
@@ -418,13 +230,32 @@ class SearchIndex:
|
||||
for result in expand_result(filter(lambda doc: doc['found'], results["docs"])):
|
||||
self.claim_cache.set(result['claim_id'], result)
|
||||
|
||||
async def full_id_from_short_id(self, name, short_id, channel_id=None):
|
||||
key = '#'.join((channel_id or '', name, short_id))
|
||||
if key not in self.short_id_cache:
|
||||
query = {'name': name, 'claim_id': short_id}
|
||||
if channel_id:
|
||||
query['channel_id'] = channel_id
|
||||
query['order_by'] = ['^channel_join']
|
||||
query['signature_valid'] = True
|
||||
else:
|
||||
query['order_by'] = '^creation_height'
|
||||
result, _, _ = await self.search(**query, limit=1)
|
||||
if len(result) == 1:
|
||||
result = result[0]['claim_id']
|
||||
self.short_id_cache[key] = result
|
||||
return self.short_id_cache.get(key, None)
|
||||
|
||||
async def search(self, **kwargs):
|
||||
if 'channel' in kwargs:
|
||||
kwargs['channel_id'] = await self.resolve_url(kwargs.pop('channel'))
|
||||
if not kwargs['channel_id'] or not isinstance(kwargs['channel_id'], str):
|
||||
return [], 0, 0
|
||||
try:
|
||||
return await self.search_ahead(**kwargs)
|
||||
except NotFoundError:
|
||||
return [], 0, 0
|
||||
# return expand_result(result['hits']), 0, result.get('total', {}).get('value', 0)
|
||||
return expand_result(result['hits']), 0, result.get('total', {}).get('value', 0)
|
||||
|
||||
async def search_ahead(self, **kwargs):
|
||||
# 'limit_claims_per_channel' case. Fetch 1000 results, reorder, slice, inflate and return
|
||||
@@ -504,6 +335,78 @@ class SearchIndex:
|
||||
next_page_hits_maybe_check_later.append((hit_id, hit_channel_id))
|
||||
return reordered_hits
|
||||
|
||||
async def resolve_url(self, raw_url):
|
||||
if raw_url not in self.resolution_cache:
|
||||
self.resolution_cache[raw_url] = await self._resolve_url(raw_url)
|
||||
return self.resolution_cache[raw_url]
|
||||
|
||||
async def _resolve_url(self, raw_url):
|
||||
try:
|
||||
url = URL.parse(raw_url)
|
||||
except ValueError as e:
|
||||
return e
|
||||
|
||||
stream = LookupError(f'Could not find claim at "{raw_url}".')
|
||||
|
||||
channel_id = await self.resolve_channel_id(url)
|
||||
if isinstance(channel_id, LookupError):
|
||||
return channel_id
|
||||
stream = (await self.resolve_stream(url, channel_id if isinstance(channel_id, str) else None)) or stream
|
||||
if url.has_stream:
|
||||
return StreamResolution(stream)
|
||||
else:
|
||||
return ChannelResolution(channel_id)
|
||||
|
||||
async def resolve_channel_id(self, url: URL):
|
||||
if not url.has_channel:
|
||||
return
|
||||
if url.channel.is_fullid:
|
||||
return url.channel.claim_id
|
||||
if url.channel.is_shortid:
|
||||
channel_id = await self.full_id_from_short_id(url.channel.name, url.channel.claim_id)
|
||||
if not channel_id:
|
||||
return LookupError(f'Could not find channel in "{url}".')
|
||||
return channel_id
|
||||
|
||||
query = url.channel.to_dict()
|
||||
if set(query) == {'name'}:
|
||||
query['is_controlling'] = True
|
||||
else:
|
||||
query['order_by'] = ['^creation_height']
|
||||
matches, _, _ = await self.search(**query, limit=1)
|
||||
if matches:
|
||||
channel_id = matches[0]['claim_id']
|
||||
else:
|
||||
return LookupError(f'Could not find channel in "{url}".')
|
||||
return channel_id
|
||||
|
||||
async def resolve_stream(self, url: URL, channel_id: str = None):
|
||||
if not url.has_stream:
|
||||
return None
|
||||
if url.has_channel and channel_id is None:
|
||||
return None
|
||||
query = url.stream.to_dict()
|
||||
if url.stream.claim_id is not None:
|
||||
if url.stream.is_fullid:
|
||||
claim_id = url.stream.claim_id
|
||||
else:
|
||||
claim_id = await self.full_id_from_short_id(query['name'], query['claim_id'], channel_id)
|
||||
return claim_id
|
||||
|
||||
if channel_id is not None:
|
||||
if set(query) == {'name'}:
|
||||
# temporarily emulate is_controlling for claims in channel
|
||||
query['order_by'] = ['effective_amount', '^height']
|
||||
else:
|
||||
query['order_by'] = ['^channel_join']
|
||||
query['channel_id'] = channel_id
|
||||
query['signature_valid'] = True
|
||||
elif set(query) == {'name'}:
|
||||
query['is_controlling'] = True
|
||||
matches, _, _ = await self.search(**query, limit=1)
|
||||
if matches:
|
||||
return matches[0]['claim_id']
|
||||
|
||||
async def _get_referenced_rows(self, txo_rows: List[dict]):
|
||||
txo_rows = [row for row in txo_rows if isinstance(row, dict)]
|
||||
referenced_ids = set(filter(None, map(itemgetter('reposted_claim_id'), txo_rows)))
|
||||
@@ -521,6 +424,33 @@ class SearchIndex:
|
||||
return referenced_txos
|
||||
|
||||
|
||||
def extract_doc(doc, index):
|
||||
doc['claim_id'] = doc.pop('claim_hash')[::-1].hex()
|
||||
if doc['reposted_claim_hash'] is not None:
|
||||
doc['reposted_claim_id'] = doc.pop('reposted_claim_hash')[::-1].hex()
|
||||
else:
|
||||
doc['reposted_claim_id'] = None
|
||||
channel_hash = doc.pop('channel_hash')
|
||||
doc['channel_id'] = channel_hash[::-1].hex() if channel_hash else channel_hash
|
||||
doc['censoring_channel_id'] = doc.get('censoring_channel_id')
|
||||
txo_hash = doc.pop('txo_hash')
|
||||
doc['tx_id'] = txo_hash[:32][::-1].hex()
|
||||
doc['tx_nout'] = struct.unpack('<I', txo_hash[32:])[0]
|
||||
doc['repost_count'] = doc.pop('reposted')
|
||||
doc['is_controlling'] = bool(doc['is_controlling'])
|
||||
doc['signature'] = (doc.pop('signature') or b'').hex() or None
|
||||
doc['signature_digest'] = (doc.pop('signature_digest') or b'').hex() or None
|
||||
doc['public_key_bytes'] = (doc.pop('public_key_bytes') or b'').hex() or None
|
||||
doc['public_key_id'] = (doc.pop('public_key_hash') or b'').hex() or None
|
||||
doc['is_signature_valid'] = bool(doc['signature_valid'])
|
||||
doc['claim_type'] = doc.get('claim_type', 0) or 0
|
||||
doc['stream_type'] = int(doc.get('stream_type', 0) or 0)
|
||||
doc['has_source'] = bool(doc['has_source'])
|
||||
doc['normalized_name'] = doc.pop('normalized')
|
||||
doc = {key: value for key, value in doc.items() if key in ALL_FIELDS}
|
||||
return {'doc': doc, '_id': doc['claim_id'], '_index': index, '_op_type': 'update', 'doc_as_upsert': True}
|
||||
|
||||
|
||||
def expand_query(**kwargs):
|
||||
if "amount_order" in kwargs:
|
||||
kwargs["limit"] = 1
|
||||
@@ -532,8 +462,6 @@ def expand_query(**kwargs):
|
||||
kwargs.pop('is_controlling')
|
||||
query = {'must': [], 'must_not': []}
|
||||
collapse = None
|
||||
if 'fee_currency' in kwargs and kwargs['fee_currency'] is not None:
|
||||
kwargs['fee_currency'] = kwargs['fee_currency'].upper()
|
||||
for key, value in kwargs.items():
|
||||
key = key.replace('claim.', '')
|
||||
many = key.endswith('__in') or isinstance(value, list)
|
||||
@@ -552,8 +480,6 @@ def expand_query(**kwargs):
|
||||
value = CLAIM_TYPES[value]
|
||||
else:
|
||||
value = [CLAIM_TYPES[claim_type] for claim_type in value]
|
||||
elif key == 'stream_type':
|
||||
value = [STREAM_TYPES[value]] if isinstance(value, str) else list(map(STREAM_TYPES.get, value))
|
||||
if key == '_id':
|
||||
if isinstance(value, Iterable):
|
||||
value = [item[::-1].hex() for item in value]
|
||||
@@ -561,6 +487,8 @@ def expand_query(**kwargs):
|
||||
value = value[::-1].hex()
|
||||
if not many and key in ('_id', 'claim_id') and len(value) < 20:
|
||||
partial_id = True
|
||||
if key == 'public_key_id':
|
||||
value = Base58.decode(value)[1:21].hex()
|
||||
if key in ('signature_valid', 'has_source'):
|
||||
continue # handled later
|
||||
if key in TEXT_FIELDS:
|
||||
@@ -590,6 +518,8 @@ def expand_query(**kwargs):
|
||||
query['must'].append({"terms": {'claim_id.keyword': value}})
|
||||
elif key == 'media_types':
|
||||
query['must'].append({"terms": {'media_type.keyword': value}})
|
||||
elif key == 'stream_types':
|
||||
query['must'].append({"terms": {'stream_type': [STREAM_TYPES[stype] for stype in value]}})
|
||||
elif key == 'any_languages':
|
||||
query['must'].append({"terms": {'languages': clean_tags(value)}})
|
||||
elif key == 'any_languages':
|
||||
@@ -607,13 +537,13 @@ def expand_query(**kwargs):
|
||||
elif key == 'limit_claims_per_channel':
|
||||
collapse = ('channel_id.keyword', value)
|
||||
if kwargs.get('has_channel_signature'):
|
||||
query['must'].append({"exists": {"field": "signature"}})
|
||||
query['must'].append({"exists": {"field": "signature_digest"}})
|
||||
if 'signature_valid' in kwargs:
|
||||
query['must'].append({"term": {"is_signature_valid": bool(kwargs["signature_valid"])}})
|
||||
elif 'signature_valid' in kwargs:
|
||||
query.setdefault('should', [])
|
||||
query["minimum_should_match"] = 1
|
||||
query['should'].append({"bool": {"must_not": {"exists": {"field": "signature"}}}})
|
||||
query['should'].append({"bool": {"must_not": {"exists": {"field": "signature_digest"}}}})
|
||||
query['should'].append({"term": {"is_signature_valid": bool(kwargs["signature_valid"])}})
|
||||
if 'has_source' in kwargs:
|
||||
query.setdefault('should', [])
|
||||
@@ -682,9 +612,7 @@ def expand_result(results):
|
||||
result['tx_hash'] = unhexlify(result['tx_id'])[::-1]
|
||||
result['reposted'] = result.pop('repost_count')
|
||||
result['signature_valid'] = result.pop('is_signature_valid')
|
||||
# result['normalized'] = result.pop('normalized_name')
|
||||
# if result['censoring_channel_hash']:
|
||||
# result['censoring_channel_hash'] = unhexlify(result['censoring_channel_hash'])[::-1]
|
||||
result['normalized'] = result.pop('normalized_name')
|
||||
expanded.append(result)
|
||||
if inner_hits:
|
||||
return expand_result(inner_hits)
|
||||
|
||||
@@ -1,119 +1,100 @@
|
||||
import os
|
||||
import argparse
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
from collections import namedtuple
|
||||
from multiprocessing import Process
|
||||
|
||||
import sqlite3
|
||||
from elasticsearch import AsyncElasticsearch
|
||||
from elasticsearch.helpers import async_streaming_bulk
|
||||
from elasticsearch.helpers import async_bulk
|
||||
from lbry.wallet.server.env import Env
|
||||
from lbry.wallet.server.leveldb import LevelDB
|
||||
from lbry.wallet.server.db.elasticsearch.search import SearchIndex, IndexVersionMismatch
|
||||
from lbry.wallet.server.db.elasticsearch.constants import ALL_FIELDS
|
||||
from lbry.wallet.server.coin import LBC
|
||||
from lbry.wallet.server.db.elasticsearch.search import extract_doc, SearchIndex, IndexVersionMismatch
|
||||
|
||||
|
||||
async def get_recent_claims(env, index_name='claims', db=None):
|
||||
need_open = db is None
|
||||
db = db or LevelDB(env)
|
||||
try:
|
||||
if need_open:
|
||||
db.open_db()
|
||||
if db.es_sync_height == db.db_height or db.db_height <= 0:
|
||||
return
|
||||
if need_open:
|
||||
await db.initialize_caches()
|
||||
cnt = 0
|
||||
touched_claims = set()
|
||||
deleted_claims = set()
|
||||
for height in range(db.es_sync_height, db.db_height + 1):
|
||||
touched_or_deleted = db.prefix_db.touched_or_deleted.get(height)
|
||||
touched_claims.update(touched_or_deleted.touched_claims)
|
||||
deleted_claims.update(touched_or_deleted.deleted_claims)
|
||||
touched_claims.difference_update(deleted_claims)
|
||||
async def get_all(db, shard_num, shards_total, limit=0, index_name='claims'):
|
||||
logging.info("shard %d starting", shard_num)
|
||||
|
||||
for deleted in deleted_claims:
|
||||
yield {
|
||||
'_index': index_name,
|
||||
'_op_type': 'delete',
|
||||
'_id': deleted.hex()
|
||||
}
|
||||
for touched in touched_claims:
|
||||
claim = db.claim_producer(touched)
|
||||
if claim:
|
||||
yield {
|
||||
'doc': {key: value for key, value in claim.items() if key in ALL_FIELDS},
|
||||
'_id': claim['claim_id'],
|
||||
'_index': index_name,
|
||||
'_op_type': 'update',
|
||||
'doc_as_upsert': True
|
||||
}
|
||||
cnt += 1
|
||||
else:
|
||||
logging.warning("could not sync claim %s", touched.hex())
|
||||
if cnt % 10000 == 0:
|
||||
logging.info("%i claims sent to ES", cnt)
|
||||
|
||||
db.es_sync_height = db.db_height
|
||||
db.write_db_state()
|
||||
db.prefix_db.unsafe_commit()
|
||||
db.assert_db_state()
|
||||
|
||||
logging.info("finished sending %i claims to ES, deleted %i", cnt, len(deleted_claims))
|
||||
finally:
|
||||
if need_open:
|
||||
db.close()
|
||||
def namedtuple_factory(cursor, row):
|
||||
Row = namedtuple('Row', (d[0] for d in cursor.description))
|
||||
return Row(*row)
|
||||
db.row_factory = namedtuple_factory
|
||||
total = db.execute(f"select count(*) as total from claim where height % {shards_total} = {shard_num};").fetchone()[0]
|
||||
for num, claim in enumerate(db.execute(f"""
|
||||
SELECT claimtrie.claim_hash as is_controlling,
|
||||
claimtrie.last_take_over_height,
|
||||
(select group_concat(tag, ',,') from tag where tag.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as tags,
|
||||
(select group_concat(language, ' ') from language where language.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as languages,
|
||||
cr.has_source as reposted_has_source,
|
||||
cr.claim_type as reposted_claim_type,
|
||||
cr.stream_type as reposted_stream_type,
|
||||
cr.media_type as reposted_media_type,
|
||||
cr.duration as reposted_duration,
|
||||
cr.fee_amount as reposted_fee_amount,
|
||||
cr.fee_currency as reposted_fee_currency,
|
||||
claim.*
|
||||
FROM claim LEFT JOIN claimtrie USING (claim_hash) LEFT JOIN claim cr ON cr.claim_hash=claim.reposted_claim_hash
|
||||
WHERE claim.height % {shards_total} = {shard_num}
|
||||
ORDER BY claim.height desc
|
||||
""")):
|
||||
claim = dict(claim._asdict())
|
||||
claim['has_source'] = bool(claim.pop('reposted_has_source') or claim['has_source'])
|
||||
claim['stream_type'] = claim.pop('reposted_stream_type') or claim['stream_type']
|
||||
claim['media_type'] = claim.pop('reposted_media_type') or claim['media_type']
|
||||
claim['fee_amount'] = claim.pop('reposted_fee_amount') or claim['fee_amount']
|
||||
claim['fee_currency'] = claim.pop('reposted_fee_currency') or claim['fee_currency']
|
||||
claim['duration'] = claim.pop('reposted_duration') or claim['duration']
|
||||
claim['censor_type'] = 0
|
||||
claim['censoring_channel_id'] = None
|
||||
claim['tags'] = claim['tags'].split(',,') if claim['tags'] else []
|
||||
claim['languages'] = claim['languages'].split(' ') if claim['languages'] else []
|
||||
if num % 10_000 == 0:
|
||||
logging.info("%d/%d", num, total)
|
||||
yield extract_doc(claim, index_name)
|
||||
if 0 < limit <= num:
|
||||
break
|
||||
|
||||
|
||||
async def get_all_claims(env, index_name='claims', db=None):
|
||||
need_open = db is None
|
||||
db = db or LevelDB(env)
|
||||
if need_open:
|
||||
db.open_db()
|
||||
await db.initialize_caches()
|
||||
logging.info("Fetching claims to send ES from leveldb")
|
||||
try:
|
||||
cnt = 0
|
||||
async for claim in db.all_claims_producer():
|
||||
yield {
|
||||
'doc': {key: value for key, value in claim.items() if key in ALL_FIELDS},
|
||||
'_id': claim['claim_id'],
|
||||
'_index': index_name,
|
||||
'_op_type': 'update',
|
||||
'doc_as_upsert': True
|
||||
}
|
||||
cnt += 1
|
||||
if cnt % 10000 == 0:
|
||||
logging.info("sent %i claims to ES", cnt)
|
||||
finally:
|
||||
if need_open:
|
||||
db.close()
|
||||
|
||||
|
||||
async def make_es_index_and_run_sync(env: Env, clients=32, force=False, db=None, index_name='claims'):
|
||||
index = SearchIndex(env.es_index_prefix, elastic_host=env.elastic_host, elastic_port=env.elastic_port)
|
||||
async def consume(producer, index_name):
|
||||
env = Env(LBC)
|
||||
logging.info("ES sync host: %s:%i", env.elastic_host, env.elastic_port)
|
||||
es = AsyncElasticsearch([{'host': env.elastic_host, 'port': env.elastic_port}])
|
||||
try:
|
||||
created = await index.start()
|
||||
await async_bulk(es, producer, request_timeout=120)
|
||||
await es.indices.refresh(index=index_name)
|
||||
finally:
|
||||
await es.close()
|
||||
|
||||
|
||||
async def make_es_index(index=None):
|
||||
env = Env(LBC)
|
||||
if index is None:
|
||||
index = SearchIndex('', elastic_host=env.elastic_host, elastic_port=env.elastic_port)
|
||||
|
||||
try:
|
||||
return await index.start()
|
||||
except IndexVersionMismatch as err:
|
||||
logging.info(
|
||||
"dropping ES search index (version %s) for upgrade to version %s", err.got_version, err.expected_version
|
||||
)
|
||||
await index.delete_index()
|
||||
await index.stop()
|
||||
created = await index.start()
|
||||
return await index.start()
|
||||
finally:
|
||||
index.stop()
|
||||
|
||||
es = AsyncElasticsearch([{'host': env.elastic_host, 'port': env.elastic_port}])
|
||||
if force or created:
|
||||
claim_generator = get_all_claims(env, index_name=index_name, db=db)
|
||||
else:
|
||||
claim_generator = get_recent_claims(env, index_name=index_name, db=db)
|
||||
try:
|
||||
async for ok, item in async_streaming_bulk(es, claim_generator, request_timeout=600, raise_on_error=False):
|
||||
if not ok:
|
||||
logging.warning("indexing failed for an item: %s", item)
|
||||
await es.indices.refresh(index=index_name)
|
||||
finally:
|
||||
await es.close()
|
||||
|
||||
async def run(db_path, clients, blocks, shard, index_name='claims'):
|
||||
db = sqlite3.connect(db_path, isolation_level=None, check_same_thread=False, uri=True)
|
||||
db.execute('pragma journal_mode=wal;')
|
||||
db.execute('pragma temp_store=memory;')
|
||||
producer = get_all(db, shard, clients, limit=blocks, index_name=index_name)
|
||||
await asyncio.gather(*(consume(producer, index_name=index_name) for _ in range(min(8, clients))))
|
||||
|
||||
|
||||
def __run(args, shard):
|
||||
asyncio.run(run(args.db_path, args.clients, args.blocks, shard))
|
||||
|
||||
|
||||
def run_elastic_sync():
|
||||
@@ -123,14 +104,23 @@ def run_elastic_sync():
|
||||
|
||||
logging.info('lbry.server starting')
|
||||
parser = argparse.ArgumentParser(prog="lbry-hub-elastic-sync")
|
||||
parser.add_argument("-c", "--clients", type=int, default=32)
|
||||
parser.add_argument("db_path", type=str)
|
||||
parser.add_argument("-c", "--clients", type=int, default=16)
|
||||
parser.add_argument("-b", "--blocks", type=int, default=0)
|
||||
parser.add_argument("-f", "--force", default=False, action='store_true')
|
||||
Env.contribute_to_arg_parser(parser)
|
||||
args = parser.parse_args()
|
||||
env = Env.from_arg_parser(args)
|
||||
processes = []
|
||||
|
||||
if not os.path.exists(os.path.join(args.db_dir, 'lbry-leveldb')):
|
||||
logging.info("DB path doesnt exist, nothing to sync to ES")
|
||||
if not args.force and not os.path.exists(args.db_path):
|
||||
logging.info("DB path doesnt exist")
|
||||
return
|
||||
|
||||
asyncio.run(make_es_index_and_run_sync(env, clients=args.clients, force=args.force))
|
||||
if not args.force and not asyncio.run(make_es_index()):
|
||||
logging.info("ES is already initialized")
|
||||
return
|
||||
for i in range(args.clients):
|
||||
processes.append(Process(target=__run, args=(args, i)))
|
||||
processes[-1].start()
|
||||
for process in processes:
|
||||
process.join()
|
||||
process.close()
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,175 +0,0 @@
|
||||
import struct
|
||||
import logging
|
||||
from string import printable
|
||||
from collections import defaultdict
|
||||
from typing import Tuple, Iterable, Callable, Optional
|
||||
from lbry.wallet.server.db import DB_PREFIXES
|
||||
|
||||
_OP_STRUCT = struct.Struct('>BLL')
|
||||
log = logging.getLogger()
|
||||
|
||||
|
||||
class RevertableOp:
|
||||
__slots__ = [
|
||||
'key',
|
||||
'value',
|
||||
]
|
||||
is_put = 0
|
||||
|
||||
def __init__(self, key: bytes, value: bytes):
|
||||
self.key = key
|
||||
self.value = value
|
||||
|
||||
@property
|
||||
def is_delete(self) -> bool:
|
||||
return not self.is_put
|
||||
|
||||
def invert(self) -> 'RevertableOp':
|
||||
raise NotImplementedError()
|
||||
|
||||
def pack(self) -> bytes:
|
||||
"""
|
||||
Serialize to bytes
|
||||
"""
|
||||
return struct.pack(
|
||||
f'>BLL{len(self.key)}s{len(self.value)}s', int(self.is_put), len(self.key), len(self.value), self.key,
|
||||
self.value
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def unpack(cls, packed: bytes) -> Tuple['RevertableOp', bytes]:
|
||||
"""
|
||||
Deserialize from bytes
|
||||
|
||||
:param packed: bytes containing at least one packed revertable op
|
||||
:return: tuple of the deserialized op (a put or a delete) and the remaining serialized bytes
|
||||
"""
|
||||
is_put, key_len, val_len = _OP_STRUCT.unpack(packed[:9])
|
||||
key = packed[9:9 + key_len]
|
||||
value = packed[9 + key_len:9 + key_len + val_len]
|
||||
if is_put == 1:
|
||||
return RevertablePut(key, value), packed[9 + key_len + val_len:]
|
||||
return RevertableDelete(key, value), packed[9 + key_len + val_len:]
|
||||
|
||||
def __eq__(self, other: 'RevertableOp') -> bool:
|
||||
return (self.is_put, self.key, self.value) == (other.is_put, other.key, other.value)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return str(self)
|
||||
|
||||
def __str__(self) -> str:
|
||||
from lbry.wallet.server.db.prefixes import auto_decode_item
|
||||
k, v = auto_decode_item(self.key, self.value)
|
||||
key = ''.join(c if c in printable else '.' for c in str(k))
|
||||
val = ''.join(c if c in printable else '.' for c in str(v))
|
||||
return f"{'PUT' if self.is_put else 'DELETE'} {DB_PREFIXES(self.key[:1]).name}: {key} | {val}"
|
||||
|
||||
|
||||
class RevertableDelete(RevertableOp):
|
||||
def invert(self):
|
||||
return RevertablePut(self.key, self.value)
|
||||
|
||||
|
||||
class RevertablePut(RevertableOp):
|
||||
is_put = True
|
||||
|
||||
def invert(self):
|
||||
return RevertableDelete(self.key, self.value)
|
||||
|
||||
|
||||
class OpStackIntegrity(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class RevertableOpStack:
|
||||
def __init__(self, get_fn: Callable[[bytes], Optional[bytes]], unsafe_prefixes=None):
|
||||
"""
|
||||
This represents a sequence of revertable puts and deletes to a key-value database that checks for integrity
|
||||
violations when applying the puts and deletes. The integrity checks assure that keys that do not exist
|
||||
are not deleted, and that when keys are deleted the current value is correctly known so that the delete
|
||||
may be undone. When putting values, the integrity checks assure that existing values are not overwritten
|
||||
without first being deleted. Updates are performed by applying a delete op for the old value and a put op
|
||||
for the new value.
|
||||
|
||||
:param get_fn: getter function from an object implementing `KeyValueStorage`
|
||||
:param unsafe_prefixes: optional set of prefixes to ignore integrity errors for, violations are still logged
|
||||
"""
|
||||
self._get = get_fn
|
||||
self._items = defaultdict(list)
|
||||
self._unsafe_prefixes = unsafe_prefixes or set()
|
||||
|
||||
def append_op(self, op: RevertableOp):
|
||||
"""
|
||||
Apply a put or delete op, checking that it introduces no integrity errors
|
||||
"""
|
||||
|
||||
inverted = op.invert()
|
||||
if self._items[op.key] and inverted == self._items[op.key][-1]:
|
||||
self._items[op.key].pop() # if the new op is the inverse of the last op, we can safely null both
|
||||
return
|
||||
elif self._items[op.key] and self._items[op.key][-1] == op: # duplicate of last op
|
||||
return # raise an error?
|
||||
stored_val = self._get(op.key)
|
||||
has_stored_val = stored_val is not None
|
||||
delete_stored_op = None if not has_stored_val else RevertableDelete(op.key, stored_val)
|
||||
will_delete_existing_stored = False if delete_stored_op is None else (delete_stored_op in self._items[op.key])
|
||||
try:
|
||||
if op.is_put and has_stored_val and not will_delete_existing_stored:
|
||||
raise OpStackIntegrity(
|
||||
f"db op tries to add on top of existing key without deleting first: {op}"
|
||||
)
|
||||
elif op.is_delete and has_stored_val and stored_val != op.value and not will_delete_existing_stored:
|
||||
# there is a value and we're not deleting it in this op
|
||||
# check that a delete for the stored value is in the stack
|
||||
raise OpStackIntegrity(f"db op tries to delete with incorrect existing value {op}")
|
||||
elif op.is_delete and not has_stored_val:
|
||||
raise OpStackIntegrity(f"db op tries to delete nonexistent key: {op}")
|
||||
elif op.is_delete and stored_val != op.value:
|
||||
raise OpStackIntegrity(f"db op tries to delete with incorrect value: {op}")
|
||||
except OpStackIntegrity as err:
|
||||
if op.key[:1] in self._unsafe_prefixes:
|
||||
log.debug(f"skipping over integrity error: {err}")
|
||||
else:
|
||||
raise err
|
||||
self._items[op.key].append(op)
|
||||
|
||||
def extend_ops(self, ops: Iterable[RevertableOp]):
|
||||
"""
|
||||
Apply a sequence of put or delete ops, checking that they introduce no integrity errors
|
||||
"""
|
||||
for op in ops:
|
||||
self.append_op(op)
|
||||
|
||||
def clear(self):
|
||||
self._items.clear()
|
||||
|
||||
def __len__(self):
|
||||
return sum(map(len, self._items.values()))
|
||||
|
||||
def __iter__(self):
|
||||
for key, ops in self._items.items():
|
||||
for op in ops:
|
||||
yield op
|
||||
|
||||
def __reversed__(self):
|
||||
for key, ops in self._items.items():
|
||||
for op in reversed(ops):
|
||||
yield op
|
||||
|
||||
def get_undo_ops(self) -> bytes:
|
||||
"""
|
||||
Get the serialized bytes to undo all of the changes made by the pending ops
|
||||
"""
|
||||
return b''.join(op.invert().pack() for op in reversed(self))
|
||||
|
||||
def apply_packed_undo_ops(self, packed: bytes):
|
||||
"""
|
||||
Unpack and apply a sequence of undo ops from serialized undo bytes
|
||||
"""
|
||||
while packed:
|
||||
op, packed = RevertableOp.unpack(packed)
|
||||
self.append_op(op)
|
||||
|
||||
def get_last_op_for_key(self, key: bytes) -> Optional[RevertableOp]:
|
||||
if key in self._items and self._items[key]:
|
||||
return self._items[key][-1]
|
||||
@@ -0,0 +1,9 @@
|
||||
from . import zscore
|
||||
from . import ar
|
||||
from . import variable_decay
|
||||
|
||||
TRENDING_ALGORITHMS = {
|
||||
'zscore': zscore,
|
||||
'ar': ar,
|
||||
'variable_decay': variable_decay
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
import copy
|
||||
import math
|
||||
import time
|
||||
|
||||
# Half life in blocks
|
||||
HALF_LIFE = 134
|
||||
|
||||
# Decay coefficient per block
|
||||
DECAY = 0.5**(1.0/HALF_LIFE)
|
||||
|
||||
# How frequently to write trending values to the db
|
||||
SAVE_INTERVAL = 10
|
||||
|
||||
# Renormalisation interval
|
||||
RENORM_INTERVAL = 1000
|
||||
|
||||
# Assertion
|
||||
assert RENORM_INTERVAL % SAVE_INTERVAL == 0
|
||||
|
||||
# Decay coefficient per renormalisation interval
|
||||
DECAY_PER_RENORM = DECAY**(RENORM_INTERVAL)
|
||||
|
||||
# Log trending calculations?
|
||||
TRENDING_LOG = True
|
||||
|
||||
|
||||
def install(connection):
|
||||
"""
|
||||
Install the AR trending algorithm.
|
||||
"""
|
||||
check_trending_values(connection)
|
||||
|
||||
if TRENDING_LOG:
|
||||
f = open("trending_ar.log", "a")
|
||||
f.close()
|
||||
|
||||
# Stub
|
||||
CREATE_TREND_TABLE = ""
|
||||
|
||||
|
||||
def check_trending_values(connection):
|
||||
"""
|
||||
If the trending values appear to be based on the zscore algorithm,
|
||||
reset them. This will allow resyncing from a standard snapshot.
|
||||
"""
|
||||
c = connection.cursor()
|
||||
needs_reset = False
|
||||
for row in c.execute("SELECT COUNT(*) num FROM claim WHERE trending_global <> 0;"):
|
||||
if row[0] != 0:
|
||||
needs_reset = True
|
||||
break
|
||||
|
||||
if needs_reset:
|
||||
print("Resetting some columns. This might take a while...", flush=True, end="")
|
||||
c.execute(""" BEGIN;
|
||||
UPDATE claim SET trending_group = 0;
|
||||
UPDATE claim SET trending_mixed = 0;
|
||||
UPDATE claim SET trending_global = 0;
|
||||
UPDATE claim SET trending_local = 0;
|
||||
COMMIT;""")
|
||||
print("done.")
|
||||
|
||||
|
||||
def spike_height(trending_score, x, x_old, time_boost=1.0):
|
||||
"""
|
||||
Compute the size of a trending spike.
|
||||
"""
|
||||
|
||||
# Change in softened amount
|
||||
change_in_softened_amount = x**0.25 - x_old**0.25
|
||||
|
||||
# Softened change in amount
|
||||
delta = x - x_old
|
||||
softened_change_in_amount = abs(delta)**0.25
|
||||
|
||||
# Softened change in amount counts more for minnows
|
||||
if delta > 0.0:
|
||||
if trending_score >= 0.0:
|
||||
multiplier = 0.1/((trending_score/time_boost + softened_change_in_amount) + 1.0)
|
||||
softened_change_in_amount *= multiplier
|
||||
else:
|
||||
softened_change_in_amount *= -1.0
|
||||
|
||||
return time_boost*(softened_change_in_amount + change_in_softened_amount)
|
||||
|
||||
|
||||
def get_time_boost(height):
|
||||
"""
|
||||
Return the time boost at a given height.
|
||||
"""
|
||||
return 1.0/DECAY**(height % RENORM_INTERVAL)
|
||||
|
||||
|
||||
def trending_log(s):
|
||||
"""
|
||||
Log a string.
|
||||
"""
|
||||
if TRENDING_LOG:
|
||||
fout = open("trending_ar.log", "a")
|
||||
fout.write(s)
|
||||
fout.flush()
|
||||
fout.close()
|
||||
|
||||
class TrendingData:
|
||||
"""
|
||||
An object of this class holds trending data
|
||||
"""
|
||||
def __init__(self):
|
||||
self.claims = {}
|
||||
|
||||
# Have all claims been read from db yet?
|
||||
self.initialised = False
|
||||
|
||||
def insert_claim_from_load(self, claim_hash, trending_score, total_amount):
|
||||
assert not self.initialised
|
||||
self.claims[claim_hash] = {"trending_score": trending_score,
|
||||
"total_amount": total_amount,
|
||||
"changed": False}
|
||||
|
||||
|
||||
def update_claim(self, claim_hash, total_amount, time_boost=1.0):
|
||||
"""
|
||||
Update trending data for a claim, given its new total amount.
|
||||
"""
|
||||
assert self.initialised
|
||||
|
||||
# Extract existing total amount and trending score
|
||||
# or use starting values if the claim is new
|
||||
if claim_hash in self.claims:
|
||||
old_state = copy.deepcopy(self.claims[claim_hash])
|
||||
else:
|
||||
old_state = {"trending_score": 0.0,
|
||||
"total_amount": 0.0,
|
||||
"changed": False}
|
||||
|
||||
# Calculate LBC change
|
||||
change = total_amount - old_state["total_amount"]
|
||||
|
||||
# Modify data if there was an LBC change
|
||||
if change != 0.0:
|
||||
spike = spike_height(old_state["trending_score"],
|
||||
total_amount,
|
||||
old_state["total_amount"],
|
||||
time_boost)
|
||||
trending_score = old_state["trending_score"] + spike
|
||||
self.claims[claim_hash] = {"total_amount": total_amount,
|
||||
"trending_score": trending_score,
|
||||
"changed": True}
|
||||
|
||||
|
||||
|
||||
def test_trending():
|
||||
"""
|
||||
Quick trending test for something receiving 10 LBC per block
|
||||
"""
|
||||
data = TrendingData()
|
||||
data.insert_claim_from_load("abc", 10.0, 1.0)
|
||||
data.initialised = True
|
||||
|
||||
for height in range(1, 5000):
|
||||
|
||||
if height % RENORM_INTERVAL == 0:
|
||||
data.claims["abc"]["trending_score"] *= DECAY_PER_RENORM
|
||||
|
||||
time_boost = get_time_boost(height)
|
||||
data.update_claim("abc", data.claims["abc"]["total_amount"] + 10.0,
|
||||
time_boost=time_boost)
|
||||
|
||||
|
||||
print(str(height) + " " + str(time_boost) + " " \
|
||||
+ str(data.claims["abc"]["trending_score"]))
|
||||
|
||||
|
||||
|
||||
# One global instance
|
||||
# pylint: disable=C0103
|
||||
trending_data = TrendingData()
|
||||
|
||||
def run(db, height, final_height, recalculate_claim_hashes):
|
||||
|
||||
if height < final_height - 5*HALF_LIFE:
|
||||
trending_log("Skipping AR trending at block {h}.\n".format(h=height))
|
||||
return
|
||||
|
||||
start = time.time()
|
||||
|
||||
trending_log("Calculating AR trending at block {h}.\n".format(h=height))
|
||||
trending_log(" Length of trending data = {l}.\n"\
|
||||
.format(l=len(trending_data.claims)))
|
||||
|
||||
# Renormalise trending scores and mark all as having changed
|
||||
if height % RENORM_INTERVAL == 0:
|
||||
trending_log(" Renormalising trending scores...")
|
||||
|
||||
keys = trending_data.claims.keys()
|
||||
for key in keys:
|
||||
if trending_data.claims[key]["trending_score"] != 0.0:
|
||||
trending_data.claims[key]["trending_score"] *= DECAY_PER_RENORM
|
||||
trending_data.claims[key]["changed"] = True
|
||||
|
||||
# Tiny becomes zero
|
||||
if abs(trending_data.claims[key]["trending_score"]) < 1E-9:
|
||||
trending_data.claims[key]["trending_score"] = 0.0
|
||||
|
||||
trending_log("done.\n")
|
||||
|
||||
|
||||
# Regular message.
|
||||
trending_log(" Reading total_amounts from db and updating"\
|
||||
+ " trending scores in RAM...")
|
||||
|
||||
# Get the value of the time boost
|
||||
time_boost = get_time_boost(height)
|
||||
|
||||
# Update claims from db
|
||||
if not trending_data.initialised:
|
||||
# On fresh launch
|
||||
for row in db.execute("""
|
||||
SELECT claim_hash, trending_mixed,
|
||||
(amount + support_amount)
|
||||
AS total_amount
|
||||
FROM claim;
|
||||
"""):
|
||||
trending_data.insert_claim_from_load(row[0], row[1], 1E-8*row[2])
|
||||
trending_data.initialised = True
|
||||
else:
|
||||
for row in db.execute(f"""
|
||||
SELECT claim_hash,
|
||||
(amount + support_amount)
|
||||
AS total_amount
|
||||
FROM claim
|
||||
WHERE claim_hash IN
|
||||
({','.join('?' for _ in recalculate_claim_hashes)});
|
||||
""", list(recalculate_claim_hashes)):
|
||||
trending_data.update_claim(row[0], 1E-8*row[1], time_boost)
|
||||
|
||||
trending_log("done.\n")
|
||||
|
||||
|
||||
# Write trending scores to DB
|
||||
if height % SAVE_INTERVAL == 0:
|
||||
|
||||
trending_log(" Writing trending scores to db...")
|
||||
|
||||
the_list = []
|
||||
keys = trending_data.claims.keys()
|
||||
for key in keys:
|
||||
if trending_data.claims[key]["changed"]:
|
||||
the_list.append((trending_data.claims[key]["trending_score"],
|
||||
key))
|
||||
trending_data.claims[key]["changed"] = False
|
||||
|
||||
trending_log("{n} scores to write...".format(n=len(the_list)))
|
||||
|
||||
db.executemany("UPDATE claim SET trending_mixed=? WHERE claim_hash=?;",
|
||||
the_list)
|
||||
|
||||
trending_log("done.\n")
|
||||
|
||||
trending_log("Trending operations took {time} seconds.\n\n"\
|
||||
.format(time=time.time() - start))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_trending()
|
||||
@@ -0,0 +1,485 @@
|
||||
"""
|
||||
AR-like trending with a delayed effect and a faster
|
||||
decay rate for high valued claims.
|
||||
"""
|
||||
|
||||
import math
|
||||
import time
|
||||
import sqlite3
|
||||
|
||||
# Half life in blocks *for lower LBC claims* (it's shorter for whale claims)
|
||||
HALF_LIFE = 200
|
||||
|
||||
# Whale threshold, in LBC (higher -> less DB writing)
|
||||
WHALE_THRESHOLD = 10000.0
|
||||
|
||||
# Decay coefficient per block
|
||||
DECAY = 0.5**(1.0/HALF_LIFE)
|
||||
|
||||
# How frequently to write trending values to the db
|
||||
SAVE_INTERVAL = 10
|
||||
|
||||
# Renormalisation interval
|
||||
RENORM_INTERVAL = 1000
|
||||
|
||||
# Assertion
|
||||
assert RENORM_INTERVAL % SAVE_INTERVAL == 0
|
||||
|
||||
# Decay coefficient per renormalisation interval
|
||||
DECAY_PER_RENORM = DECAY**(RENORM_INTERVAL)
|
||||
|
||||
# Log trending calculations?
|
||||
TRENDING_LOG = True
|
||||
|
||||
|
||||
def install(connection):
|
||||
"""
|
||||
Install the trending algorithm.
|
||||
"""
|
||||
check_trending_values(connection)
|
||||
trending_data.initialise(connection.cursor())
|
||||
|
||||
if TRENDING_LOG:
|
||||
f = open("trending_variable_decay.log", "a")
|
||||
f.close()
|
||||
|
||||
# Stub
|
||||
CREATE_TREND_TABLE = ""
|
||||
|
||||
def check_trending_values(connection):
|
||||
"""
|
||||
If the trending values appear to be based on the zscore algorithm,
|
||||
reset them. This will allow resyncing from a standard snapshot.
|
||||
"""
|
||||
c = connection.cursor()
|
||||
needs_reset = False
|
||||
for row in c.execute("SELECT COUNT(*) num FROM claim WHERE trending_global <> 0;"):
|
||||
if row[0] != 0:
|
||||
needs_reset = True
|
||||
break
|
||||
|
||||
if needs_reset:
|
||||
print("Resetting some columns. This might take a while...", flush=True,
|
||||
end="")
|
||||
c.execute(""" BEGIN;
|
||||
UPDATE claim SET trending_group = 0;
|
||||
UPDATE claim SET trending_mixed = 0;
|
||||
COMMIT;""")
|
||||
print("done.")
|
||||
|
||||
|
||||
|
||||
|
||||
def trending_log(s):
|
||||
"""
|
||||
Log a string to the log file
|
||||
"""
|
||||
if TRENDING_LOG:
|
||||
fout = open("trending_variable_decay.log", "a")
|
||||
fout.write(s)
|
||||
fout.flush()
|
||||
fout.close()
|
||||
|
||||
|
||||
def trending_unit(height):
|
||||
"""
|
||||
Return the trending score unit at a given height.
|
||||
"""
|
||||
# Round to the beginning of a SAVE_INTERVAL batch of blocks.
|
||||
_height = height - (height % SAVE_INTERVAL)
|
||||
return 1.0/DECAY**(height % RENORM_INTERVAL)
|
||||
|
||||
|
||||
class TrendingDB:
|
||||
"""
|
||||
An in-memory database of trending scores
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.conn = sqlite3.connect(":memory:", check_same_thread=False)
|
||||
self.cursor = self.conn.cursor()
|
||||
self.initialised = False
|
||||
self.write_needed = set()
|
||||
|
||||
def execute(self, query, *args, **kwargs):
|
||||
return self.conn.execute(query, *args, **kwargs)
|
||||
|
||||
def executemany(self, query, *args, **kwargs):
|
||||
return self.conn.executemany(query, *args, **kwargs)
|
||||
|
||||
def begin(self):
|
||||
self.execute("BEGIN;")
|
||||
|
||||
def commit(self):
|
||||
self.execute("COMMIT;")
|
||||
|
||||
def initialise(self, db):
|
||||
"""
|
||||
Pass in claims.db
|
||||
"""
|
||||
if self.initialised:
|
||||
return
|
||||
|
||||
trending_log("Initialising trending database...")
|
||||
|
||||
# The need for speed
|
||||
self.execute("PRAGMA JOURNAL_MODE=OFF;")
|
||||
self.execute("PRAGMA SYNCHRONOUS=0;")
|
||||
|
||||
self.begin()
|
||||
|
||||
# Create the tables
|
||||
self.execute("""
|
||||
CREATE TABLE IF NOT EXISTS claims
|
||||
(claim_hash BYTES PRIMARY KEY,
|
||||
lbc REAL NOT NULL DEFAULT 0.0,
|
||||
trending_score REAL NOT NULL DEFAULT 0.0)
|
||||
WITHOUT ROWID;""")
|
||||
|
||||
self.execute("""
|
||||
CREATE TABLE IF NOT EXISTS spikes
|
||||
(id INTEGER PRIMARY KEY,
|
||||
claim_hash BYTES NOT NULL,
|
||||
height INTEGER NOT NULL,
|
||||
mass REAL NOT NULL,
|
||||
FOREIGN KEY (claim_hash)
|
||||
REFERENCES claims (claim_hash));""")
|
||||
|
||||
# Clear out any existing data
|
||||
self.execute("DELETE FROM claims;")
|
||||
self.execute("DELETE FROM spikes;")
|
||||
|
||||
# Create indexes
|
||||
self.execute("CREATE INDEX idx1 ON spikes (claim_hash, height, mass);")
|
||||
self.execute("CREATE INDEX idx2 ON spikes (claim_hash, height, mass DESC);")
|
||||
self.execute("CREATE INDEX idx3 on claims (lbc DESC, claim_hash, trending_score);")
|
||||
|
||||
# Import data from claims.db
|
||||
for row in db.execute("""
|
||||
SELECT claim_hash,
|
||||
1E-8*(amount + support_amount) AS lbc,
|
||||
trending_mixed
|
||||
FROM claim;
|
||||
"""):
|
||||
self.execute("INSERT INTO claims VALUES (?, ?, ?);", row)
|
||||
self.commit()
|
||||
|
||||
self.initialised = True
|
||||
trending_log("done.\n")
|
||||
|
||||
def apply_spikes(self, height):
|
||||
"""
|
||||
Apply spikes that are due. This occurs inside a transaction.
|
||||
"""
|
||||
|
||||
spikes = []
|
||||
unit = trending_unit(height)
|
||||
for row in self.execute("""
|
||||
SELECT SUM(mass), claim_hash FROM spikes
|
||||
WHERE height = ?
|
||||
GROUP BY claim_hash;
|
||||
""", (height, )):
|
||||
spikes.append((row[0]*unit, row[1]))
|
||||
self.write_needed.add(row[1])
|
||||
|
||||
self.executemany("""
|
||||
UPDATE claims
|
||||
SET trending_score = (trending_score + ?)
|
||||
WHERE claim_hash = ?;
|
||||
""", spikes)
|
||||
self.execute("DELETE FROM spikes WHERE height = ?;", (height, ))
|
||||
|
||||
|
||||
def decay_whales(self, height):
|
||||
"""
|
||||
Occurs inside transaction.
|
||||
"""
|
||||
if height % SAVE_INTERVAL != 0:
|
||||
return
|
||||
|
||||
whales = self.execute("""
|
||||
SELECT trending_score, lbc, claim_hash
|
||||
FROM claims
|
||||
WHERE lbc >= ?;
|
||||
""", (WHALE_THRESHOLD, )).fetchall()
|
||||
whales2 = []
|
||||
for whale in whales:
|
||||
trending, lbc, claim_hash = whale
|
||||
|
||||
# Overall multiplication factor for decay rate
|
||||
# At WHALE_THRESHOLD, this is 1
|
||||
# At 10*WHALE_THRESHOLD, it is 3
|
||||
decay_rate_factor = 1.0 + 2.0*math.log10(lbc/WHALE_THRESHOLD)
|
||||
|
||||
# The -1 is because this is just the *extra* part being applied
|
||||
factor = (DECAY**SAVE_INTERVAL)**(decay_rate_factor - 1.0)
|
||||
|
||||
# Decay
|
||||
trending *= factor
|
||||
whales2.append((trending, claim_hash))
|
||||
self.write_needed.add(claim_hash)
|
||||
|
||||
self.executemany("UPDATE claims SET trending_score=? WHERE claim_hash=?;",
|
||||
whales2)
|
||||
|
||||
|
||||
def renorm(self, height):
|
||||
"""
|
||||
Renormalise trending scores. Occurs inside a transaction.
|
||||
"""
|
||||
|
||||
if height % RENORM_INTERVAL == 0:
|
||||
threshold = 1.0E-3/DECAY_PER_RENORM
|
||||
for row in self.execute("""SELECT claim_hash FROM claims
|
||||
WHERE ABS(trending_score) >= ?;""",
|
||||
(threshold, )):
|
||||
self.write_needed.add(row[0])
|
||||
|
||||
self.execute("""UPDATE claims SET trending_score = ?*trending_score
|
||||
WHERE ABS(trending_score) >= ?;""",
|
||||
(DECAY_PER_RENORM, threshold))
|
||||
|
||||
def write_to_claims_db(self, db, height):
|
||||
"""
|
||||
Write changed trending scores to claims.db.
|
||||
"""
|
||||
if height % SAVE_INTERVAL != 0:
|
||||
return
|
||||
|
||||
rows = self.execute(f"""
|
||||
SELECT trending_score, claim_hash
|
||||
FROM claims
|
||||
WHERE claim_hash IN
|
||||
({','.join('?' for _ in self.write_needed)});
|
||||
""", list(self.write_needed)).fetchall()
|
||||
|
||||
db.executemany("""UPDATE claim SET trending_mixed = ?
|
||||
WHERE claim_hash = ?;""", rows)
|
||||
|
||||
# Clear list of claims needing to be written to claims.db
|
||||
self.write_needed = set()
|
||||
|
||||
|
||||
def update(self, db, height, recalculate_claim_hashes):
|
||||
"""
|
||||
Update trending scores.
|
||||
Input is a cursor to claims.db, the block height, and the list of
|
||||
claims that changed.
|
||||
"""
|
||||
assert self.initialised
|
||||
|
||||
self.begin()
|
||||
self.renorm(height)
|
||||
|
||||
# Fetch changed/new claims from claims.db
|
||||
for row in db.execute(f"""
|
||||
SELECT claim_hash,
|
||||
1E-8*(amount + support_amount) AS lbc
|
||||
FROM claim
|
||||
WHERE claim_hash IN
|
||||
({','.join('?' for _ in recalculate_claim_hashes)});
|
||||
""", list(recalculate_claim_hashes)):
|
||||
claim_hash, lbc = row
|
||||
|
||||
# Insert into trending db if it does not exist
|
||||
self.execute("""
|
||||
INSERT INTO claims (claim_hash)
|
||||
VALUES (?)
|
||||
ON CONFLICT (claim_hash) DO NOTHING;""",
|
||||
(claim_hash, ))
|
||||
|
||||
# See if it was an LBC change
|
||||
old = self.execute("SELECT * FROM claims WHERE claim_hash=?;",
|
||||
(claim_hash, )).fetchone()
|
||||
lbc_old = old[1]
|
||||
|
||||
# Save new LBC value into trending db
|
||||
self.execute("UPDATE claims SET lbc = ? WHERE claim_hash = ?;",
|
||||
(lbc, claim_hash))
|
||||
|
||||
if lbc > lbc_old:
|
||||
|
||||
# Schedule a future spike
|
||||
delay = min(int((lbc + 1E-8)**0.4), HALF_LIFE)
|
||||
spike = (claim_hash, height + delay, spike_mass(lbc, lbc_old))
|
||||
self.execute("""INSERT INTO spikes
|
||||
(claim_hash, height, mass)
|
||||
VALUES (?, ?, ?);""", spike)
|
||||
|
||||
elif lbc < lbc_old:
|
||||
|
||||
# Subtract from future spikes
|
||||
penalty = spike_mass(lbc_old, lbc)
|
||||
spikes = self.execute("""
|
||||
SELECT * FROM spikes
|
||||
WHERE claim_hash = ?
|
||||
ORDER BY height ASC, mass DESC;
|
||||
""", (claim_hash, )).fetchall()
|
||||
for spike in spikes:
|
||||
spike_id, mass = spike[0], spike[3]
|
||||
|
||||
if mass > penalty:
|
||||
# The entire penalty merely reduces this spike
|
||||
self.execute("UPDATE spikes SET mass=? WHERE id=?;",
|
||||
(mass - penalty, spike_id))
|
||||
penalty = 0.0
|
||||
else:
|
||||
# Removing this spike entirely accounts for some (or
|
||||
# all) of the penalty, then move on to other spikes
|
||||
self.execute("DELETE FROM spikes WHERE id=?;",
|
||||
(spike_id, ))
|
||||
penalty -= mass
|
||||
|
||||
# If penalty remains, that's a negative spike to be applied
|
||||
# immediately.
|
||||
if penalty > 0.0:
|
||||
self.execute("""
|
||||
INSERT INTO spikes (claim_hash, height, mass)
|
||||
VALUES (?, ?, ?);""",
|
||||
(claim_hash, height, -penalty))
|
||||
|
||||
self.apply_spikes(height)
|
||||
self.decay_whales(height)
|
||||
self.commit()
|
||||
|
||||
self.write_to_claims_db(db, height)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# The "global" instance to work with
|
||||
# pylint: disable=C0103
|
||||
trending_data = TrendingDB()
|
||||
|
||||
def spike_mass(x, x_old):
|
||||
"""
|
||||
Compute the mass of a trending spike (normed - constant units).
|
||||
x_old = old LBC value
|
||||
x = new LBC value
|
||||
"""
|
||||
|
||||
# Sign of trending spike
|
||||
sign = 1.0
|
||||
if x < x_old:
|
||||
sign = -1.0
|
||||
|
||||
# Magnitude
|
||||
mag = abs(x**0.25 - x_old**0.25)
|
||||
|
||||
# Minnow boost
|
||||
mag *= 1.0 + 2E4/(x + 100.0)**2
|
||||
|
||||
return sign*mag
|
||||
|
||||
|
||||
def run(db, height, final_height, recalculate_claim_hashes):
|
||||
if height < final_height - 5*HALF_LIFE:
|
||||
trending_log(f"Skipping trending calculations at block {height}.\n")
|
||||
return
|
||||
|
||||
start = time.time()
|
||||
trending_log(f"Calculating variable_decay trending at block {height}.\n")
|
||||
trending_data.update(db, height, recalculate_claim_hashes)
|
||||
end = time.time()
|
||||
trending_log(f"Trending operations took {end - start} seconds.\n\n")
|
||||
|
||||
def test_trending():
|
||||
"""
|
||||
Quick trending test for claims with different support patterns.
|
||||
Actually use the run() function.
|
||||
"""
|
||||
|
||||
# Create a fake "claims.db" for testing
|
||||
# pylint: disable=I1101
|
||||
dbc = apsw.Connection(":memory:")
|
||||
db = dbc.cursor()
|
||||
|
||||
# Create table
|
||||
db.execute("""
|
||||
BEGIN;
|
||||
CREATE TABLE claim (claim_hash TEXT PRIMARY KEY,
|
||||
amount REAL NOT NULL DEFAULT 0.0,
|
||||
support_amount REAL NOT NULL DEFAULT 0.0,
|
||||
trending_mixed REAL NOT NULL DEFAULT 0.0);
|
||||
COMMIT;
|
||||
""")
|
||||
|
||||
# Initialise trending data before anything happens with the claims
|
||||
trending_data.initialise(db)
|
||||
|
||||
# Insert initial states of claims
|
||||
everything = {"huge_whale": 0.01, "medium_whale": 0.01, "small_whale": 0.01,
|
||||
"huge_whale_botted": 0.01, "minnow": 0.01}
|
||||
|
||||
def to_list_of_tuples(stuff):
|
||||
l = []
|
||||
for key in stuff:
|
||||
l.append((key, stuff[key]))
|
||||
return l
|
||||
|
||||
db.executemany("""
|
||||
INSERT INTO claim (claim_hash, amount) VALUES (?, 1E8*?);
|
||||
""", to_list_of_tuples(everything))
|
||||
|
||||
# Process block zero
|
||||
height = 0
|
||||
run(db, height, height, everything.keys())
|
||||
|
||||
# Save trajectories for plotting
|
||||
trajectories = {}
|
||||
for row in trending_data.execute("""
|
||||
SELECT claim_hash, trending_score
|
||||
FROM claims;
|
||||
"""):
|
||||
trajectories[row[0]] = [row[1]/trending_unit(height)]
|
||||
|
||||
# Main loop
|
||||
for height in range(1, 1000):
|
||||
|
||||
# One-off supports
|
||||
if height == 1:
|
||||
everything["huge_whale"] += 5E5
|
||||
everything["medium_whale"] += 5E4
|
||||
everything["small_whale"] += 5E3
|
||||
|
||||
# Every block
|
||||
if height < 500:
|
||||
everything["huge_whale_botted"] += 5E5/500
|
||||
everything["minnow"] += 1
|
||||
|
||||
# Remove supports
|
||||
if height == 500:
|
||||
for key in everything:
|
||||
everything[key] = 0.01
|
||||
|
||||
# Whack into the db
|
||||
db.executemany("""
|
||||
UPDATE claim SET amount = 1E8*? WHERE claim_hash = ?;
|
||||
""", [(y, x) for (x, y) in to_list_of_tuples(everything)])
|
||||
|
||||
# Call run()
|
||||
run(db, height, height, everything.keys())
|
||||
|
||||
# Append current trending scores to trajectories
|
||||
for row in db.execute("""
|
||||
SELECT claim_hash, trending_mixed
|
||||
FROM claim;
|
||||
"""):
|
||||
trajectories[row[0]].append(row[1]/trending_unit(height))
|
||||
|
||||
dbc.close()
|
||||
|
||||
# pylint: disable=C0415
|
||||
import matplotlib.pyplot as plt
|
||||
for key in trajectories:
|
||||
plt.plot(trajectories[key], label=key)
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_trending()
|
||||
@@ -0,0 +1,119 @@
|
||||
from math import sqrt
|
||||
|
||||
# TRENDING_WINDOW is the number of blocks in ~6hr period (21600 seconds / 161 seconds per block)
|
||||
TRENDING_WINDOW = 134
|
||||
|
||||
# TRENDING_DATA_POINTS says how many samples to use for the trending algorithm
|
||||
# i.e. only consider claims from the most recent (TRENDING_WINDOW * TRENDING_DATA_POINTS) blocks
|
||||
TRENDING_DATA_POINTS = 28
|
||||
|
||||
CREATE_TREND_TABLE = """
|
||||
create table if not exists trend (
|
||||
claim_hash bytes not null,
|
||||
height integer not null,
|
||||
amount integer not null,
|
||||
primary key (claim_hash, height)
|
||||
) without rowid;
|
||||
"""
|
||||
|
||||
|
||||
class ZScore:
|
||||
__slots__ = 'count', 'total', 'power', 'last'
|
||||
|
||||
def __init__(self):
|
||||
self.count = 0
|
||||
self.total = 0
|
||||
self.power = 0
|
||||
self.last = None
|
||||
|
||||
def step(self, value):
|
||||
if self.last is not None:
|
||||
self.count += 1
|
||||
self.total += self.last
|
||||
self.power += self.last ** 2
|
||||
self.last = value
|
||||
|
||||
@property
|
||||
def mean(self):
|
||||
return self.total / self.count
|
||||
|
||||
@property
|
||||
def standard_deviation(self):
|
||||
value = (self.power / self.count) - self.mean ** 2
|
||||
return sqrt(value) if value > 0 else 0
|
||||
|
||||
def finalize(self):
|
||||
if self.count == 0:
|
||||
return self.last
|
||||
return (self.last - self.mean) / (self.standard_deviation or 1)
|
||||
|
||||
|
||||
def install(connection):
|
||||
connection.create_aggregate("zscore", 1, ZScore)
|
||||
connection.executescript(CREATE_TREND_TABLE)
|
||||
|
||||
|
||||
def run(db, height, final_height, affected_claims):
|
||||
# don't start tracking until we're at the end of initial sync
|
||||
if height < (final_height - (TRENDING_WINDOW * TRENDING_DATA_POINTS)):
|
||||
return
|
||||
|
||||
if height % TRENDING_WINDOW != 0:
|
||||
return
|
||||
|
||||
db.execute(f"""
|
||||
DELETE FROM trend WHERE height < {height - (TRENDING_WINDOW * TRENDING_DATA_POINTS)}
|
||||
""")
|
||||
|
||||
start = (height - TRENDING_WINDOW) + 1
|
||||
db.execute(f"""
|
||||
INSERT OR IGNORE INTO trend (claim_hash, height, amount)
|
||||
SELECT claim_hash, {start}, COALESCE(
|
||||
(SELECT SUM(amount) FROM support WHERE claim_hash=claim.claim_hash
|
||||
AND height >= {start}), 0
|
||||
) AS support_sum
|
||||
FROM claim WHERE support_sum > 0
|
||||
""")
|
||||
|
||||
zscore = ZScore()
|
||||
for global_sum in db.execute("SELECT AVG(amount) AS avg_amount FROM trend GROUP BY height"):
|
||||
zscore.step(global_sum.avg_amount)
|
||||
global_mean, global_deviation = 0, 1
|
||||
if zscore.count > 0:
|
||||
global_mean = zscore.mean
|
||||
global_deviation = zscore.standard_deviation
|
||||
|
||||
db.execute(f"""
|
||||
UPDATE claim SET
|
||||
trending_local = COALESCE((
|
||||
SELECT zscore(amount) FROM trend
|
||||
WHERE claim_hash=claim.claim_hash ORDER BY height DESC
|
||||
), 0),
|
||||
trending_global = COALESCE((
|
||||
SELECT (amount - {global_mean}) / {global_deviation} FROM trend
|
||||
WHERE claim_hash=claim.claim_hash AND height = {start}
|
||||
), 0),
|
||||
trending_group = 0,
|
||||
trending_mixed = 0
|
||||
""")
|
||||
|
||||
# trending_group and trending_mixed determine how trending will show in query results
|
||||
# normally the SQL will be: "ORDER BY trending_group, trending_mixed"
|
||||
# changing the trending_group will have significant impact on trending results
|
||||
# changing the value used for trending_mixed will only impact trending within a trending_group
|
||||
db.execute(f"""
|
||||
UPDATE claim SET
|
||||
trending_group = CASE
|
||||
WHEN trending_local > 0 AND trending_global > 0 THEN 4
|
||||
WHEN trending_local <= 0 AND trending_global > 0 THEN 3
|
||||
WHEN trending_local > 0 AND trending_global <= 0 THEN 2
|
||||
WHEN trending_local <= 0 AND trending_global <= 0 THEN 1
|
||||
END,
|
||||
trending_mixed = CASE
|
||||
WHEN trending_local > 0 AND trending_global > 0 THEN trending_global
|
||||
WHEN trending_local <= 0 AND trending_global > 0 THEN trending_local
|
||||
WHEN trending_local > 0 AND trending_global <= 0 THEN trending_local
|
||||
WHEN trending_local <= 0 AND trending_global <= 0 THEN trending_global
|
||||
END
|
||||
WHERE trending_local <> 0 OR trending_global <> 0
|
||||
""")
|
||||
@@ -0,0 +1,994 @@
|
||||
import os
|
||||
|
||||
import sqlite3
|
||||
from typing import Union, Tuple, Set, List
|
||||
from itertools import chain
|
||||
from decimal import Decimal
|
||||
from collections import namedtuple
|
||||
from binascii import unhexlify, hexlify
|
||||
from lbry.wallet.server.leveldb import LevelDB
|
||||
from lbry.wallet.server.util import class_logger
|
||||
from lbry.wallet.database import query, constraints_to_sql
|
||||
|
||||
from lbry.schema.tags import clean_tags
|
||||
from lbry.schema.mime_types import guess_stream_type
|
||||
from lbry.wallet import Ledger, RegTestLedger
|
||||
from lbry.wallet.transaction import Transaction, Output
|
||||
from lbry.wallet.server.db.canonical import register_canonical_functions
|
||||
from lbry.wallet.server.db.trending import TRENDING_ALGORITHMS
|
||||
|
||||
from .common import CLAIM_TYPES, STREAM_TYPES, COMMON_TAGS, INDEXED_LANGUAGES
|
||||
from lbry.wallet.server.db.elasticsearch import SearchIndex
|
||||
|
||||
ATTRIBUTE_ARRAY_MAX_LENGTH = 100
|
||||
sqlite3.enable_callback_tracebacks(True)
|
||||
|
||||
|
||||
class SQLDB:
|
||||
|
||||
PRAGMAS = """
|
||||
pragma journal_mode=WAL;
|
||||
"""
|
||||
|
||||
CREATE_CLAIM_TABLE = """
|
||||
create table if not exists claim (
|
||||
claim_hash bytes primary key,
|
||||
claim_id text not null,
|
||||
claim_name text not null,
|
||||
normalized text not null,
|
||||
txo_hash bytes not null,
|
||||
tx_position integer not null,
|
||||
amount integer not null,
|
||||
timestamp integer not null, -- last updated timestamp
|
||||
creation_timestamp integer not null,
|
||||
height integer not null, -- last updated height
|
||||
creation_height integer not null,
|
||||
activation_height integer,
|
||||
expiration_height integer not null,
|
||||
release_time integer not null,
|
||||
|
||||
short_url text not null, -- normalized#shortest-unique-claim_id
|
||||
canonical_url text, -- channel's-short_url/normalized#shortest-unique-claim_id-within-channel
|
||||
|
||||
title text,
|
||||
author text,
|
||||
description text,
|
||||
|
||||
claim_type integer,
|
||||
has_source bool,
|
||||
reposted integer default 0,
|
||||
|
||||
-- streams
|
||||
stream_type text,
|
||||
media_type text,
|
||||
fee_amount integer default 0,
|
||||
fee_currency text,
|
||||
duration integer,
|
||||
|
||||
-- reposts
|
||||
reposted_claim_hash bytes,
|
||||
|
||||
-- claims which are channels
|
||||
public_key_bytes bytes,
|
||||
public_key_hash bytes,
|
||||
claims_in_channel integer,
|
||||
|
||||
-- claims which are inside channels
|
||||
channel_hash bytes,
|
||||
channel_join integer, -- height at which claim got valid signature / joined channel
|
||||
signature bytes,
|
||||
signature_digest bytes,
|
||||
signature_valid bool,
|
||||
|
||||
effective_amount integer not null default 0,
|
||||
support_amount integer not null default 0,
|
||||
trending_group integer not null default 0,
|
||||
trending_mixed integer not null default 0,
|
||||
trending_local integer not null default 0,
|
||||
trending_global integer not null default 0
|
||||
);
|
||||
|
||||
create index if not exists claim_normalized_idx on claim (normalized, activation_height);
|
||||
create index if not exists claim_channel_hash_idx on claim (channel_hash, signature, claim_hash);
|
||||
create index if not exists claim_claims_in_channel_idx on claim (signature_valid, channel_hash, normalized);
|
||||
create index if not exists claim_txo_hash_idx on claim (txo_hash);
|
||||
create index if not exists claim_activation_height_idx on claim (activation_height, claim_hash);
|
||||
create index if not exists claim_expiration_height_idx on claim (expiration_height);
|
||||
create index if not exists claim_reposted_claim_hash_idx on claim (reposted_claim_hash);
|
||||
"""
|
||||
|
||||
CREATE_SUPPORT_TABLE = """
|
||||
create table if not exists support (
|
||||
txo_hash bytes primary key,
|
||||
tx_position integer not null,
|
||||
height integer not null,
|
||||
claim_hash bytes not null,
|
||||
amount integer not null
|
||||
);
|
||||
create index if not exists support_claim_hash_idx on support (claim_hash, height);
|
||||
"""
|
||||
|
||||
CREATE_TAG_TABLE = """
|
||||
create table if not exists tag (
|
||||
tag text not null,
|
||||
claim_hash bytes not null,
|
||||
height integer not null
|
||||
);
|
||||
create unique index if not exists tag_claim_hash_tag_idx on tag (claim_hash, tag);
|
||||
"""
|
||||
|
||||
CREATE_LANGUAGE_TABLE = """
|
||||
create table if not exists language (
|
||||
language text not null,
|
||||
claim_hash bytes not null,
|
||||
height integer not null
|
||||
);
|
||||
create unique index if not exists language_claim_hash_language_idx on language (claim_hash, language);
|
||||
"""
|
||||
|
||||
CREATE_CLAIMTRIE_TABLE = """
|
||||
create table if not exists claimtrie (
|
||||
normalized text primary key,
|
||||
claim_hash bytes not null,
|
||||
last_take_over_height integer not null
|
||||
);
|
||||
create index if not exists claimtrie_claim_hash_idx on claimtrie (claim_hash);
|
||||
"""
|
||||
|
||||
CREATE_CHANGELOG_TRIGGER = """
|
||||
create table if not exists changelog (
|
||||
claim_hash bytes primary key
|
||||
);
|
||||
create index if not exists claimtrie_claim_hash_idx on claimtrie (claim_hash);
|
||||
create trigger if not exists claim_changelog after update on claim
|
||||
begin
|
||||
insert or ignore into changelog (claim_hash) values (new.claim_hash);
|
||||
end;
|
||||
create trigger if not exists claimtrie_changelog after update on claimtrie
|
||||
begin
|
||||
insert or ignore into changelog (claim_hash) values (new.claim_hash);
|
||||
insert or ignore into changelog (claim_hash) values (old.claim_hash);
|
||||
end;
|
||||
"""
|
||||
|
||||
SEARCH_INDEXES = """
|
||||
-- used by any tag clouds
|
||||
create index if not exists tag_tag_idx on tag (tag, claim_hash);
|
||||
|
||||
-- naked order bys (no filters)
|
||||
create unique index if not exists claim_release_idx on claim (release_time, claim_hash);
|
||||
create unique index if not exists claim_trending_idx on claim (trending_group, trending_mixed, claim_hash);
|
||||
create unique index if not exists claim_effective_amount_idx on claim (effective_amount, claim_hash);
|
||||
|
||||
-- claim_type filter + order by
|
||||
create unique index if not exists claim_type_release_idx on claim (release_time, claim_type, claim_hash);
|
||||
create unique index if not exists claim_type_trending_idx on claim (trending_group, trending_mixed, claim_type, claim_hash);
|
||||
create unique index if not exists claim_type_effective_amount_idx on claim (effective_amount, claim_type, claim_hash);
|
||||
|
||||
-- stream_type filter + order by
|
||||
create unique index if not exists stream_type_release_idx on claim (stream_type, release_time, claim_hash);
|
||||
create unique index if not exists stream_type_trending_idx on claim (stream_type, trending_group, trending_mixed, claim_hash);
|
||||
create unique index if not exists stream_type_effective_amount_idx on claim (stream_type, effective_amount, claim_hash);
|
||||
|
||||
-- channel_hash filter + order by
|
||||
create unique index if not exists channel_hash_release_idx on claim (channel_hash, release_time, claim_hash);
|
||||
create unique index if not exists channel_hash_trending_idx on claim (channel_hash, trending_group, trending_mixed, claim_hash);
|
||||
create unique index if not exists channel_hash_effective_amount_idx on claim (channel_hash, effective_amount, claim_hash);
|
||||
|
||||
-- duration filter + order by
|
||||
create unique index if not exists duration_release_idx on claim (duration, release_time, claim_hash);
|
||||
create unique index if not exists duration_trending_idx on claim (duration, trending_group, trending_mixed, claim_hash);
|
||||
create unique index if not exists duration_effective_amount_idx on claim (duration, effective_amount, claim_hash);
|
||||
|
||||
-- fee_amount + order by
|
||||
create unique index if not exists fee_amount_release_idx on claim (fee_amount, release_time, claim_hash);
|
||||
create unique index if not exists fee_amount_trending_idx on claim (fee_amount, trending_group, trending_mixed, claim_hash);
|
||||
create unique index if not exists fee_amount_effective_amount_idx on claim (fee_amount, effective_amount, claim_hash);
|
||||
|
||||
-- TODO: verify that all indexes below are used
|
||||
create index if not exists claim_height_normalized_idx on claim (height, normalized asc);
|
||||
create index if not exists claim_resolve_idx on claim (normalized, claim_id);
|
||||
create index if not exists claim_id_idx on claim (claim_id, claim_hash);
|
||||
create index if not exists claim_timestamp_idx on claim (timestamp);
|
||||
create index if not exists claim_public_key_hash_idx on claim (public_key_hash);
|
||||
create index if not exists claim_signature_valid_idx on claim (signature_valid);
|
||||
"""
|
||||
|
||||
TAG_INDEXES = '\n'.join(
|
||||
f"create unique index if not exists tag_{tag_key}_idx on tag (tag, claim_hash) WHERE tag='{tag_value}';"
|
||||
for tag_value, tag_key in COMMON_TAGS.items()
|
||||
)
|
||||
|
||||
LANGUAGE_INDEXES = '\n'.join(
|
||||
f"create unique index if not exists language_{language}_idx on language (language, claim_hash) WHERE language='{language}';"
|
||||
for language in INDEXED_LANGUAGES
|
||||
)
|
||||
|
||||
CREATE_TABLES_QUERY = (
|
||||
CREATE_CLAIM_TABLE +
|
||||
CREATE_SUPPORT_TABLE +
|
||||
CREATE_CLAIMTRIE_TABLE +
|
||||
CREATE_TAG_TABLE +
|
||||
CREATE_CHANGELOG_TRIGGER +
|
||||
CREATE_LANGUAGE_TABLE
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self, main, path: str, blocking_channels: list, filtering_channels: list, trending: list):
|
||||
self.main = main
|
||||
self._db_path = path
|
||||
self.db = None
|
||||
self.logger = class_logger(__name__, self.__class__.__name__)
|
||||
self.ledger = Ledger if main.coin.NET == 'mainnet' else RegTestLedger
|
||||
self.blocked_streams = None
|
||||
self.blocked_channels = None
|
||||
self.blocking_channel_hashes = {
|
||||
unhexlify(channel_id)[::-1] for channel_id in blocking_channels if channel_id
|
||||
}
|
||||
self.filtered_streams = None
|
||||
self.filtered_channels = None
|
||||
self.filtering_channel_hashes = {
|
||||
unhexlify(channel_id)[::-1] for channel_id in filtering_channels if channel_id
|
||||
}
|
||||
self.trending = trending
|
||||
self.pending_deletes = set()
|
||||
|
||||
def open(self):
|
||||
self.db = sqlite3.connect(self._db_path, isolation_level=None, check_same_thread=False, uri=True)
|
||||
|
||||
def namedtuple_factory(cursor, row):
|
||||
Row = namedtuple('Row', (d[0] for d in cursor.description))
|
||||
return Row(*row)
|
||||
self.db.row_factory = namedtuple_factory
|
||||
self.db.executescript(self.PRAGMAS)
|
||||
self.db.executescript(self.CREATE_TABLES_QUERY)
|
||||
register_canonical_functions(self.db)
|
||||
self.blocked_streams = {}
|
||||
self.blocked_channels = {}
|
||||
self.filtered_streams = {}
|
||||
self.filtered_channels = {}
|
||||
self.update_blocked_and_filtered_claims()
|
||||
for algorithm in self.trending:
|
||||
algorithm.install(self.db)
|
||||
|
||||
def close(self):
|
||||
if self.db is not None:
|
||||
self.db.close()
|
||||
|
||||
def update_blocked_and_filtered_claims(self):
|
||||
self.update_claims_from_channel_hashes(
|
||||
self.blocked_streams, self.blocked_channels, self.blocking_channel_hashes
|
||||
)
|
||||
self.update_claims_from_channel_hashes(
|
||||
self.filtered_streams, self.filtered_channels, self.filtering_channel_hashes
|
||||
)
|
||||
self.filtered_streams.update(self.blocked_streams)
|
||||
self.filtered_channels.update(self.blocked_channels)
|
||||
|
||||
def update_claims_from_channel_hashes(self, shared_streams, shared_channels, channel_hashes):
|
||||
streams, channels = {}, {}
|
||||
if channel_hashes:
|
||||
sql = query(
|
||||
"SELECT repost.channel_hash, repost.reposted_claim_hash, target.claim_type "
|
||||
"FROM claim as repost JOIN claim AS target ON (target.claim_hash=repost.reposted_claim_hash)", **{
|
||||
'repost.reposted_claim_hash__is_not_null': 1,
|
||||
'repost.channel_hash__in': channel_hashes
|
||||
}
|
||||
)
|
||||
for blocked_claim in self.execute(*sql):
|
||||
if blocked_claim.claim_type == CLAIM_TYPES['stream']:
|
||||
streams[blocked_claim.reposted_claim_hash] = blocked_claim.channel_hash
|
||||
elif blocked_claim.claim_type == CLAIM_TYPES['channel']:
|
||||
channels[blocked_claim.reposted_claim_hash] = blocked_claim.channel_hash
|
||||
shared_streams.clear()
|
||||
shared_streams.update(streams)
|
||||
shared_channels.clear()
|
||||
shared_channels.update(channels)
|
||||
|
||||
@staticmethod
|
||||
def _insert_sql(table: str, data: dict) -> Tuple[str, list]:
|
||||
columns, values = [], []
|
||||
for column, value in data.items():
|
||||
columns.append(column)
|
||||
values.append(value)
|
||||
sql = (
|
||||
f"INSERT INTO {table} ({', '.join(columns)}) "
|
||||
f"VALUES ({', '.join(['?'] * len(values))})"
|
||||
)
|
||||
return sql, values
|
||||
|
||||
@staticmethod
|
||||
def _update_sql(table: str, data: dict, where: str,
|
||||
constraints: Union[list, tuple]) -> Tuple[str, list]:
|
||||
columns, values = [], []
|
||||
for column, value in data.items():
|
||||
columns.append(f"{column} = ?")
|
||||
values.append(value)
|
||||
values.extend(constraints)
|
||||
return f"UPDATE {table} SET {', '.join(columns)} WHERE {where}", values
|
||||
|
||||
@staticmethod
|
||||
def _delete_sql(table: str, constraints: dict) -> Tuple[str, dict]:
|
||||
where, values = constraints_to_sql(constraints)
|
||||
return f"DELETE FROM {table} WHERE {where}", values
|
||||
|
||||
def execute(self, *args):
|
||||
return self.db.execute(*args)
|
||||
|
||||
def executemany(self, *args):
|
||||
return self.db.executemany(*args)
|
||||
|
||||
def begin(self):
|
||||
self.execute('begin;')
|
||||
|
||||
def commit(self):
|
||||
self.execute('commit;')
|
||||
|
||||
def _upsertable_claims(self, txos: List[Output], header, clear_first=False):
|
||||
claim_hashes, claims, tags, languages = set(), [], {}, {}
|
||||
for txo in txos:
|
||||
tx = txo.tx_ref.tx
|
||||
|
||||
try:
|
||||
assert txo.claim_name
|
||||
assert txo.normalized_name
|
||||
except:
|
||||
#self.logger.exception(f"Could not decode claim name for {tx.id}:{txo.position}.")
|
||||
continue
|
||||
|
||||
language = 'none'
|
||||
try:
|
||||
if txo.claim.is_stream and txo.claim.stream.languages:
|
||||
language = txo.claim.stream.languages[0].language
|
||||
except:
|
||||
pass
|
||||
|
||||
claim_hash = txo.claim_hash
|
||||
claim_hashes.add(claim_hash)
|
||||
claim_record = {
|
||||
'claim_hash': claim_hash,
|
||||
'claim_id': txo.claim_id,
|
||||
'claim_name': txo.claim_name,
|
||||
'normalized': txo.normalized_name,
|
||||
'txo_hash': txo.ref.hash,
|
||||
'tx_position': tx.position,
|
||||
'amount': txo.amount,
|
||||
'timestamp': header['timestamp'],
|
||||
'height': tx.height,
|
||||
'title': None,
|
||||
'description': None,
|
||||
'author': None,
|
||||
'duration': None,
|
||||
'claim_type': None,
|
||||
'has_source': False,
|
||||
'stream_type': None,
|
||||
'media_type': None,
|
||||
'release_time': None,
|
||||
'fee_currency': None,
|
||||
'fee_amount': 0,
|
||||
'reposted_claim_hash': None
|
||||
}
|
||||
claims.append(claim_record)
|
||||
|
||||
try:
|
||||
claim = txo.claim
|
||||
except:
|
||||
#self.logger.exception(f"Could not parse claim protobuf for {tx.id}:{txo.position}.")
|
||||
continue
|
||||
|
||||
if claim.is_stream:
|
||||
claim_record['claim_type'] = CLAIM_TYPES['stream']
|
||||
claim_record['has_source'] = claim.stream.has_source
|
||||
claim_record['media_type'] = claim.stream.source.media_type
|
||||
claim_record['stream_type'] = STREAM_TYPES[guess_stream_type(claim_record['media_type'])]
|
||||
claim_record['title'] = claim.stream.title
|
||||
claim_record['description'] = claim.stream.description
|
||||
claim_record['author'] = claim.stream.author
|
||||
if claim.stream.video and claim.stream.video.duration:
|
||||
claim_record['duration'] = claim.stream.video.duration
|
||||
if claim.stream.audio and claim.stream.audio.duration:
|
||||
claim_record['duration'] = claim.stream.audio.duration
|
||||
if claim.stream.release_time:
|
||||
claim_record['release_time'] = claim.stream.release_time
|
||||
if claim.stream.has_fee:
|
||||
fee = claim.stream.fee
|
||||
if isinstance(fee.currency, str):
|
||||
claim_record['fee_currency'] = fee.currency.lower()
|
||||
if isinstance(fee.amount, Decimal):
|
||||
if fee.amount >= 0 and int(fee.amount*1000) < 9223372036854775807:
|
||||
claim_record['fee_amount'] = int(fee.amount*1000)
|
||||
elif claim.is_repost:
|
||||
claim_record['claim_type'] = CLAIM_TYPES['repost']
|
||||
claim_record['reposted_claim_hash'] = claim.repost.reference.claim_hash
|
||||
elif claim.is_channel:
|
||||
claim_record['claim_type'] = CLAIM_TYPES['channel']
|
||||
elif claim.is_collection:
|
||||
claim_record['claim_type'] = CLAIM_TYPES['collection']
|
||||
|
||||
languages[(language, claim_hash)] = (language, claim_hash, tx.height)
|
||||
|
||||
for tag in clean_tags(claim.message.tags):
|
||||
tags[(tag, claim_hash)] = (tag, claim_hash, tx.height)
|
||||
|
||||
if clear_first:
|
||||
self._clear_claim_metadata(claim_hashes)
|
||||
|
||||
if tags:
|
||||
self.executemany(
|
||||
"INSERT OR IGNORE INTO tag (tag, claim_hash, height) VALUES (?, ?, ?)", tags.values()
|
||||
)
|
||||
if languages:
|
||||
self.executemany(
|
||||
"INSERT OR IGNORE INTO language (language, claim_hash, height) VALUES (?, ?, ?)", languages.values()
|
||||
)
|
||||
|
||||
return claims
|
||||
|
||||
def insert_claims(self, txos: List[Output], header):
|
||||
claims = self._upsertable_claims(txos, header)
|
||||
if claims:
|
||||
self.executemany("""
|
||||
INSERT OR REPLACE INTO claim (
|
||||
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
|
||||
claim_type, media_type, stream_type, timestamp, creation_timestamp, has_source,
|
||||
fee_currency, fee_amount, title, description, author, duration, height, reposted_claim_hash,
|
||||
creation_height, release_time, activation_height, expiration_height, short_url)
|
||||
VALUES (
|
||||
:claim_hash, :claim_id, :claim_name, :normalized, :txo_hash, :tx_position, :amount,
|
||||
:claim_type, :media_type, :stream_type, :timestamp, :timestamp, :has_source,
|
||||
:fee_currency, :fee_amount, :title, :description, :author, :duration, :height, :reposted_claim_hash, :height,
|
||||
CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE :timestamp END,
|
||||
CASE WHEN :normalized NOT IN (SELECT normalized FROM claimtrie) THEN :height END,
|
||||
CASE WHEN :height >= 137181 THEN :height+2102400 ELSE :height+262974 END,
|
||||
:claim_name||COALESCE(
|
||||
(SELECT shortest_id(claim_id, :claim_id) FROM claim WHERE normalized = :normalized),
|
||||
'#'||substr(:claim_id, 1, 1)
|
||||
)
|
||||
)""", claims)
|
||||
|
||||
def update_claims(self, txos: List[Output], header):
|
||||
claims = self._upsertable_claims(txos, header, clear_first=True)
|
||||
if claims:
|
||||
self.executemany("""
|
||||
UPDATE claim SET
|
||||
txo_hash=:txo_hash, tx_position=:tx_position, amount=:amount, height=:height,
|
||||
claim_type=:claim_type, media_type=:media_type, stream_type=:stream_type,
|
||||
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency, has_source=:has_source,
|
||||
title=:title, duration=:duration, description=:description, author=:author, reposted_claim_hash=:reposted_claim_hash,
|
||||
release_time=CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE release_time END
|
||||
WHERE claim_hash=:claim_hash;
|
||||
""", claims)
|
||||
|
||||
def delete_claims(self, claim_hashes: Set[bytes]):
|
||||
""" Deletes claim supports and from claimtrie in case of an abandon. """
|
||||
if claim_hashes:
|
||||
affected_channels = self.execute(*query(
|
||||
"SELECT channel_hash FROM claim", channel_hash__is_not_null=1, claim_hash__in=claim_hashes
|
||||
)).fetchall()
|
||||
for table in ('claim', 'support', 'claimtrie'):
|
||||
self.execute(*self._delete_sql(table, {'claim_hash__in': claim_hashes}))
|
||||
self._clear_claim_metadata(claim_hashes)
|
||||
return {r.channel_hash for r in affected_channels}
|
||||
return set()
|
||||
|
||||
def delete_claims_above_height(self, height: int):
|
||||
claim_hashes = [x[0] for x in self.execute(
|
||||
"SELECT claim_hash FROM claim WHERE height>?", (height, )
|
||||
).fetchall()]
|
||||
while claim_hashes:
|
||||
batch = set(claim_hashes[:500])
|
||||
claim_hashes = claim_hashes[500:]
|
||||
self.delete_claims(batch)
|
||||
|
||||
def _clear_claim_metadata(self, claim_hashes: Set[bytes]):
|
||||
if claim_hashes:
|
||||
for table in ('tag',): # 'language', 'location', etc
|
||||
self.execute(*self._delete_sql(table, {'claim_hash__in': claim_hashes}))
|
||||
|
||||
def split_inputs_into_claims_supports_and_other(self, txis):
|
||||
txo_hashes = {txi.txo_ref.hash for txi in txis}
|
||||
claims = self.execute(*query(
|
||||
"SELECT txo_hash, claim_hash, normalized FROM claim", txo_hash__in=txo_hashes
|
||||
)).fetchall()
|
||||
txo_hashes -= {r.txo_hash for r in claims}
|
||||
supports = {}
|
||||
if txo_hashes:
|
||||
supports = self.execute(*query(
|
||||
"SELECT txo_hash, claim_hash FROM support", txo_hash__in=txo_hashes
|
||||
)).fetchall()
|
||||
txo_hashes -= {r.txo_hash for r in supports}
|
||||
return claims, supports, txo_hashes
|
||||
|
||||
def insert_supports(self, txos: List[Output]):
|
||||
supports = []
|
||||
for txo in txos:
|
||||
tx = txo.tx_ref.tx
|
||||
supports.append((
|
||||
txo.ref.hash, tx.position, tx.height,
|
||||
txo.claim_hash, txo.amount
|
||||
))
|
||||
if supports:
|
||||
self.executemany(
|
||||
"INSERT OR IGNORE INTO support ("
|
||||
" txo_hash, tx_position, height, claim_hash, amount"
|
||||
") "
|
||||
"VALUES (?, ?, ?, ?, ?)", supports
|
||||
)
|
||||
|
||||
def delete_supports(self, txo_hashes: Set[bytes]):
|
||||
if txo_hashes:
|
||||
self.execute(*self._delete_sql('support', {'txo_hash__in': txo_hashes}))
|
||||
|
||||
def calculate_reposts(self, txos: List[Output]):
|
||||
targets = set()
|
||||
for txo in txos:
|
||||
try:
|
||||
claim = txo.claim
|
||||
except:
|
||||
continue
|
||||
if claim.is_repost:
|
||||
targets.add((claim.repost.reference.claim_hash,))
|
||||
if targets:
|
||||
self.executemany(
|
||||
"""
|
||||
UPDATE claim SET reposted = (
|
||||
SELECT count(*) FROM claim AS repost WHERE repost.reposted_claim_hash = claim.claim_hash
|
||||
)
|
||||
WHERE claim_hash = ?
|
||||
""", targets
|
||||
)
|
||||
return {target[0] for target in targets}
|
||||
|
||||
def validate_channel_signatures(self, height, new_claims, updated_claims, spent_claims, affected_channels, timer):
|
||||
if not new_claims and not updated_claims and not spent_claims:
|
||||
return
|
||||
|
||||
sub_timer = timer.add_timer('segregate channels and signables')
|
||||
sub_timer.start()
|
||||
channels, new_channel_keys, signables = {}, {}, {}
|
||||
for txo in chain(new_claims, updated_claims):
|
||||
try:
|
||||
claim = txo.claim
|
||||
except:
|
||||
continue
|
||||
if claim.is_channel:
|
||||
channels[txo.claim_hash] = txo
|
||||
new_channel_keys[txo.claim_hash] = claim.channel.public_key_bytes
|
||||
else:
|
||||
signables[txo.claim_hash] = txo
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('make list of channels we need to lookup')
|
||||
sub_timer.start()
|
||||
missing_channel_keys = set()
|
||||
for txo in signables.values():
|
||||
claim = txo.claim
|
||||
if claim.is_signed and claim.signing_channel_hash not in new_channel_keys:
|
||||
missing_channel_keys.add(claim.signing_channel_hash)
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('lookup missing channels')
|
||||
sub_timer.start()
|
||||
all_channel_keys = {}
|
||||
if new_channel_keys or missing_channel_keys or affected_channels:
|
||||
all_channel_keys = dict(self.execute(*query(
|
||||
"SELECT claim_hash, public_key_bytes FROM claim",
|
||||
claim_hash__in=set(new_channel_keys) | missing_channel_keys | affected_channels
|
||||
)))
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('prepare for updating claims')
|
||||
sub_timer.start()
|
||||
changed_channel_keys = {}
|
||||
for claim_hash, new_key in new_channel_keys.items():
|
||||
if claim_hash not in all_channel_keys or all_channel_keys[claim_hash] != new_key:
|
||||
all_channel_keys[claim_hash] = new_key
|
||||
changed_channel_keys[claim_hash] = new_key
|
||||
|
||||
claim_updates = []
|
||||
|
||||
for claim_hash, txo in signables.items():
|
||||
claim = txo.claim
|
||||
update = {
|
||||
'claim_hash': claim_hash,
|
||||
'channel_hash': None,
|
||||
'signature': None,
|
||||
'signature_digest': None,
|
||||
'signature_valid': None
|
||||
}
|
||||
if claim.is_signed:
|
||||
update.update({
|
||||
'channel_hash': claim.signing_channel_hash,
|
||||
'signature': txo.get_encoded_signature(),
|
||||
'signature_digest': txo.get_signature_digest(self.ledger),
|
||||
'signature_valid': 0
|
||||
})
|
||||
claim_updates.append(update)
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('find claims affected by a change in channel key')
|
||||
sub_timer.start()
|
||||
if changed_channel_keys:
|
||||
sql = f"""
|
||||
SELECT * FROM claim WHERE
|
||||
channel_hash IN ({','.join('?' for _ in changed_channel_keys)}) AND
|
||||
signature IS NOT NULL
|
||||
"""
|
||||
for affected_claim in self.execute(sql, list(changed_channel_keys.keys())):
|
||||
if affected_claim.claim_hash not in signables:
|
||||
claim_updates.append({
|
||||
'claim_hash': affected_claim.claim_hash,
|
||||
'channel_hash': affected_claim.channel_hash,
|
||||
'signature': affected_claim.signature,
|
||||
'signature_digest': affected_claim.signature_digest,
|
||||
'signature_valid': 0
|
||||
})
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('verify signatures')
|
||||
sub_timer.start()
|
||||
for update in claim_updates:
|
||||
channel_pub_key = all_channel_keys.get(update['channel_hash'])
|
||||
if channel_pub_key and update['signature']:
|
||||
update['signature_valid'] = Output.is_signature_valid(
|
||||
bytes(update['signature']), bytes(update['signature_digest']), channel_pub_key
|
||||
)
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('update claims')
|
||||
sub_timer.start()
|
||||
if claim_updates:
|
||||
self.executemany(f"""
|
||||
UPDATE claim SET
|
||||
channel_hash=:channel_hash, signature=:signature, signature_digest=:signature_digest,
|
||||
signature_valid=:signature_valid,
|
||||
channel_join=CASE
|
||||
WHEN signature_valid=1 AND :signature_valid=1 AND channel_hash=:channel_hash THEN channel_join
|
||||
WHEN :signature_valid=1 THEN {height}
|
||||
END,
|
||||
canonical_url=CASE
|
||||
WHEN signature_valid=1 AND :signature_valid=1 AND channel_hash=:channel_hash THEN canonical_url
|
||||
WHEN :signature_valid=1 THEN
|
||||
(SELECT short_url FROM claim WHERE claim_hash=:channel_hash)||'/'||
|
||||
claim_name||COALESCE(
|
||||
(SELECT shortest_id(other_claim.claim_id, claim.claim_id) FROM claim AS other_claim
|
||||
WHERE other_claim.signature_valid = 1 AND
|
||||
other_claim.channel_hash = :channel_hash AND
|
||||
other_claim.normalized = claim.normalized),
|
||||
'#'||substr(claim_id, 1, 1)
|
||||
)
|
||||
END
|
||||
WHERE claim_hash=:claim_hash;
|
||||
""", claim_updates)
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('update claims affected by spent channels')
|
||||
sub_timer.start()
|
||||
if spent_claims:
|
||||
self.execute(
|
||||
f"""
|
||||
UPDATE claim SET
|
||||
signature_valid=CASE WHEN signature IS NOT NULL THEN 0 END,
|
||||
channel_join=NULL, canonical_url=NULL
|
||||
WHERE channel_hash IN ({','.join('?' for _ in spent_claims)})
|
||||
""", list(spent_claims)
|
||||
)
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('update channels')
|
||||
sub_timer.start()
|
||||
if channels:
|
||||
self.executemany(
|
||||
"""
|
||||
UPDATE claim SET
|
||||
public_key_bytes=:public_key_bytes,
|
||||
public_key_hash=:public_key_hash
|
||||
WHERE claim_hash=:claim_hash""", [{
|
||||
'claim_hash': claim_hash,
|
||||
'public_key_bytes': txo.claim.channel.public_key_bytes,
|
||||
'public_key_hash': self.ledger.address_to_hash160(
|
||||
self.ledger.public_key_to_address(txo.claim.channel.public_key_bytes)
|
||||
)
|
||||
} for claim_hash, txo in channels.items()]
|
||||
)
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('update claims_in_channel counts')
|
||||
sub_timer.start()
|
||||
if all_channel_keys:
|
||||
self.executemany(f"""
|
||||
UPDATE claim SET
|
||||
claims_in_channel=(
|
||||
SELECT COUNT(*) FROM claim AS claim_in_channel
|
||||
WHERE claim_in_channel.signature_valid=1 AND
|
||||
claim_in_channel.channel_hash=claim.claim_hash
|
||||
)
|
||||
WHERE claim_hash = ?
|
||||
""", [(channel_hash,) for channel_hash in all_channel_keys])
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('update blocked claims list')
|
||||
sub_timer.start()
|
||||
if (self.blocking_channel_hashes.intersection(all_channel_keys) or
|
||||
self.filtering_channel_hashes.intersection(all_channel_keys)):
|
||||
self.update_blocked_and_filtered_claims()
|
||||
sub_timer.stop()
|
||||
|
||||
def _update_support_amount(self, claim_hashes):
|
||||
if claim_hashes:
|
||||
self.execute(f"""
|
||||
UPDATE claim SET
|
||||
support_amount = COALESCE(
|
||||
(SELECT SUM(amount) FROM support WHERE support.claim_hash=claim.claim_hash), 0
|
||||
)
|
||||
WHERE claim_hash IN ({','.join('?' for _ in claim_hashes)})
|
||||
""", claim_hashes)
|
||||
|
||||
def _update_effective_amount(self, height, claim_hashes=None):
|
||||
self.execute(
|
||||
f"UPDATE claim SET effective_amount = amount + support_amount "
|
||||
f"WHERE activation_height = {height}"
|
||||
)
|
||||
if claim_hashes:
|
||||
self.execute(
|
||||
f"UPDATE claim SET effective_amount = amount + support_amount "
|
||||
f"WHERE activation_height < {height} "
|
||||
f" AND claim_hash IN ({','.join('?' for _ in claim_hashes)})",
|
||||
claim_hashes
|
||||
)
|
||||
|
||||
def _calculate_activation_height(self, height):
|
||||
last_take_over_height = f"""COALESCE(
|
||||
(SELECT last_take_over_height FROM claimtrie
|
||||
WHERE claimtrie.normalized=claim.normalized),
|
||||
{height}
|
||||
)
|
||||
"""
|
||||
self.execute(f"""
|
||||
UPDATE claim SET activation_height =
|
||||
{height} + min(4032, cast(({height} - {last_take_over_height}) / 32 AS INT))
|
||||
WHERE activation_height IS NULL
|
||||
""")
|
||||
|
||||
def _perform_overtake(self, height, changed_claim_hashes, deleted_names):
|
||||
deleted_names_sql = claim_hashes_sql = ""
|
||||
if changed_claim_hashes:
|
||||
claim_hashes_sql = f"OR claim_hash IN ({','.join('?' for _ in changed_claim_hashes)})"
|
||||
if deleted_names:
|
||||
deleted_names_sql = f"OR normalized IN ({','.join('?' for _ in deleted_names)})"
|
||||
overtakes = self.execute(f"""
|
||||
SELECT winner.normalized, winner.claim_hash,
|
||||
claimtrie.claim_hash AS current_winner,
|
||||
MAX(winner.effective_amount) AS max_winner_effective_amount
|
||||
FROM (
|
||||
SELECT normalized, claim_hash, effective_amount FROM claim
|
||||
WHERE normalized IN (
|
||||
SELECT normalized FROM claim WHERE activation_height={height} {claim_hashes_sql}
|
||||
) {deleted_names_sql}
|
||||
ORDER BY effective_amount DESC, height ASC, tx_position ASC
|
||||
) AS winner LEFT JOIN claimtrie USING (normalized)
|
||||
GROUP BY winner.normalized
|
||||
HAVING current_winner IS NULL OR current_winner <> winner.claim_hash
|
||||
""", list(changed_claim_hashes)+deleted_names)
|
||||
for overtake in overtakes:
|
||||
if overtake.current_winner:
|
||||
self.execute(
|
||||
f"UPDATE claimtrie SET claim_hash = ?, last_take_over_height = {height} "
|
||||
f"WHERE normalized = ?",
|
||||
(overtake.claim_hash, overtake.normalized)
|
||||
)
|
||||
else:
|
||||
self.execute(
|
||||
f"INSERT INTO claimtrie (claim_hash, normalized, last_take_over_height) "
|
||||
f"VALUES (?, ?, {height})",
|
||||
(overtake.claim_hash, overtake.normalized)
|
||||
)
|
||||
self.execute(
|
||||
f"UPDATE claim SET activation_height = {height} WHERE normalized = ? "
|
||||
f"AND (activation_height IS NULL OR activation_height > {height})",
|
||||
(overtake.normalized,)
|
||||
)
|
||||
|
||||
def _copy(self, height):
|
||||
if height > 50:
|
||||
self.execute(f"DROP TABLE claimtrie{height-50}")
|
||||
self.execute(f"CREATE TABLE claimtrie{height} AS SELECT * FROM claimtrie")
|
||||
|
||||
def update_claimtrie(self, height, changed_claim_hashes, deleted_names, timer):
|
||||
r = timer.run
|
||||
binary_claim_hashes = list(changed_claim_hashes)
|
||||
|
||||
r(self._calculate_activation_height, height)
|
||||
r(self._update_support_amount, binary_claim_hashes)
|
||||
|
||||
r(self._update_effective_amount, height, binary_claim_hashes)
|
||||
r(self._perform_overtake, height, binary_claim_hashes, list(deleted_names))
|
||||
|
||||
r(self._update_effective_amount, height)
|
||||
r(self._perform_overtake, height, [], [])
|
||||
|
||||
def get_expiring(self, height):
|
||||
return self.execute(
|
||||
f"SELECT claim_hash, normalized FROM claim WHERE expiration_height = {height}"
|
||||
)
|
||||
|
||||
def enqueue_changes(self):
|
||||
query = """
|
||||
SELECT claimtrie.claim_hash as is_controlling,
|
||||
claimtrie.last_take_over_height,
|
||||
(select group_concat(tag, ',,') from tag where tag.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as tags,
|
||||
(select group_concat(language, ' ') from language where language.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as languages,
|
||||
cr.has_source as reposted_has_source,
|
||||
cr.claim_type as reposted_claim_type,
|
||||
cr.stream_type as reposted_stream_type,
|
||||
cr.media_type as reposted_media_type,
|
||||
cr.duration as reposted_duration,
|
||||
cr.fee_amount as reposted_fee_amount,
|
||||
cr.fee_currency as reposted_fee_currency,
|
||||
claim.*
|
||||
FROM claim LEFT JOIN claimtrie USING (claim_hash) LEFT JOIN claim cr ON cr.claim_hash=claim.reposted_claim_hash
|
||||
WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
|
||||
"""
|
||||
for claim in self.execute(query):
|
||||
claim = claim._asdict()
|
||||
id_set = set(filter(None, (claim['claim_hash'], claim['channel_hash'], claim['reposted_claim_hash'])))
|
||||
claim['censor_type'] = 0
|
||||
censoring_channel_hash = None
|
||||
claim['has_source'] = bool(claim.pop('reposted_has_source') or claim['has_source'])
|
||||
claim['stream_type'] = claim.pop('reposted_stream_type') or claim['stream_type']
|
||||
claim['media_type'] = claim.pop('reposted_media_type') or claim['media_type']
|
||||
claim['fee_amount'] = claim.pop('reposted_fee_amount') or claim['fee_amount']
|
||||
claim['fee_currency'] = claim.pop('reposted_fee_currency') or claim['fee_currency']
|
||||
claim['duration'] = claim.pop('reposted_duration') or claim['duration']
|
||||
for reason_id in id_set:
|
||||
if reason_id in self.blocked_streams:
|
||||
claim['censor_type'] = 2
|
||||
censoring_channel_hash = self.blocked_streams.get(reason_id)
|
||||
elif reason_id in self.blocked_channels:
|
||||
claim['censor_type'] = 2
|
||||
censoring_channel_hash = self.blocked_channels.get(reason_id)
|
||||
elif reason_id in self.filtered_streams:
|
||||
claim['censor_type'] = 1
|
||||
censoring_channel_hash = self.filtered_streams.get(reason_id)
|
||||
elif reason_id in self.filtered_channels:
|
||||
claim['censor_type'] = 1
|
||||
censoring_channel_hash = self.filtered_channels.get(reason_id)
|
||||
claim['censoring_channel_id'] = censoring_channel_hash[::-1].hex() if censoring_channel_hash else None
|
||||
|
||||
claim['tags'] = claim['tags'].split(',,') if claim['tags'] else []
|
||||
claim['languages'] = claim['languages'].split(' ') if claim['languages'] else []
|
||||
yield 'update', claim
|
||||
|
||||
def clear_changelog(self):
|
||||
self.execute("delete from changelog;")
|
||||
|
||||
def claim_producer(self):
|
||||
while self.pending_deletes:
|
||||
claim_hash = self.pending_deletes.pop()
|
||||
yield 'delete', hexlify(claim_hash[::-1]).decode()
|
||||
for claim in self.enqueue_changes():
|
||||
yield claim
|
||||
self.clear_changelog()
|
||||
|
||||
def advance_txs(self, height, all_txs, header, daemon_height, timer):
|
||||
insert_claims = []
|
||||
update_claims = []
|
||||
update_claim_hashes = set()
|
||||
delete_claim_hashes = self.pending_deletes
|
||||
insert_supports = []
|
||||
delete_support_txo_hashes = set()
|
||||
recalculate_claim_hashes = set() # added/deleted supports, added/updated claim
|
||||
deleted_claim_names = set()
|
||||
delete_others = set()
|
||||
body_timer = timer.add_timer('body')
|
||||
for position, (etx, txid) in enumerate(all_txs):
|
||||
tx = timer.run(
|
||||
Transaction, etx.raw, height=height, position=position
|
||||
)
|
||||
# Inputs
|
||||
spent_claims, spent_supports, spent_others = timer.run(
|
||||
self.split_inputs_into_claims_supports_and_other, tx.inputs
|
||||
)
|
||||
body_timer.start()
|
||||
delete_claim_hashes.update({r.claim_hash for r in spent_claims})
|
||||
deleted_claim_names.update({r.normalized for r in spent_claims})
|
||||
delete_support_txo_hashes.update({r.txo_hash for r in spent_supports})
|
||||
recalculate_claim_hashes.update({r.claim_hash for r in spent_supports})
|
||||
delete_others.update(spent_others)
|
||||
# Outputs
|
||||
for output in tx.outputs:
|
||||
if output.is_support:
|
||||
insert_supports.append(output)
|
||||
recalculate_claim_hashes.add(output.claim_hash)
|
||||
elif output.script.is_claim_name:
|
||||
insert_claims.append(output)
|
||||
recalculate_claim_hashes.add(output.claim_hash)
|
||||
elif output.script.is_update_claim:
|
||||
claim_hash = output.claim_hash
|
||||
update_claims.append(output)
|
||||
recalculate_claim_hashes.add(claim_hash)
|
||||
body_timer.stop()
|
||||
|
||||
skip_update_claim_timer = timer.add_timer('skip update of abandoned claims')
|
||||
skip_update_claim_timer.start()
|
||||
for updated_claim in list(update_claims):
|
||||
if updated_claim.ref.hash in delete_others:
|
||||
update_claims.remove(updated_claim)
|
||||
for updated_claim in update_claims:
|
||||
claim_hash = updated_claim.claim_hash
|
||||
delete_claim_hashes.discard(claim_hash)
|
||||
update_claim_hashes.add(claim_hash)
|
||||
skip_update_claim_timer.stop()
|
||||
|
||||
skip_insert_claim_timer = timer.add_timer('skip insertion of abandoned claims')
|
||||
skip_insert_claim_timer.start()
|
||||
for new_claim in list(insert_claims):
|
||||
if new_claim.ref.hash in delete_others:
|
||||
if new_claim.claim_hash not in update_claim_hashes:
|
||||
insert_claims.remove(new_claim)
|
||||
skip_insert_claim_timer.stop()
|
||||
|
||||
skip_insert_support_timer = timer.add_timer('skip insertion of abandoned supports')
|
||||
skip_insert_support_timer.start()
|
||||
for new_support in list(insert_supports):
|
||||
if new_support.ref.hash in delete_others:
|
||||
insert_supports.remove(new_support)
|
||||
skip_insert_support_timer.stop()
|
||||
|
||||
expire_timer = timer.add_timer('recording expired claims')
|
||||
expire_timer.start()
|
||||
for expired in self.get_expiring(height):
|
||||
delete_claim_hashes.add(expired.claim_hash)
|
||||
deleted_claim_names.add(expired.normalized)
|
||||
expire_timer.stop()
|
||||
|
||||
r = timer.run
|
||||
affected_channels = r(self.delete_claims, delete_claim_hashes)
|
||||
r(self.delete_supports, delete_support_txo_hashes)
|
||||
r(self.insert_claims, insert_claims, header)
|
||||
r(self.calculate_reposts, insert_claims)
|
||||
r(self.update_claims, update_claims, header)
|
||||
r(self.validate_channel_signatures, height, insert_claims,
|
||||
update_claims, delete_claim_hashes, affected_channels, forward_timer=True)
|
||||
r(self.insert_supports, insert_supports)
|
||||
r(self.update_claimtrie, height, recalculate_claim_hashes, deleted_claim_names, forward_timer=True)
|
||||
for algorithm in self.trending:
|
||||
r(algorithm.run, self.db.cursor(), height, daemon_height, recalculate_claim_hashes)
|
||||
|
||||
|
||||
class LBRYLevelDB(LevelDB):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
path = os.path.join(self.env.db_dir, 'claims.db')
|
||||
trending = []
|
||||
for algorithm_name in self.env.trending_algorithms:
|
||||
if algorithm_name in TRENDING_ALGORITHMS:
|
||||
trending.append(TRENDING_ALGORITHMS[algorithm_name])
|
||||
if self.env.es_mode == 'reader':
|
||||
self.logger.info('Index mode: reader')
|
||||
self.sql = None
|
||||
else:
|
||||
self.logger.info('Index mode: writer. Using SQLite db to sync ES')
|
||||
self.sql = SQLDB(
|
||||
self, path,
|
||||
self.env.default('BLOCKING_CHANNEL_IDS', '').split(' '),
|
||||
self.env.default('FILTERING_CHANNEL_IDS', '').split(' '),
|
||||
trending
|
||||
)
|
||||
|
||||
# Search index
|
||||
self.search_index = SearchIndex(
|
||||
self.env.es_index_prefix, self.env.database_query_timeout, self.env.elastic_host, self.env.elastic_port
|
||||
)
|
||||
|
||||
def close(self):
|
||||
super().close()
|
||||
if self.sql:
|
||||
self.sql.close()
|
||||
|
||||
async def _open_dbs(self, *args, **kwargs):
|
||||
await self.search_index.start()
|
||||
await super()._open_dbs(*args, **kwargs)
|
||||
if self.sql:
|
||||
self.sql.open()
|
||||
+61
-169
@@ -5,7 +5,7 @@
|
||||
# See the file "LICENCE" for information about the copyright
|
||||
# and warranty status of this software.
|
||||
|
||||
import math
|
||||
|
||||
import re
|
||||
import resource
|
||||
from os import environ
|
||||
@@ -13,7 +13,7 @@ from collections import namedtuple
|
||||
from ipaddress import ip_address
|
||||
|
||||
from lbry.wallet.server.util import class_logger
|
||||
from lbry.wallet.server.coin import Coin, LBC, LBCTestNet, LBCRegTest
|
||||
from lbry.wallet.server.coin import Coin
|
||||
import lbry.wallet.server.util as lib_util
|
||||
|
||||
|
||||
@@ -28,84 +28,73 @@ class Env:
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, coin=None, db_dir=None, daemon_url=None, host=None, rpc_host=None, elastic_host=None,
|
||||
elastic_port=None, loop_policy=None, max_query_workers=None, websocket_host=None, websocket_port=None,
|
||||
chain=None, es_index_prefix=None, es_mode=None, cache_MB=None, reorg_limit=None, tcp_port=None,
|
||||
udp_port=None, ssl_port=None, ssl_certfile=None, ssl_keyfile=None, rpc_port=None,
|
||||
prometheus_port=None, max_subscriptions=None, banner_file=None, anon_logs=None, log_sessions=None,
|
||||
allow_lan_udp=None, cache_all_tx_hashes=None, cache_all_claim_txos=None, country=None,
|
||||
payment_address=None, donation_address=None, max_send=None, max_receive=None, max_sessions=None,
|
||||
session_timeout=None, drop_client=None, description=None, daily_fee=None,
|
||||
database_query_timeout=None, db_max_open_files=512):
|
||||
def __init__(self, coin=None):
|
||||
self.logger = class_logger(__name__, self.__class__.__name__)
|
||||
|
||||
self.db_dir = db_dir if db_dir is not None else self.required('DB_DIRECTORY')
|
||||
self.daemon_url = daemon_url if daemon_url is not None else self.required('DAEMON_URL')
|
||||
self.db_max_open_files = db_max_open_files
|
||||
|
||||
self.host = host if host is not None else self.default('HOST', 'localhost')
|
||||
self.rpc_host = rpc_host if rpc_host is not None else self.default('RPC_HOST', 'localhost')
|
||||
self.elastic_host = elastic_host if elastic_host is not None else self.default('ELASTIC_HOST', 'localhost')
|
||||
self.elastic_port = elastic_port if elastic_port is not None else self.integer('ELASTIC_PORT', 9200)
|
||||
self.loop_policy = self.set_event_loop_policy(
|
||||
loop_policy if loop_policy is not None else self.default('EVENT_LOOP_POLICY', None)
|
||||
)
|
||||
self.allow_root = self.boolean('ALLOW_ROOT', False)
|
||||
self.host = self.default('HOST', 'localhost')
|
||||
self.rpc_host = self.default('RPC_HOST', 'localhost')
|
||||
self.elastic_host = self.default('ELASTIC_HOST', 'localhost')
|
||||
self.elastic_port = self.integer('ELASTIC_PORT', 9200)
|
||||
self.loop_policy = self.set_event_loop_policy()
|
||||
self.obsolete(['UTXO_MB', 'HIST_MB', 'NETWORK'])
|
||||
self.max_query_workers = max_query_workers if max_query_workers is not None else self.integer('MAX_QUERY_WORKERS', 4)
|
||||
self.websocket_host = websocket_host if websocket_host is not None else self.default('WEBSOCKET_HOST', self.host)
|
||||
self.websocket_port = websocket_port if websocket_port is not None else self.integer('WEBSOCKET_PORT', None)
|
||||
self.db_dir = self.required('DB_DIRECTORY')
|
||||
self.db_engine = self.default('DB_ENGINE', 'leveldb')
|
||||
self.trending_algorithms = [
|
||||
trending for trending in set(self.default('TRENDING_ALGORITHMS', 'zscore').split(' ')) if trending
|
||||
]
|
||||
self.max_query_workers = self.integer('MAX_QUERY_WORKERS', None)
|
||||
self.individual_tag_indexes = self.boolean('INDIVIDUAL_TAG_INDEXES', True)
|
||||
self.track_metrics = self.boolean('TRACK_METRICS', False)
|
||||
self.websocket_host = self.default('WEBSOCKET_HOST', self.host)
|
||||
self.websocket_port = self.integer('WEBSOCKET_PORT', None)
|
||||
self.daemon_url = self.required('DAEMON_URL')
|
||||
if coin is not None:
|
||||
assert issubclass(coin, Coin)
|
||||
self.coin = coin
|
||||
else:
|
||||
chain = chain if chain is not None else self.default('NET', 'mainnet').strip().lower()
|
||||
if chain == 'mainnet':
|
||||
self.coin = LBC
|
||||
elif chain == 'testnet':
|
||||
self.coin = LBCTestNet
|
||||
else:
|
||||
self.coin = LBCRegTest
|
||||
self.es_index_prefix = es_index_prefix if es_index_prefix is not None else self.default('ES_INDEX_PREFIX', '')
|
||||
self.es_mode = es_mode if es_mode is not None else self.default('ES_MODE', 'writer')
|
||||
self.cache_MB = cache_MB if cache_MB is not None else self.integer('CACHE_MB', 1024)
|
||||
self.reorg_limit = reorg_limit if reorg_limit is not None else self.integer('REORG_LIMIT', self.coin.REORG_LIMIT)
|
||||
coin_name = self.required('COIN').strip()
|
||||
network = self.default('NET', 'mainnet').strip()
|
||||
self.coin = Coin.lookup_coin_class(coin_name, network)
|
||||
self.es_index_prefix = self.default('ES_INDEX_PREFIX', '')
|
||||
self.es_mode = self.default('ES_MODE', 'writer')
|
||||
self.cache_MB = self.integer('CACHE_MB', 1200)
|
||||
self.reorg_limit = self.integer('REORG_LIMIT', self.coin.REORG_LIMIT)
|
||||
# Server stuff
|
||||
self.tcp_port = tcp_port if tcp_port is not None else self.integer('TCP_PORT', None)
|
||||
self.udp_port = udp_port if udp_port is not None else self.integer('UDP_PORT', self.tcp_port)
|
||||
self.ssl_port = ssl_port if ssl_port is not None else self.integer('SSL_PORT', None)
|
||||
self.tcp_port = self.integer('TCP_PORT', None)
|
||||
self.udp_port = self.integer('UDP_PORT', self.tcp_port)
|
||||
self.ssl_port = self.integer('SSL_PORT', None)
|
||||
if self.ssl_port:
|
||||
self.ssl_certfile = ssl_certfile if ssl_certfile is not None else self.required('SSL_CERTFILE')
|
||||
self.ssl_keyfile = ssl_keyfile if ssl_keyfile is not None else self.required('SSL_KEYFILE')
|
||||
self.rpc_port = rpc_port if rpc_port is not None else self.integer('RPC_PORT', 8000)
|
||||
self.prometheus_port = prometheus_port if prometheus_port is not None else self.integer('PROMETHEUS_PORT', 0)
|
||||
self.max_subscriptions = max_subscriptions if max_subscriptions is not None else self.integer('MAX_SUBSCRIPTIONS', 10000)
|
||||
self.banner_file = banner_file if banner_file is not None else self.default('BANNER_FILE', None)
|
||||
# self.tor_banner_file = self.default('TOR_BANNER_FILE', self.banner_file)
|
||||
self.anon_logs = anon_logs if anon_logs is not None else self.boolean('ANON_LOGS', False)
|
||||
self.log_sessions = log_sessions if log_sessions is not None else self.integer('LOG_SESSIONS', 3600)
|
||||
self.allow_lan_udp = allow_lan_udp if allow_lan_udp is not None else self.boolean('ALLOW_LAN_UDP', False)
|
||||
self.cache_all_tx_hashes = cache_all_tx_hashes if cache_all_tx_hashes is not None else self.boolean('CACHE_ALL_TX_HASHES', False)
|
||||
self.cache_all_claim_txos = cache_all_claim_txos if cache_all_claim_txos is not None else self.boolean('CACHE_ALL_CLAIM_TXOS', False)
|
||||
self.country = country if country is not None else self.default('COUNTRY', 'US')
|
||||
self.ssl_certfile = self.required('SSL_CERTFILE')
|
||||
self.ssl_keyfile = self.required('SSL_KEYFILE')
|
||||
self.rpc_port = self.integer('RPC_PORT', 8000)
|
||||
self.prometheus_port = self.integer('PROMETHEUS_PORT', 0)
|
||||
self.max_subscriptions = self.integer('MAX_SUBSCRIPTIONS', 10000)
|
||||
self.banner_file = self.default('BANNER_FILE', None)
|
||||
self.tor_banner_file = self.default('TOR_BANNER_FILE', self.banner_file)
|
||||
self.anon_logs = self.boolean('ANON_LOGS', False)
|
||||
self.log_sessions = self.integer('LOG_SESSIONS', 3600)
|
||||
self.allow_lan_udp = self.boolean('ALLOW_LAN_UDP', False)
|
||||
self.country = self.default('COUNTRY', 'US')
|
||||
# Peer discovery
|
||||
self.peer_discovery = self.peer_discovery_enum()
|
||||
self.peer_announce = self.boolean('PEER_ANNOUNCE', True)
|
||||
self.peer_hubs = self.extract_peer_hubs()
|
||||
# self.tor_proxy_host = self.default('TOR_PROXY_HOST', 'localhost')
|
||||
# self.tor_proxy_port = self.integer('TOR_PROXY_PORT', None)
|
||||
self.force_proxy = self.boolean('FORCE_PROXY', False)
|
||||
self.tor_proxy_host = self.default('TOR_PROXY_HOST', 'localhost')
|
||||
self.tor_proxy_port = self.integer('TOR_PROXY_PORT', None)
|
||||
# The electrum client takes the empty string as unspecified
|
||||
self.payment_address = payment_address if payment_address is not None else self.default('PAYMENT_ADDRESS', '')
|
||||
self.donation_address = donation_address if donation_address is not None else self.default('DONATION_ADDRESS', '')
|
||||
self.payment_address = self.default('PAYMENT_ADDRESS', '')
|
||||
self.donation_address = self.default('DONATION_ADDRESS', '')
|
||||
# Server limits to help prevent DoS
|
||||
self.max_send = max_send if max_send is not None else self.integer('MAX_SEND', 1000000)
|
||||
self.max_receive = max_receive if max_receive is not None else self.integer('MAX_RECEIVE', 1000000)
|
||||
# self.max_subs = self.integer('MAX_SUBS', 250000)
|
||||
self.max_sessions = max_sessions if max_sessions is not None else self.sane_max_sessions()
|
||||
# self.max_session_subs = self.integer('MAX_SESSION_SUBS', 50000)
|
||||
self.session_timeout = session_timeout if session_timeout is not None else self.integer('SESSION_TIMEOUT', 600)
|
||||
self.drop_client = drop_client if drop_client is not None else self.custom("DROP_CLIENT", None, re.compile)
|
||||
self.description = description if description is not None else self.default('DESCRIPTION', '')
|
||||
self.daily_fee = daily_fee if daily_fee is not None else self.string_amount('DAILY_FEE', '0')
|
||||
self.max_send = self.integer('MAX_SEND', 1000000)
|
||||
self.max_receive = self.integer('MAX_RECEIVE', 1000000)
|
||||
self.max_subs = self.integer('MAX_SUBS', 250000)
|
||||
self.max_sessions = self.sane_max_sessions()
|
||||
self.max_session_subs = self.integer('MAX_SESSION_SUBS', 50000)
|
||||
self.session_timeout = self.integer('SESSION_TIMEOUT', 600)
|
||||
self.drop_client = self.custom("DROP_CLIENT", None, re.compile)
|
||||
self.description = self.default('DESCRIPTION', '')
|
||||
self.daily_fee = self.string_amount('DAILY_FEE', '0')
|
||||
|
||||
# Identities
|
||||
clearnet_identity = self.clearnet_identity()
|
||||
@@ -113,8 +102,7 @@ class Env:
|
||||
self.identities = [identity
|
||||
for identity in (clearnet_identity, tor_identity)
|
||||
if identity is not None]
|
||||
self.database_query_timeout = database_query_timeout if database_query_timeout is not None else \
|
||||
(float(self.integer('QUERY_TIMEOUT_MS', 10000)) / 1000.0)
|
||||
self.database_query_timeout = float(self.integer('QUERY_TIMEOUT_MS', 3000)) / 1000.0
|
||||
|
||||
@classmethod
|
||||
def default(cls, envvar, default):
|
||||
@@ -166,9 +154,9 @@ class Env:
|
||||
if bad:
|
||||
raise cls.Error(f'remove obsolete environment variables {bad}')
|
||||
|
||||
@classmethod
|
||||
def set_event_loop_policy(cls, policy_name: str = None):
|
||||
if not policy_name or policy_name == 'default':
|
||||
def set_event_loop_policy(self):
|
||||
policy_name = self.default('EVENT_LOOP_POLICY', None)
|
||||
if not policy_name:
|
||||
import asyncio
|
||||
return asyncio.get_event_loop_policy()
|
||||
elif policy_name == 'uvloop':
|
||||
@@ -177,7 +165,7 @@ class Env:
|
||||
loop_policy = uvloop.EventLoopPolicy()
|
||||
asyncio.set_event_loop_policy(loop_policy)
|
||||
return loop_policy
|
||||
raise cls.Error(f'unknown event loop policy "{policy_name}"')
|
||||
raise self.Error(f'unknown event loop policy "{policy_name}"')
|
||||
|
||||
def cs_host(self, *, for_rpc):
|
||||
"""Returns the 'host' argument to pass to asyncio's create_server
|
||||
@@ -285,100 +273,4 @@ class Env:
|
||||
return self.PD_ON
|
||||
|
||||
def extract_peer_hubs(self):
|
||||
return [hub.strip() for hub in self.default('PEER_HUBS', '').split(',') if hub.strip()]
|
||||
|
||||
@classmethod
|
||||
def contribute_to_arg_parser(cls, parser):
|
||||
parser.add_argument('--db_dir', type=str, help='path of the directory containing lbry-leveldb',
|
||||
default=cls.default('DB_DIRECTORY', None))
|
||||
parser.add_argument('--daemon_url',
|
||||
help='URL for rpc from lbrycrd, <rpcuser>:<rpcpassword>@<lbrycrd rpc ip><lbrycrd rpc port>',
|
||||
default=cls.default('DAEMON_URL', None))
|
||||
parser.add_argument('--db_max_open_files', type=int, default=512,
|
||||
help='number of files leveldb can have open at a time')
|
||||
parser.add_argument('--host', type=str, default=cls.default('HOST', 'localhost'),
|
||||
help='Interface for hub server to listen on')
|
||||
parser.add_argument('--tcp_port', type=int, default=cls.integer('TCP_PORT', 50001),
|
||||
help='TCP port to listen on for hub server')
|
||||
parser.add_argument('--udp_port', type=int, default=cls.integer('UDP_PORT', 50001),
|
||||
help='UDP port to listen on for hub server')
|
||||
parser.add_argument('--rpc_host', default=cls.default('RPC_HOST', 'localhost'), type=str,
|
||||
help='Listening interface for admin rpc')
|
||||
parser.add_argument('--rpc_port', default=cls.integer('RPC_PORT', 8000), type=int,
|
||||
help='Listening port for admin rpc')
|
||||
parser.add_argument('--websocket_host', default=cls.default('WEBSOCKET_HOST', 'localhost'), type=str,
|
||||
help='Listening interface for websocket')
|
||||
parser.add_argument('--websocket_port', default=cls.integer('WEBSOCKET_PORT', None), type=int,
|
||||
help='Listening port for websocket')
|
||||
|
||||
parser.add_argument('--ssl_port', default=cls.integer('SSL_PORT', None), type=int,
|
||||
help='SSL port to listen on for hub server')
|
||||
parser.add_argument('--ssl_certfile', default=cls.default('SSL_CERTFILE', None), type=str,
|
||||
help='Path to SSL cert file')
|
||||
parser.add_argument('--ssl_keyfile', default=cls.default('SSL_KEYFILE', None), type=str,
|
||||
help='Path to SSL key file')
|
||||
parser.add_argument('--reorg_limit', default=cls.integer('REORG_LIMIT', 200), type=int, help='Max reorg depth')
|
||||
parser.add_argument('--elastic_host', default=cls.default('ELASTIC_HOST', 'localhost'), type=str,
|
||||
help='elasticsearch host')
|
||||
parser.add_argument('--elastic_port', default=cls.integer('ELASTIC_PORT', 9200), type=int,
|
||||
help='elasticsearch port')
|
||||
parser.add_argument('--es_mode', default=cls.default('ES_MODE', 'writer'), type=str,
|
||||
choices=['reader', 'writer'])
|
||||
parser.add_argument('--es_index_prefix', default=cls.default('ES_INDEX_PREFIX', ''), type=str)
|
||||
parser.add_argument('--loop_policy', default=cls.default('EVENT_LOOP_POLICY', 'default'), type=str,
|
||||
choices=['default', 'uvloop'])
|
||||
parser.add_argument('--max_query_workers', type=int, default=cls.integer('MAX_QUERY_WORKERS', 4),
|
||||
help='number of threads used by the request handler to read the database')
|
||||
parser.add_argument('--cache_MB', type=int, default=cls.integer('CACHE_MB', 1024),
|
||||
help='size of the leveldb lru cache, in megabytes')
|
||||
parser.add_argument('--cache_all_tx_hashes', type=bool,
|
||||
help='Load all tx hashes into memory. This will make address subscriptions and sync, '
|
||||
'resolve, transaction fetching, and block sync all faster at the expense of higher '
|
||||
'memory usage')
|
||||
parser.add_argument('--cache_all_claim_txos', type=bool,
|
||||
help='Load all claim txos into memory. This will make address subscriptions and sync, '
|
||||
'resolve, transaction fetching, and block sync all faster at the expense of higher '
|
||||
'memory usage')
|
||||
parser.add_argument('--prometheus_port', type=int, default=cls.integer('PROMETHEUS_PORT', 0),
|
||||
help='port for hub prometheus metrics to listen on, disabled by default')
|
||||
parser.add_argument('--max_subscriptions', type=int, default=cls.integer('MAX_SUBSCRIPTIONS', 10000),
|
||||
help='max subscriptions per connection')
|
||||
parser.add_argument('--banner_file', type=str, default=cls.default('BANNER_FILE', None),
|
||||
help='path to file containing banner text')
|
||||
parser.add_argument('--anon_logs', type=bool, default=cls.boolean('ANON_LOGS', False),
|
||||
help="don't log ip addresses")
|
||||
parser.add_argument('--allow_lan_udp', type=bool, default=cls.boolean('ALLOW_LAN_UDP', False),
|
||||
help='reply to hub UDP ping messages from LAN ip addresses')
|
||||
parser.add_argument('--country', type=str, default=cls.default('COUNTRY', 'US'), help='')
|
||||
parser.add_argument('--max_send', type=int, default=cls.default('MAX_SEND', 1000000), help='')
|
||||
parser.add_argument('--max_receive', type=int, default=cls.default('MAX_RECEIVE', 1000000), help='')
|
||||
parser.add_argument('--max_sessions', type=int, default=cls.default('MAX_SESSIONS', 1000), help='')
|
||||
parser.add_argument('--session_timeout', type=int, default=cls.default('SESSION_TIMEOUT', 600), help='')
|
||||
parser.add_argument('--drop_client', type=str, default=cls.default('DROP_CLIENT', None), help='')
|
||||
parser.add_argument('--description', type=str, default=cls.default('DESCRIPTION', ''), help='')
|
||||
parser.add_argument('--daily_fee', type=float, default=cls.default('DAILY_FEE', 0.0), help='')
|
||||
parser.add_argument('--payment_address', type=str, default=cls.default('PAYMENT_ADDRESS', ''), help='')
|
||||
parser.add_argument('--donation_address', type=str, default=cls.default('DONATION_ADDRESS', ''), help='')
|
||||
parser.add_argument('--chain', type=str, default=cls.default('NET', 'mainnet'),
|
||||
help="Which chain to use, default is mainnet")
|
||||
parser.add_argument('--query_timeout_ms', type=int, default=cls.integer('QUERY_TIMEOUT_MS', 10000),
|
||||
help="elasticsearch query timeout")
|
||||
|
||||
@classmethod
|
||||
def from_arg_parser(cls, args):
|
||||
return cls(
|
||||
db_dir=args.db_dir, daemon_url=args.daemon_url, db_max_open_files=args.db_max_open_files,
|
||||
host=args.host, rpc_host=args.rpc_host, elastic_host=args.elastic_host, elastic_port=args.elastic_port,
|
||||
loop_policy=args.loop_policy, max_query_workers=args.max_query_workers, websocket_host=args.websocket_host,
|
||||
websocket_port=args.websocket_port, chain=args.chain, es_index_prefix=args.es_index_prefix,
|
||||
es_mode=args.es_mode, cache_MB=args.cache_MB, reorg_limit=args.reorg_limit, tcp_port=args.tcp_port,
|
||||
udp_port=args.udp_port, ssl_port=args.ssl_port, ssl_certfile=args.ssl_certfile,
|
||||
ssl_keyfile=args.ssl_keyfile, rpc_port=args.rpc_port, prometheus_port=args.prometheus_port,
|
||||
max_subscriptions=args.max_subscriptions, banner_file=args.banner_file, anon_logs=args.anon_logs,
|
||||
log_sessions=None, allow_lan_udp=args.allow_lan_udp,
|
||||
cache_all_tx_hashes=args.cache_all_tx_hashes, cache_all_claim_txos=args.cache_all_claim_txos,
|
||||
country=args.country, payment_address=args.payment_address, donation_address=args.donation_address,
|
||||
max_send=args.max_send, max_receive=args.max_receive, max_sessions=args.max_sessions,
|
||||
session_timeout=args.session_timeout, drop_client=args.drop_client, description=args.description,
|
||||
daily_fee=args.daily_fee, database_query_timeout=(args.query_timeout_ms / 1000)
|
||||
)
|
||||
return [hub.strip() for hub in self.default('PEER_HUBS', '').split(',')]
|
||||
@@ -36,7 +36,6 @@ _sha512 = hashlib.sha512
|
||||
_new_hash = hashlib.new
|
||||
_new_hmac = hmac.new
|
||||
HASHX_LEN = 11
|
||||
CLAIM_HASH_LEN = 20
|
||||
|
||||
|
||||
def sha256(x):
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
# Copyright (c) 2016-2018, Neil Booth
|
||||
# Copyright (c) 2017, the ElectrumX authors
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# See the file "LICENCE" for information about the copyright
|
||||
# and warranty status of this software.
|
||||
|
||||
"""History by script hash (address)."""
|
||||
|
||||
import array
|
||||
import ast
|
||||
import bisect
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
|
||||
from lbry.wallet.server import util
|
||||
from lbry.wallet.server.util import pack_be_uint32, unpack_be_uint32_from, unpack_be_uint16_from
|
||||
from lbry.wallet.server.hash import hash_to_hex_str, HASHX_LEN
|
||||
|
||||
|
||||
class History:
|
||||
|
||||
DB_VERSIONS = [0, 1]
|
||||
|
||||
def __init__(self):
|
||||
self.logger = util.class_logger(__name__, self.__class__.__name__)
|
||||
# For history compaction
|
||||
self.max_hist_row_entries = 12500
|
||||
self.unflushed = defaultdict(partial(array.array, 'I'))
|
||||
self.unflushed_count = 0
|
||||
self.db = None
|
||||
|
||||
@property
|
||||
def needs_migration(self):
|
||||
return self.db_version != max(self.DB_VERSIONS)
|
||||
|
||||
def migrate(self):
|
||||
# 0 -> 1: flush_count from 16 to 32 bits
|
||||
self.logger.warning("HISTORY MIGRATION IN PROGRESS. Please avoid shutting down before it finishes.")
|
||||
with self.db.write_batch() as batch:
|
||||
for key, value in self.db.iterator(prefix=b''):
|
||||
if len(key) != 13:
|
||||
continue
|
||||
flush_id, = unpack_be_uint16_from(key[-2:])
|
||||
new_key = key[:-2] + pack_be_uint32(flush_id)
|
||||
batch.put(new_key, value)
|
||||
self.logger.warning("history migration: new keys added, removing old ones.")
|
||||
for key, value in self.db.iterator(prefix=b''):
|
||||
if len(key) == 13:
|
||||
batch.delete(key)
|
||||
self.logger.warning("history migration: writing new state.")
|
||||
self.db_version = 1
|
||||
self.write_state(batch)
|
||||
self.logger.warning("history migration: done.")
|
||||
|
||||
def open_db(self, db_class, for_sync, utxo_flush_count, compacting):
|
||||
self.db = db_class('hist', for_sync)
|
||||
self.read_state()
|
||||
if self.needs_migration:
|
||||
self.migrate()
|
||||
self.clear_excess(utxo_flush_count)
|
||||
# An incomplete compaction needs to be cancelled otherwise
|
||||
# restarting it will corrupt the history
|
||||
if not compacting:
|
||||
self._cancel_compaction()
|
||||
return self.flush_count
|
||||
|
||||
def close_db(self):
|
||||
if self.db:
|
||||
self.db.close()
|
||||
self.db = None
|
||||
|
||||
def read_state(self):
|
||||
state = self.db.get(b'state\0\0')
|
||||
if state:
|
||||
state = ast.literal_eval(state.decode())
|
||||
if not isinstance(state, dict):
|
||||
raise RuntimeError('failed reading state from history DB')
|
||||
self.flush_count = state['flush_count']
|
||||
self.comp_flush_count = state.get('comp_flush_count', -1)
|
||||
self.comp_cursor = state.get('comp_cursor', -1)
|
||||
self.db_version = state.get('db_version', 0)
|
||||
else:
|
||||
self.flush_count = 0
|
||||
self.comp_flush_count = -1
|
||||
self.comp_cursor = -1
|
||||
self.db_version = max(self.DB_VERSIONS)
|
||||
|
||||
self.logger.info(f'history DB version: {self.db_version}')
|
||||
if self.db_version not in self.DB_VERSIONS:
|
||||
msg = f'this software only handles DB versions {self.DB_VERSIONS}'
|
||||
self.logger.error(msg)
|
||||
raise RuntimeError(msg)
|
||||
self.logger.info(f'flush count: {self.flush_count:,d}')
|
||||
|
||||
def clear_excess(self, utxo_flush_count):
|
||||
# < might happen at end of compaction as both DBs cannot be
|
||||
# updated atomically
|
||||
if self.flush_count <= utxo_flush_count:
|
||||
return
|
||||
|
||||
self.logger.info('DB shut down uncleanly. Scanning for '
|
||||
'excess history flushes...')
|
||||
|
||||
keys = []
|
||||
for key, hist in self.db.iterator(prefix=b''):
|
||||
flush_id, = unpack_be_uint32_from(key[-4:])
|
||||
if flush_id > utxo_flush_count:
|
||||
keys.append(key)
|
||||
|
||||
self.logger.info(f'deleting {len(keys):,d} history entries')
|
||||
|
||||
self.flush_count = utxo_flush_count
|
||||
with self.db.write_batch() as batch:
|
||||
for key in keys:
|
||||
batch.delete(key)
|
||||
self.write_state(batch)
|
||||
|
||||
self.logger.info('deleted excess history entries')
|
||||
|
||||
def write_state(self, batch):
|
||||
"""Write state to the history DB."""
|
||||
state = {
|
||||
'flush_count': self.flush_count,
|
||||
'comp_flush_count': self.comp_flush_count,
|
||||
'comp_cursor': self.comp_cursor,
|
||||
'db_version': self.db_version,
|
||||
}
|
||||
# History entries are not prefixed; the suffix \0\0 ensures we
|
||||
# look similar to other entries and aren't interfered with
|
||||
batch.put(b'state\0\0', repr(state).encode())
|
||||
|
||||
def add_unflushed(self, hashXs_by_tx, first_tx_num):
|
||||
unflushed = self.unflushed
|
||||
count = 0
|
||||
for tx_num, hashXs in enumerate(hashXs_by_tx, start=first_tx_num):
|
||||
hashXs = set(hashXs)
|
||||
for hashX in hashXs:
|
||||
unflushed[hashX].append(tx_num)
|
||||
count += len(hashXs)
|
||||
self.unflushed_count += count
|
||||
|
||||
def unflushed_memsize(self):
|
||||
return len(self.unflushed) * 180 + self.unflushed_count * 4
|
||||
|
||||
def assert_flushed(self):
|
||||
assert not self.unflushed
|
||||
|
||||
def flush(self):
|
||||
start_time = time.time()
|
||||
self.flush_count += 1
|
||||
flush_id = pack_be_uint32(self.flush_count)
|
||||
unflushed = self.unflushed
|
||||
|
||||
with self.db.write_batch() as batch:
|
||||
for hashX in sorted(unflushed):
|
||||
key = hashX + flush_id
|
||||
batch.put(key, unflushed[hashX].tobytes())
|
||||
self.write_state(batch)
|
||||
|
||||
count = len(unflushed)
|
||||
unflushed.clear()
|
||||
self.unflushed_count = 0
|
||||
|
||||
if self.db.for_sync:
|
||||
elapsed = time.time() - start_time
|
||||
self.logger.info(f'flushed history in {elapsed:.1f}s '
|
||||
f'for {count:,d} addrs')
|
||||
|
||||
def backup(self, hashXs, tx_count):
|
||||
# Not certain this is needed, but it doesn't hurt
|
||||
self.flush_count += 1
|
||||
nremoves = 0
|
||||
bisect_left = bisect.bisect_left
|
||||
|
||||
with self.db.write_batch() as batch:
|
||||
for hashX in sorted(hashXs):
|
||||
deletes = []
|
||||
puts = {}
|
||||
for key, hist in self.db.iterator(prefix=hashX, reverse=True):
|
||||
a = array.array('I')
|
||||
a.frombytes(hist)
|
||||
# Remove all history entries >= tx_count
|
||||
idx = bisect_left(a, tx_count)
|
||||
nremoves += len(a) - idx
|
||||
if idx > 0:
|
||||
puts[key] = a[:idx].tobytes()
|
||||
break
|
||||
deletes.append(key)
|
||||
|
||||
for key in deletes:
|
||||
batch.delete(key)
|
||||
for key, value in puts.items():
|
||||
batch.put(key, value)
|
||||
self.write_state(batch)
|
||||
|
||||
self.logger.info(f'backing up removed {nremoves:,d} history entries')
|
||||
|
||||
# def get_txnums(self, hashX, limit=1000):
|
||||
# """Generator that returns an unpruned, sorted list of tx_nums in the
|
||||
# history of a hashX. Includes both spending and receiving
|
||||
# transactions. By default yields at most 1000 entries. Set
|
||||
# limit to None to get them all. """
|
||||
# limit = util.resolve_limit(limit)
|
||||
# for key, hist in self.db.iterator(prefix=hashX):
|
||||
# a = array.array('I')
|
||||
# a.frombytes(hist)
|
||||
# for tx_num in a:
|
||||
# if limit == 0:
|
||||
# return
|
||||
# yield tx_num
|
||||
# limit -= 1
|
||||
|
||||
#
|
||||
# History compaction
|
||||
#
|
||||
|
||||
# comp_cursor is a cursor into compaction progress.
|
||||
# -1: no compaction in progress
|
||||
# 0-65535: Compaction in progress; all prefixes < comp_cursor have
|
||||
# been compacted, and later ones have not.
|
||||
# 65536: compaction complete in-memory but not flushed
|
||||
#
|
||||
# comp_flush_count applies during compaction, and is a flush count
|
||||
# for history with prefix < comp_cursor. flush_count applies
|
||||
# to still uncompacted history. It is -1 when no compaction is
|
||||
# taking place. Key suffixes up to and including comp_flush_count
|
||||
# are used, so a parallel history flush must first increment this
|
||||
#
|
||||
# When compaction is complete and the final flush takes place,
|
||||
# flush_count is reset to comp_flush_count, and comp_flush_count to -1
|
||||
|
||||
def _flush_compaction(self, cursor, write_items, keys_to_delete):
|
||||
"""Flush a single compaction pass as a batch."""
|
||||
# Update compaction state
|
||||
if cursor == 65536:
|
||||
self.flush_count = self.comp_flush_count
|
||||
self.comp_cursor = -1
|
||||
self.comp_flush_count = -1
|
||||
else:
|
||||
self.comp_cursor = cursor
|
||||
|
||||
# History DB. Flush compacted history and updated state
|
||||
with self.db.write_batch() as batch:
|
||||
# Important: delete first! The keyspace may overlap.
|
||||
for key in keys_to_delete:
|
||||
batch.delete(key)
|
||||
for key, value in write_items:
|
||||
batch.put(key, value)
|
||||
self.write_state(batch)
|
||||
|
||||
def _compact_hashX(self, hashX, hist_map, hist_list,
|
||||
write_items, keys_to_delete):
|
||||
"""Compress history for a hashX. hist_list is an ordered list of
|
||||
the histories to be compressed."""
|
||||
# History entries (tx numbers) are 4 bytes each. Distribute
|
||||
# over rows of up to 50KB in size. A fixed row size means
|
||||
# future compactions will not need to update the first N - 1
|
||||
# rows.
|
||||
max_row_size = self.max_hist_row_entries * 4
|
||||
full_hist = b''.join(hist_list)
|
||||
nrows = (len(full_hist) + max_row_size - 1) // max_row_size
|
||||
if nrows > 4:
|
||||
self.logger.info('hashX {} is large: {:,d} entries across '
|
||||
'{:,d} rows'
|
||||
.format(hash_to_hex_str(hashX),
|
||||
len(full_hist) // 4, nrows))
|
||||
|
||||
# Find what history needs to be written, and what keys need to
|
||||
# be deleted. Start by assuming all keys are to be deleted,
|
||||
# and then remove those that are the same on-disk as when
|
||||
# compacted.
|
||||
write_size = 0
|
||||
keys_to_delete.update(hist_map)
|
||||
for n, chunk in enumerate(util.chunks(full_hist, max_row_size)):
|
||||
key = hashX + pack_be_uint32(n)
|
||||
if hist_map.get(key) == chunk:
|
||||
keys_to_delete.remove(key)
|
||||
else:
|
||||
write_items.append((key, chunk))
|
||||
write_size += len(chunk)
|
||||
|
||||
assert n + 1 == nrows
|
||||
self.comp_flush_count = max(self.comp_flush_count, n)
|
||||
|
||||
return write_size
|
||||
|
||||
def _compact_prefix(self, prefix, write_items, keys_to_delete):
|
||||
"""Compact all history entries for hashXs beginning with the
|
||||
given prefix. Update keys_to_delete and write."""
|
||||
prior_hashX = None
|
||||
hist_map = {}
|
||||
hist_list = []
|
||||
|
||||
key_len = HASHX_LEN + 2
|
||||
write_size = 0
|
||||
for key, hist in self.db.iterator(prefix=prefix):
|
||||
# Ignore non-history entries
|
||||
if len(key) != key_len:
|
||||
continue
|
||||
hashX = key[:-2]
|
||||
if hashX != prior_hashX and prior_hashX:
|
||||
write_size += self._compact_hashX(prior_hashX, hist_map,
|
||||
hist_list, write_items,
|
||||
keys_to_delete)
|
||||
hist_map.clear()
|
||||
hist_list.clear()
|
||||
prior_hashX = hashX
|
||||
hist_map[key] = hist
|
||||
hist_list.append(hist)
|
||||
|
||||
if prior_hashX:
|
||||
write_size += self._compact_hashX(prior_hashX, hist_map, hist_list,
|
||||
write_items, keys_to_delete)
|
||||
return write_size
|
||||
|
||||
def _compact_history(self, limit):
|
||||
"""Inner loop of history compaction. Loops until limit bytes have
|
||||
been processed.
|
||||
"""
|
||||
keys_to_delete = set()
|
||||
write_items = [] # A list of (key, value) pairs
|
||||
write_size = 0
|
||||
|
||||
# Loop over 2-byte prefixes
|
||||
cursor = self.comp_cursor
|
||||
while write_size < limit and cursor < (1 << 32):
|
||||
prefix = pack_be_uint32(cursor)
|
||||
write_size += self._compact_prefix(prefix, write_items,
|
||||
keys_to_delete)
|
||||
cursor += 1
|
||||
|
||||
max_rows = self.comp_flush_count + 1
|
||||
self._flush_compaction(cursor, write_items, keys_to_delete)
|
||||
|
||||
self.logger.info('history compaction: wrote {:,d} rows ({:.1f} MB), '
|
||||
'removed {:,d} rows, largest: {:,d}, {:.1f}% complete'
|
||||
.format(len(write_items), write_size / 1000000,
|
||||
len(keys_to_delete), max_rows,
|
||||
100 * cursor / 65536))
|
||||
return write_size
|
||||
|
||||
def _cancel_compaction(self):
|
||||
if self.comp_cursor != -1:
|
||||
self.logger.warning('cancelling in-progress history compaction')
|
||||
self.comp_flush_count = -1
|
||||
self.comp_cursor = -1
|
||||
+586
-939
File diff suppressed because it is too large.
Load diff
+104
-56
@@ -9,16 +9,15 @@
|
||||
import asyncio
|
||||
import itertools
|
||||
import time
|
||||
import attr
|
||||
import typing
|
||||
from typing import Set, Optional, Callable, Awaitable
|
||||
from abc import ABC, abstractmethod
|
||||
from collections import defaultdict
|
||||
from prometheus_client import Histogram
|
||||
|
||||
import attr
|
||||
|
||||
from lbry.wallet.server.hash import hash_to_hex_str, hex_str_to_hash
|
||||
from lbry.wallet.server.util import class_logger, chunks
|
||||
from lbry.wallet.server.leveldb import UTXO
|
||||
if typing.TYPE_CHECKING:
|
||||
from lbry.wallet.server.session import LBRYSessionManager
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
@@ -29,7 +28,6 @@ class MemPoolTx:
|
||||
out_pairs = attr.ib()
|
||||
fee = attr.ib()
|
||||
size = attr.ib()
|
||||
raw_tx = attr.ib()
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
@@ -39,6 +37,47 @@ class MemPoolTxSummary:
|
||||
has_unconfirmed_inputs = attr.ib()
|
||||
|
||||
|
||||
class MemPoolAPI(ABC):
|
||||
"""A concrete instance of this class is passed to the MemPool object
|
||||
and used by it to query DB and blockchain state."""
|
||||
|
||||
@abstractmethod
|
||||
async def height(self):
|
||||
"""Query bitcoind for its height."""
|
||||
|
||||
@abstractmethod
|
||||
def cached_height(self):
|
||||
"""Return the height of bitcoind the last time it was queried,
|
||||
for any reason, without actually querying it.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def mempool_hashes(self):
|
||||
"""Query bitcoind for the hashes of all transactions in its
|
||||
mempool, returned as a list."""
|
||||
|
||||
@abstractmethod
|
||||
async def raw_transactions(self, hex_hashes):
|
||||
"""Query bitcoind for the serialized raw transactions with the given
|
||||
hashes. Missing transactions are returned as None.
|
||||
|
||||
hex_hashes is an iterable of hexadecimal hash strings."""
|
||||
|
||||
@abstractmethod
|
||||
async def lookup_utxos(self, prevouts):
|
||||
"""Return a list of (hashX, value) pairs each prevout if unspent,
|
||||
otherwise return None if spent or not found.
|
||||
|
||||
prevouts - an iterable of (hash, index) pairs
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def on_mempool(self, touched, new_touched, height):
|
||||
"""Called each time the mempool is synchronized. touched is a set of
|
||||
hashXs touched since the previous call. height is the
|
||||
daemon's height at the time the mempool was obtained."""
|
||||
|
||||
|
||||
NAMESPACE = "wallet_server"
|
||||
HISTOGRAM_BUCKETS = (
|
||||
.005, .01, .025, .05, .075, .1, .25, .5, .75, 1.0, 2.5, 5.0, 7.5, 10.0, 15.0, 20.0, 30.0, 60.0, float('inf')
|
||||
@@ -50,14 +89,23 @@ mempool_process_time_metric = Histogram(
|
||||
|
||||
|
||||
class MemPool:
|
||||
def __init__(self, coin, daemon, db, state_lock: asyncio.Lock, refresh_secs=1.0, log_status_secs=120.0):
|
||||
self.coin = coin
|
||||
self._daemon = daemon
|
||||
self._db = db
|
||||
self._touched_mp = {}
|
||||
self._touched_bp = {}
|
||||
self._highest_block = -1
|
||||
"""Representation of the daemon's mempool.
|
||||
|
||||
coin - a coin class from coins.py
|
||||
api - an object implementing MemPoolAPI
|
||||
|
||||
Updated regularly in caught-up state. Goal is to enable efficient
|
||||
response to the calls in the external interface. To that end we
|
||||
maintain the following maps:
|
||||
|
||||
tx: tx_hash -> MemPoolTx
|
||||
hashXs: hashX -> set of all hashes of txs touching the hashX
|
||||
"""
|
||||
|
||||
def __init__(self, coin, api, refresh_secs=1.0, log_status_secs=120.0):
|
||||
assert isinstance(api, MemPoolAPI)
|
||||
self.coin = coin
|
||||
self.api = api
|
||||
self.logger = class_logger(__name__, self.__class__.__name__)
|
||||
self.txs = {}
|
||||
self.hashXs = defaultdict(set) # None can be a key
|
||||
@@ -65,11 +113,10 @@ class MemPool:
|
||||
self.refresh_secs = refresh_secs
|
||||
self.log_status_secs = log_status_secs
|
||||
# Prevents mempool refreshes during fee histogram calculation
|
||||
self.lock = state_lock
|
||||
self.lock = asyncio.Lock()
|
||||
self.wakeup = asyncio.Event()
|
||||
self.mempool_process_time_metric = mempool_process_time_metric
|
||||
self.notified_mempool_txs = set()
|
||||
self.notify_sessions: Optional[Callable[[int, Set[bytes], Set[bytes]], Awaitable[None]]] = None
|
||||
|
||||
async def _logging(self, synchronized_event):
|
||||
"""Print regular logs of mempool stats."""
|
||||
@@ -85,6 +132,40 @@ class MemPool:
|
||||
await asyncio.sleep(self.log_status_secs)
|
||||
await synchronized_event.wait()
|
||||
|
||||
async def _refresh_histogram(self, synchronized_event):
|
||||
while True:
|
||||
await synchronized_event.wait()
|
||||
async with self.lock:
|
||||
self._update_histogram(100_000)
|
||||
await asyncio.sleep(self.coin.MEMPOOL_HISTOGRAM_REFRESH_SECS)
|
||||
|
||||
def _update_histogram(self, bin_size):
|
||||
# Build a histogram by fee rate
|
||||
histogram = defaultdict(int)
|
||||
for tx in self.txs.values():
|
||||
histogram[tx.fee // tx.size] += tx.size
|
||||
|
||||
# Now compact it. For efficiency, get_fees returns a
|
||||
# compact histogram with variable bin size. The compact
|
||||
# histogram is an array of (fee_rate, vsize) values.
|
||||
# vsize_n is the cumulative virtual size of mempool
|
||||
# transactions with a fee rate in the interval
|
||||
# [rate_(n-1), rate_n)], and rate_(n-1) > rate_n.
|
||||
# Intervals are chosen to create tranches containing at
|
||||
# least 100kb of transactions
|
||||
compact = []
|
||||
cum_size = 0
|
||||
r = 0 # ?
|
||||
for fee_rate, size in sorted(histogram.items(), reverse=True):
|
||||
cum_size += size
|
||||
if cum_size + r > bin_size:
|
||||
compact.append((fee_rate, cum_size))
|
||||
r += cum_size - bin_size
|
||||
cum_size = 0
|
||||
bin_size *= 1.1
|
||||
self.logger.info(f'compact fee histogram: {compact}')
|
||||
self.cached_compact_histogram = compact
|
||||
|
||||
def _accept_transactions(self, tx_map, utxo_map, touched):
|
||||
"""Accept transactions in tx_map to the mempool if all their inputs
|
||||
can be found in the existing mempool or a utxo_map from the
|
||||
@@ -142,9 +223,9 @@ class MemPool:
|
||||
"""Refresh our view of the daemon's mempool."""
|
||||
while True:
|
||||
start = time.perf_counter()
|
||||
height = self._daemon.cached_height()
|
||||
hex_hashes = await self._daemon.mempool_hashes()
|
||||
if height != await self._daemon.height():
|
||||
height = self.api.cached_height()
|
||||
hex_hashes = await self.api.mempool_hashes()
|
||||
if height != await self.api.height():
|
||||
continue
|
||||
hashes = {hex_str_to_hash(hh) for hh in hex_hashes}
|
||||
async with self.lock:
|
||||
@@ -156,7 +237,7 @@ class MemPool:
|
||||
}
|
||||
synchronized_event.set()
|
||||
synchronized_event.clear()
|
||||
await self.on_mempool(touched, new_touched, height)
|
||||
await self.api.on_mempool(touched, new_touched, height)
|
||||
duration = time.perf_counter() - start
|
||||
self.mempool_process_time_metric.observe(duration)
|
||||
try:
|
||||
@@ -211,7 +292,8 @@ class MemPool:
|
||||
|
||||
async def _fetch_and_accept(self, hashes, all_hashes, touched):
|
||||
"""Fetch a list of mempool transactions."""
|
||||
raw_txs = await self._daemon.getrawtransactions((hash_to_hex_str(hash) for hash in hashes))
|
||||
hex_hashes_iter = (hash_to_hex_str(hash) for hash in hashes)
|
||||
raw_txs = await self.api.raw_transactions(hex_hashes_iter)
|
||||
|
||||
to_hashX = self.coin.hashX_from_script
|
||||
deserializer = self.coin.DESERIALIZER
|
||||
@@ -231,7 +313,7 @@ class MemPool:
|
||||
txout_pairs = tuple((to_hashX(txout.pk_script), txout.value)
|
||||
for txout in tx.outputs)
|
||||
tx_map[hash] = MemPoolTx(txin_pairs, None, txout_pairs,
|
||||
0, tx_size, raw_tx)
|
||||
0, tx_size)
|
||||
|
||||
# Determine all prevouts not in the mempool, and fetch the
|
||||
# UTXO information from the database. Failed prevout lookups
|
||||
@@ -241,7 +323,7 @@ class MemPool:
|
||||
prevouts = tuple(prevout for tx in tx_map.values()
|
||||
for prevout in tx.prevouts
|
||||
if prevout[0] not in all_hashes)
|
||||
utxos = await self._db.lookup_utxos(prevouts)
|
||||
utxos = await self.api.lookup_utxos(prevouts)
|
||||
utxo_map = dict(zip(prevouts, utxos))
|
||||
|
||||
return self._accept_transactions(tx_map, utxo_map, touched)
|
||||
@@ -325,37 +407,3 @@ class MemPool:
|
||||
if unspent_inputs:
|
||||
return -1
|
||||
return 0
|
||||
|
||||
async def _maybe_notify(self, new_touched):
|
||||
tmp, tbp = self._touched_mp, self._touched_bp
|
||||
common = set(tmp).intersection(tbp)
|
||||
if common:
|
||||
height = max(common)
|
||||
elif tmp and max(tmp) == self._highest_block:
|
||||
height = self._highest_block
|
||||
else:
|
||||
# Either we are processing a block and waiting for it to
|
||||
# come in, or we have not yet had a mempool update for the
|
||||
# new block height
|
||||
return
|
||||
touched = tmp.pop(height)
|
||||
for old in [h for h in tmp if h <= height]:
|
||||
del tmp[old]
|
||||
for old in [h for h in tbp if h <= height]:
|
||||
touched.update(tbp.pop(old))
|
||||
# print("notify", height, len(touched), len(new_touched))
|
||||
await self.notify_sessions(height, touched, new_touched)
|
||||
|
||||
async def start(self, height, session_manager: 'LBRYSessionManager'):
|
||||
self._highest_block = height
|
||||
self.notify_sessions = session_manager._notify_sessions
|
||||
await self.notify_sessions(height, set(), set())
|
||||
|
||||
async def on_mempool(self, touched, new_touched, height):
|
||||
self._touched_mp[height] = touched
|
||||
await self._maybe_notify(new_touched)
|
||||
|
||||
async def on_block(self, touched, height):
|
||||
self._touched_bp[height] = touched
|
||||
self._highest_block = height
|
||||
await self._maybe_notify(set())
|
||||
@@ -43,12 +43,10 @@ class Merkle:
|
||||
def __init__(self, hash_func=double_sha256):
|
||||
self.hash_func = hash_func
|
||||
|
||||
@staticmethod
|
||||
def tree_depth(hash_count):
|
||||
return Merkle.branch_length(hash_count) + 1
|
||||
def tree_depth(self, hash_count):
|
||||
return self.branch_length(hash_count) + 1
|
||||
|
||||
@staticmethod
|
||||
def branch_length(hash_count):
|
||||
def branch_length(self, hash_count):
|
||||
"""Return the length of a merkle branch given the number of hashes."""
|
||||
if not isinstance(hash_count, int):
|
||||
raise TypeError('hash_count must be an integer')
|
||||
@@ -56,8 +54,7 @@ class Merkle:
|
||||
raise ValueError('hash_count must be at least 1')
|
||||
return ceil(log(hash_count, 2))
|
||||
|
||||
@staticmethod
|
||||
def branch_and_root(hashes, index, length=None, hash_func=double_sha256):
|
||||
def branch_and_root(self, hashes, index, length=None):
|
||||
"""Return a (merkle branch, merkle_root) pair given hashes, and the
|
||||
index of one of those hashes.
|
||||
"""
|
||||
@@ -67,7 +64,7 @@ class Merkle:
|
||||
# This also asserts hashes is not empty
|
||||
if not 0 <= index < len(hashes):
|
||||
raise ValueError(f"index '{index}/{len(hashes)}' out of range")
|
||||
natural_length = Merkle.branch_length(len(hashes))
|
||||
natural_length = self.branch_length(len(hashes))
|
||||
if length is None:
|
||||
length = natural_length
|
||||
else:
|
||||
@@ -76,6 +73,7 @@ class Merkle:
|
||||
if length < natural_length:
|
||||
raise ValueError('length out of range')
|
||||
|
||||
hash_func = self.hash_func
|
||||
branch = []
|
||||
for _ in range(length):
|
||||
if len(hashes) & 1:
|
||||
@@ -87,47 +85,44 @@ class Merkle:
|
||||
|
||||
return branch, hashes[0]
|
||||
|
||||
@staticmethod
|
||||
def root(hashes, length=None):
|
||||
def root(self, hashes, length=None):
|
||||
"""Return the merkle root of a non-empty iterable of binary hashes."""
|
||||
branch, root = Merkle.branch_and_root(hashes, 0, length)
|
||||
branch, root = self.branch_and_root(hashes, 0, length)
|
||||
return root
|
||||
|
||||
# @staticmethod
|
||||
# def root_from_proof(hash, branch, index, hash_func=double_sha256):
|
||||
# """Return the merkle root given a hash, a merkle branch to it, and
|
||||
# its index in the hashes array.
|
||||
#
|
||||
# branch is an iterable sorted deepest to shallowest. If the
|
||||
# returned root is the expected value then the merkle proof is
|
||||
# verified.
|
||||
#
|
||||
# The caller should have confirmed the length of the branch with
|
||||
# branch_length(). Unfortunately this is not easily done for
|
||||
# bitcoin transactions as the number of transactions in a block
|
||||
# is unknown to an SPV client.
|
||||
# """
|
||||
# for elt in branch:
|
||||
# if index & 1:
|
||||
# hash = hash_func(elt + hash)
|
||||
# else:
|
||||
# hash = hash_func(hash + elt)
|
||||
# index >>= 1
|
||||
# if index:
|
||||
# raise ValueError('index out of range for branch')
|
||||
# return hash
|
||||
def root_from_proof(self, hash, branch, index):
|
||||
"""Return the merkle root given a hash, a merkle branch to it, and
|
||||
its index in the hashes array.
|
||||
|
||||
@staticmethod
|
||||
def level(hashes, depth_higher):
|
||||
branch is an iterable sorted deepest to shallowest. If the
|
||||
returned root is the expected value then the merkle proof is
|
||||
verified.
|
||||
|
||||
The caller should have confirmed the length of the branch with
|
||||
branch_length(). Unfortunately this is not easily done for
|
||||
bitcoin transactions as the number of transactions in a block
|
||||
is unknown to an SPV client.
|
||||
"""
|
||||
hash_func = self.hash_func
|
||||
for elt in branch:
|
||||
if index & 1:
|
||||
hash = hash_func(elt + hash)
|
||||
else:
|
||||
hash = hash_func(hash + elt)
|
||||
index >>= 1
|
||||
if index:
|
||||
raise ValueError('index out of range for branch')
|
||||
return hash
|
||||
|
||||
def level(self, hashes, depth_higher):
|
||||
"""Return a level of the merkle tree of hashes the given depth
|
||||
higher than the bottom row of the original tree."""
|
||||
size = 1 << depth_higher
|
||||
root = Merkle.root
|
||||
root = self.root
|
||||
return [root(hashes[n: n + size], depth_higher)
|
||||
for n in range(0, len(hashes), size)]
|
||||
|
||||
@staticmethod
|
||||
def branch_and_root_from_level(level, leaf_hashes, index,
|
||||
def branch_and_root_from_level(self, level, leaf_hashes, index,
|
||||
depth_higher):
|
||||
"""Return a (merkle branch, merkle_root) pair when a merkle-tree has a
|
||||
level cached.
|
||||
@@ -151,10 +146,10 @@ class Merkle:
|
||||
if not isinstance(leaf_hashes, list):
|
||||
raise TypeError("leaf_hashes must be a list")
|
||||
leaf_index = (index >> depth_higher) << depth_higher
|
||||
leaf_branch, leaf_root = Merkle.branch_and_root(
|
||||
leaf_branch, leaf_root = self.branch_and_root(
|
||||
leaf_hashes, index - leaf_index, depth_higher)
|
||||
index >>= depth_higher
|
||||
level_branch, root = Merkle.branch_and_root(level, index)
|
||||
level_branch, root = self.branch_and_root(level, index)
|
||||
# Check last so that we know index is in-range
|
||||
if leaf_root != level[index]:
|
||||
raise ValueError('leaf hashes inconsistent with level')
|
||||
|
||||
@@ -5,13 +5,66 @@ from concurrent.futures.thread import ThreadPoolExecutor
|
||||
import typing
|
||||
|
||||
import lbry
|
||||
from lbry.wallet.server.mempool import MemPool
|
||||
from lbry.wallet.server.block_processor import BlockProcessor
|
||||
from lbry.wallet.server.leveldb import LevelDB
|
||||
from lbry.wallet.server.session import LBRYSessionManager
|
||||
from lbry.wallet.server.mempool import MemPool, MemPoolAPI
|
||||
from lbry.prometheus import PrometheusServer
|
||||
|
||||
|
||||
class Notifications:
|
||||
# hashX notifications come from two sources: new blocks and
|
||||
# mempool refreshes.
|
||||
#
|
||||
# A user with a pending transaction is notified after the block it
|
||||
# gets in is processed. Block processing can take an extended
|
||||
# time, and the prefetcher might poll the daemon after the mempool
|
||||
# code in any case. In such cases the transaction will not be in
|
||||
# the mempool after the mempool refresh. We want to avoid
|
||||
# notifying clients twice - for the mempool refresh and when the
|
||||
# block is done. This object handles that logic by deferring
|
||||
# notifications appropriately.
|
||||
|
||||
def __init__(self):
|
||||
self._touched_mp = {}
|
||||
self._touched_bp = {}
|
||||
self.notified_mempool_txs = set()
|
||||
self._highest_block = -1
|
||||
|
||||
async def _maybe_notify(self, new_touched):
|
||||
tmp, tbp = self._touched_mp, self._touched_bp
|
||||
common = set(tmp).intersection(tbp)
|
||||
if common:
|
||||
height = max(common)
|
||||
elif tmp and max(tmp) == self._highest_block:
|
||||
height = self._highest_block
|
||||
else:
|
||||
# Either we are processing a block and waiting for it to
|
||||
# come in, or we have not yet had a mempool update for the
|
||||
# new block height
|
||||
return
|
||||
touched = tmp.pop(height)
|
||||
for old in [h for h in tmp if h <= height]:
|
||||
del tmp[old]
|
||||
for old in [h for h in tbp if h <= height]:
|
||||
touched.update(tbp.pop(old))
|
||||
await self.notify(height, touched, new_touched)
|
||||
|
||||
async def notify(self, height, touched, new_touched):
|
||||
pass
|
||||
|
||||
async def start(self, height, notify_func):
|
||||
self._highest_block = height
|
||||
self.notify = notify_func
|
||||
await self.notify(height, set(), set())
|
||||
|
||||
async def on_mempool(self, touched, new_touched, height):
|
||||
self._touched_mp[height] = touched
|
||||
await self._maybe_notify(new_touched)
|
||||
|
||||
async def on_block(self, touched, height):
|
||||
self._touched_bp[height] = touched
|
||||
self._highest_block = height
|
||||
await self._maybe_notify(set())
|
||||
|
||||
|
||||
class Server:
|
||||
|
||||
def __init__(self, env):
|
||||
@@ -20,16 +73,26 @@ class Server:
|
||||
self.shutdown_event = asyncio.Event()
|
||||
self.cancellable_tasks = []
|
||||
|
||||
self.notifications = notifications = Notifications()
|
||||
self.daemon = daemon = env.coin.DAEMON(env.coin, env.daemon_url)
|
||||
self.db = db = LevelDB(env)
|
||||
self.bp = bp = BlockProcessor(env, db, daemon, self.shutdown_event)
|
||||
self.db = db = env.coin.DB(env)
|
||||
self.bp = bp = env.coin.BLOCK_PROCESSOR(env, db, daemon, notifications)
|
||||
self.prometheus_server: typing.Optional[PrometheusServer] = None
|
||||
|
||||
self.session_mgr = LBRYSessionManager(
|
||||
env, db, bp.mempool, bp.history_cache, bp.resolve_cache, bp.resolve_outputs_cache, daemon,
|
||||
self.shutdown_event,
|
||||
on_available_callback=bp.status_server.set_available,
|
||||
on_unavailable_callback=bp.status_server.set_unavailable
|
||||
# Set notifications up to implement the MemPoolAPI
|
||||
notifications.height = daemon.height
|
||||
notifications.cached_height = daemon.cached_height
|
||||
notifications.mempool_hashes = daemon.mempool_hashes
|
||||
notifications.raw_transactions = daemon.getrawtransactions
|
||||
notifications.lookup_utxos = db.lookup_utxos
|
||||
|
||||
MemPoolAPI.register(Notifications)
|
||||
self.mempool = mempool = MemPool(env.coin, notifications)
|
||||
|
||||
notifications.notified_mempool_txs = self.mempool.notified_mempool_txs
|
||||
|
||||
self.session_mgr = env.coin.SESSION_MANAGER(
|
||||
env, db, bp, daemon, mempool, self.shutdown_event
|
||||
)
|
||||
self._indexer_task = None
|
||||
|
||||
@@ -57,8 +120,8 @@ class Server:
|
||||
await _start_cancellable(self.bp.fetch_and_process_blocks)
|
||||
|
||||
await self.db.populate_header_merkle_cache()
|
||||
await _start_cancellable(self.bp.mempool.keep_synchronized)
|
||||
await _start_cancellable(self.session_mgr.serve, self.bp.mempool)
|
||||
await _start_cancellable(self.mempool.keep_synchronized)
|
||||
await _start_cancellable(self.session_mgr.serve, self.notifications)
|
||||
|
||||
async def stop(self):
|
||||
for task in reversed(self.cancellable_tasks):
|
||||
@@ -72,7 +135,7 @@ class Server:
|
||||
|
||||
def run(self):
|
||||
loop = asyncio.get_event_loop()
|
||||
executor = ThreadPoolExecutor(self.env.max_query_workers, thread_name_prefix='hub-worker')
|
||||
executor = ThreadPoolExecutor(1)
|
||||
loop.set_default_executor(executor)
|
||||
|
||||
def __exit():
|
||||
|
||||
+187
-217
@@ -2,6 +2,8 @@ import os
|
||||
import ssl
|
||||
import math
|
||||
import time
|
||||
import json
|
||||
import base64
|
||||
import codecs
|
||||
import typing
|
||||
import asyncio
|
||||
@@ -13,29 +15,32 @@ from asyncio import Event, sleep
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
|
||||
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
|
||||
|
||||
from elasticsearch import ConnectionTimeout
|
||||
from prometheus_client import Counter, Info, Histogram, Gauge
|
||||
|
||||
import lbry
|
||||
from lbry.error import ResolveCensoredError, TooManyClaimSearchParametersError
|
||||
from lbry.error import TooManyClaimSearchParametersError
|
||||
from lbry.build_info import BUILD, COMMIT_HASH, DOCKER_TAG
|
||||
from lbry.schema.result import Outputs
|
||||
from lbry.wallet.server.block_processor import BlockProcessor
|
||||
from lbry.wallet.server.leveldb import LevelDB
|
||||
from lbry.wallet.server.block_processor import LBRYBlockProcessor
|
||||
from lbry.wallet.server.db.writer import LBRYLevelDB
|
||||
from lbry.wallet.server.websocket import AdminWebSocket
|
||||
from lbry.wallet.server.metrics import ServerLoadData, APICallMetrics
|
||||
from lbry.wallet.rpc.framing import NewlineFramer
|
||||
|
||||
import lbry.wallet.server.version as VERSION
|
||||
|
||||
from lbry.wallet.rpc import (
|
||||
RPCSession, JSONRPCAutoDetect, JSONRPCConnection,
|
||||
handler_invocation, RPCError, Request, JSONRPC, Notification, Batch
|
||||
handler_invocation, RPCError, Request, JSONRPC
|
||||
)
|
||||
from lbry.wallet.server import text
|
||||
from lbry.wallet.server import util
|
||||
from lbry.wallet.server.hash import sha256, hash_to_hex_str, hex_str_to_hash, HASHX_LEN, Base58Error
|
||||
from lbry.wallet.server.daemon import DaemonError
|
||||
if typing.TYPE_CHECKING:
|
||||
from lbry.wallet.server.env import Env
|
||||
from lbry.wallet.server.mempool import MemPool
|
||||
from lbry.wallet.server.daemon import Daemon
|
||||
|
||||
BAD_REQUEST = 1
|
||||
@@ -170,14 +175,12 @@ class SessionManager:
|
||||
namespace=NAMESPACE, buckets=HISTOGRAM_BUCKETS
|
||||
)
|
||||
|
||||
def __init__(self, env: 'Env', db: LevelDB, mempool, history_cache, resolve_cache, resolve_outputs_cache,
|
||||
daemon: 'Daemon', shutdown_event: asyncio.Event,
|
||||
on_available_callback: typing.Callable[[], None], on_unavailable_callback: typing.Callable[[], None]):
|
||||
def __init__(self, env: 'Env', db: LBRYLevelDB, bp: LBRYBlockProcessor, daemon: 'Daemon', mempool: 'MemPool',
|
||||
shutdown_event: asyncio.Event):
|
||||
env.max_send = max(350000, env.max_send)
|
||||
self.env = env
|
||||
self.db = db
|
||||
self.on_available_callback = on_available_callback
|
||||
self.on_unavailable_callback = on_unavailable_callback
|
||||
self.bp = bp
|
||||
self.daemon = daemon
|
||||
self.mempool = mempool
|
||||
self.shutdown_event = shutdown_event
|
||||
@@ -189,9 +192,7 @@ class SessionManager:
|
||||
self.cur_group = SessionGroup(0)
|
||||
self.txs_sent = 0
|
||||
self.start_time = time.time()
|
||||
self.history_cache = history_cache
|
||||
self.resolve_cache = resolve_cache
|
||||
self.resolve_outputs_cache = resolve_outputs_cache
|
||||
self.history_cache = self.bp.history_cache
|
||||
self.notified_height: typing.Optional[int] = None
|
||||
# Cache some idea of room to avoid recounting on each subscription
|
||||
self.subs_room = 0
|
||||
@@ -248,7 +249,7 @@ class SessionManager:
|
||||
await self.session_event.wait()
|
||||
self.session_event.clear()
|
||||
if not paused and len(self.sessions) >= max_sessions:
|
||||
self.on_unavailable_callback()
|
||||
self.bp.status_server.set_unavailable()
|
||||
self.logger.info(f'maximum sessions {max_sessions:,d} '
|
||||
f'reached, stopping new connections until '
|
||||
f'count drops to {low_watermark:,d}')
|
||||
@@ -257,11 +258,22 @@ class SessionManager:
|
||||
# Start listening for incoming connections if paused and
|
||||
# session count has fallen
|
||||
if paused and len(self.sessions) <= low_watermark:
|
||||
self.on_available_callback()
|
||||
self.bp.status_server.set_available()
|
||||
self.logger.info('resuming listening for incoming connections')
|
||||
await self._start_external_servers()
|
||||
paused = False
|
||||
|
||||
async def _log_sessions(self):
|
||||
"""Periodically log sessions."""
|
||||
log_interval = self.env.log_sessions
|
||||
if log_interval:
|
||||
while True:
|
||||
await sleep(log_interval)
|
||||
data = self._session_data(for_log=True)
|
||||
for line in text.sessions_lines(data):
|
||||
self.logger.info(line)
|
||||
self.logger.info(json.dumps(self._get_info()))
|
||||
|
||||
def _group_map(self):
|
||||
group_map = defaultdict(list)
|
||||
for session in self.sessions.values():
|
||||
@@ -364,6 +376,23 @@ class SessionManager:
|
||||
'version': lbry.__version__,
|
||||
}
|
||||
|
||||
def _session_data(self, for_log):
|
||||
"""Returned to the RPC 'sessions' call."""
|
||||
now = time.time()
|
||||
sessions = sorted(self.sessions.values(), key=lambda s: s.start_time)
|
||||
return [(session.session_id,
|
||||
session.flags(),
|
||||
session.peer_address_str(for_log=for_log),
|
||||
session.client_version,
|
||||
session.protocol_version_string(),
|
||||
session.count_pending_items(),
|
||||
session.txs_sent,
|
||||
session.sub_count(),
|
||||
session.recv_count, session.recv_size,
|
||||
session.send_count, session.send_size,
|
||||
now - session.start_time)
|
||||
for session in sessions]
|
||||
|
||||
def _group_data(self):
|
||||
"""Returned to the RPC 'groups' call."""
|
||||
result = []
|
||||
@@ -508,19 +537,23 @@ class SessionManager:
|
||||
|
||||
return lines
|
||||
|
||||
# async def rpc_reorg(self, count):
|
||||
# """Force a reorg of the given number of blocks.
|
||||
#
|
||||
# count: number of blocks to reorg
|
||||
# """
|
||||
# count = non_negative_integer(count)
|
||||
# if not self.bp.force_chain_reorg(count):
|
||||
# raise RPCError(BAD_REQUEST, 'still catching up with daemon')
|
||||
# return f'scheduled a reorg of {count:,d} blocks'
|
||||
async def rpc_sessions(self):
|
||||
"""Return statistics about connected sessions."""
|
||||
return self._session_data(for_log=False)
|
||||
|
||||
async def rpc_reorg(self, count):
|
||||
"""Force a reorg of the given number of blocks.
|
||||
|
||||
count: number of blocks to reorg
|
||||
"""
|
||||
count = non_negative_integer(count)
|
||||
if not self.bp.force_chain_reorg(count):
|
||||
raise RPCError(BAD_REQUEST, 'still catching up with daemon')
|
||||
return f'scheduled a reorg of {count:,d} blocks'
|
||||
|
||||
# --- External Interface
|
||||
|
||||
async def serve(self, mempool, server_listening_event):
|
||||
async def serve(self, notifications, server_listening_event):
|
||||
"""Start the RPC server if enabled. When the event is triggered,
|
||||
start TCP and SSL servers."""
|
||||
try:
|
||||
@@ -534,21 +567,18 @@ class SessionManager:
|
||||
if self.env.drop_client is not None:
|
||||
self.logger.info(f'drop clients matching: {self.env.drop_client.pattern}')
|
||||
# Start notifications; initialize hsub_results
|
||||
await mempool.start(self.db.db_height, self)
|
||||
await notifications.start(self.db.db_height, self._notify_sessions)
|
||||
await self.start_other()
|
||||
await self._start_external_servers()
|
||||
server_listening_event.set()
|
||||
self.on_available_callback()
|
||||
self.bp.status_server.set_available()
|
||||
# Peer discovery should start after the external servers
|
||||
# because we connect to ourself
|
||||
await asyncio.wait([
|
||||
self._clear_stale_sessions(),
|
||||
self._log_sessions(),
|
||||
self._manage_servers()
|
||||
])
|
||||
except Exception as err:
|
||||
if not isinstance(err, asyncio.CancelledError):
|
||||
log.exception("hub server died")
|
||||
raise err
|
||||
finally:
|
||||
await self._close_servers(list(self.servers.keys()))
|
||||
log.warning("disconnect %i sessions", len(self.sessions))
|
||||
@@ -633,26 +663,19 @@ class SessionManager:
|
||||
for hashX in touched.intersection(self.mempool_statuses.keys()):
|
||||
self.mempool_statuses.pop(hashX, None)
|
||||
|
||||
# self.bp._chain_executor
|
||||
await asyncio.get_event_loop().run_in_executor(
|
||||
None, touched.intersection_update, self.hashx_subscriptions_by_session.keys()
|
||||
)
|
||||
touched.intersection_update(self.hashx_subscriptions_by_session.keys())
|
||||
|
||||
if touched or new_touched or (height_changed and self.mempool_statuses):
|
||||
if touched or (height_changed and self.mempool_statuses):
|
||||
notified_hashxs = 0
|
||||
session_hashxes_to_notify = defaultdict(list)
|
||||
notified_sessions = 0
|
||||
to_notify = touched if height_changed else new_touched
|
||||
|
||||
for hashX in to_notify:
|
||||
if hashX not in self.hashx_subscriptions_by_session:
|
||||
continue
|
||||
for session_id in self.hashx_subscriptions_by_session[hashX]:
|
||||
session_hashxes_to_notify[session_id].append(hashX)
|
||||
notified_hashxs += 1
|
||||
for session_id, hashXes in session_hashxes_to_notify.items():
|
||||
asyncio.create_task(self.sessions[session_id].send_history_notifications(*hashXes))
|
||||
if session_hashxes_to_notify:
|
||||
self.logger.info(f'notified {len(session_hashxes_to_notify)} sessions/{notified_hashxs:,d} touched addresses')
|
||||
asyncio.create_task(self.sessions[session_id].send_history_notification(hashX))
|
||||
notified_sessions += 1
|
||||
notified_hashxs += 1
|
||||
if notified_sessions:
|
||||
self.logger.info(f'notified {notified_sessions} sessions/{notified_hashxs:,d} touched addresses')
|
||||
|
||||
def add_session(self, session):
|
||||
self.sessions[id(session)] = session
|
||||
@@ -723,6 +746,16 @@ class SessionBase(RPCSession):
|
||||
def toggle_logging(self):
|
||||
self.log_me = not self.log_me
|
||||
|
||||
def flags(self):
|
||||
"""Status flags."""
|
||||
status = self.kind[0]
|
||||
if self.is_closing():
|
||||
status += 'C'
|
||||
if self.log_me:
|
||||
status += 'L'
|
||||
status += str(self._concurrency.max_concurrent)
|
||||
return status
|
||||
|
||||
def connection_made(self, transport):
|
||||
"""Handle an incoming client connection."""
|
||||
super().connection_made(transport)
|
||||
@@ -777,32 +810,44 @@ class LBRYSessionManager(SessionManager):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.query_executor = None
|
||||
self.websocket = None
|
||||
# self.metrics = ServerLoadData()
|
||||
# self.metrics_loop = None
|
||||
self.metrics = ServerLoadData()
|
||||
self.metrics_loop = None
|
||||
self.running = False
|
||||
if self.env.websocket_host is not None and self.env.websocket_port is not None:
|
||||
self.websocket = AdminWebSocket(self)
|
||||
|
||||
# async def process_metrics(self):
|
||||
# while self.running:
|
||||
# data = self.metrics.to_json_and_reset({
|
||||
# 'sessions': self.session_count(),
|
||||
# 'height': self.db.db_height,
|
||||
# })
|
||||
# if self.websocket is not None:
|
||||
# self.websocket.send_message(data)
|
||||
# await asyncio.sleep(1)
|
||||
async def process_metrics(self):
|
||||
while self.running:
|
||||
data = self.metrics.to_json_and_reset({
|
||||
'sessions': self.session_count(),
|
||||
'height': self.db.db_height,
|
||||
})
|
||||
if self.websocket is not None:
|
||||
self.websocket.send_message(data)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
async def start_other(self):
|
||||
self.running = True
|
||||
if self.env.max_query_workers is not None and self.env.max_query_workers == 0:
|
||||
self.query_executor = ThreadPoolExecutor(max_workers=1)
|
||||
else:
|
||||
self.query_executor = ProcessPoolExecutor(
|
||||
max_workers=self.env.max_query_workers or max(os.cpu_count(), 4)
|
||||
)
|
||||
if self.websocket is not None:
|
||||
await self.websocket.start()
|
||||
if self.env.track_metrics:
|
||||
self.metrics_loop = asyncio.create_task(self.process_metrics())
|
||||
|
||||
async def stop_other(self):
|
||||
self.running = False
|
||||
if self.env.track_metrics:
|
||||
self.metrics_loop.cancel()
|
||||
if self.websocket is not None:
|
||||
await self.websocket.stop()
|
||||
self.query_executor.shutdown()
|
||||
|
||||
|
||||
class LBRYElectrumX(SessionBase):
|
||||
@@ -842,8 +887,6 @@ class LBRYElectrumX(SessionBase):
|
||||
'blockchain.transaction.get_height': cls.transaction_get_height,
|
||||
'blockchain.claimtrie.search': cls.claimtrie_search,
|
||||
'blockchain.claimtrie.resolve': cls.claimtrie_resolve,
|
||||
'blockchain.claimtrie.getclaimbyid': cls.claimtrie_getclaimbyid,
|
||||
# 'blockchain.claimtrie.getclaimsbyids': cls.claimtrie_getclaimsbyids,
|
||||
'blockchain.block.get_server_height': cls.get_server_height,
|
||||
'mempool.get_fee_histogram': cls.mempool_compact_histogram,
|
||||
'blockchain.block.headers': cls.block_headers,
|
||||
@@ -872,7 +915,8 @@ class LBRYElectrumX(SessionBase):
|
||||
self.protocol_tuple = self.PROTOCOL_MIN
|
||||
self.protocol_string = None
|
||||
self.daemon = self.session_mgr.daemon
|
||||
self.db: LevelDB = self.session_mgr.db
|
||||
self.bp: LBRYBlockProcessor = self.session_mgr.bp
|
||||
self.db: LBRYLevelDB = self.bp.db
|
||||
|
||||
@classmethod
|
||||
def protocol_min_max_strings(cls):
|
||||
@@ -895,7 +939,7 @@ class LBRYElectrumX(SessionBase):
|
||||
'donation_address': env.donation_address,
|
||||
'daily_fee': env.daily_fee,
|
||||
'hash_function': 'sha256',
|
||||
'trending_algorithm': 'variable_decay'
|
||||
'trending_algorithm': env.trending_algorithms[0]
|
||||
})
|
||||
|
||||
async def server_features_async(self):
|
||||
@@ -912,154 +956,96 @@ class LBRYElectrumX(SessionBase):
|
||||
def sub_count(self):
|
||||
return len(self.hashX_subs)
|
||||
|
||||
async def send_history_notifications(self, *hashXes: typing.Iterable[bytes]):
|
||||
notifications = []
|
||||
for hashX in hashXes:
|
||||
alias = self.hashX_subs[hashX]
|
||||
if len(alias) == 64:
|
||||
method = 'blockchain.scripthash.subscribe'
|
||||
else:
|
||||
method = 'blockchain.address.subscribe'
|
||||
start = time.perf_counter()
|
||||
db_history = await self.session_mgr.limited_history(hashX)
|
||||
mempool = self.mempool.transaction_summaries(hashX)
|
||||
|
||||
status = ''.join(f'{hash_to_hex_str(tx_hash)}:'
|
||||
f'{height:d}:'
|
||||
for tx_hash, height in db_history)
|
||||
status += ''.join(f'{hash_to_hex_str(tx.hash)}:'
|
||||
f'{-tx.has_unconfirmed_inputs:d}:'
|
||||
for tx in mempool)
|
||||
if status:
|
||||
status = sha256(status.encode()).hex()
|
||||
else:
|
||||
status = None
|
||||
if mempool:
|
||||
self.session_mgr.mempool_statuses[hashX] = status
|
||||
else:
|
||||
self.session_mgr.mempool_statuses.pop(hashX, None)
|
||||
|
||||
self.session_mgr.address_history_metric.observe(time.perf_counter() - start)
|
||||
notifications.append((method, (alias, status)))
|
||||
|
||||
async def send_history_notification(self, hashX):
|
||||
start = time.perf_counter()
|
||||
self.session_mgr.notifications_in_flight_metric.inc()
|
||||
for method, args in notifications:
|
||||
self.NOTIFICATION_COUNT.labels(method=method, version=self.client_version).inc()
|
||||
alias = self.hashX_subs[hashX]
|
||||
if len(alias) == 64:
|
||||
method = 'blockchain.scripthash.subscribe'
|
||||
else:
|
||||
method = 'blockchain.address.subscribe'
|
||||
try:
|
||||
await self.send_notifications(
|
||||
Batch([Notification(method, (alias, status)) for (method, (alias, status)) in notifications])
|
||||
)
|
||||
self.session_mgr.notifications_in_flight_metric.inc()
|
||||
status = await self.address_status(hashX)
|
||||
self.session_mgr.address_history_metric.observe(time.perf_counter() - start)
|
||||
start = time.perf_counter()
|
||||
await self.send_notification(method, (alias, status))
|
||||
self.session_mgr.notifications_sent_metric.observe(time.perf_counter() - start)
|
||||
finally:
|
||||
self.session_mgr.notifications_in_flight_metric.dec()
|
||||
|
||||
# def get_metrics_or_placeholder_for_api(self, query_name):
|
||||
# """ Do not hold on to a reference to the metrics
|
||||
# returned by this method past an `await` or
|
||||
# you may be working with a stale metrics object.
|
||||
# """
|
||||
# if self.env.track_metrics:
|
||||
# # return self.session_mgr.metrics.for_api(query_name)
|
||||
# else:
|
||||
# return APICallMetrics(query_name)
|
||||
def get_metrics_or_placeholder_for_api(self, query_name):
|
||||
""" Do not hold on to a reference to the metrics
|
||||
returned by this method past an `await` or
|
||||
you may be working with a stale metrics object.
|
||||
"""
|
||||
if self.env.track_metrics:
|
||||
return self.session_mgr.metrics.for_api(query_name)
|
||||
else:
|
||||
return APICallMetrics(query_name)
|
||||
|
||||
async def run_in_executor(self, query_name, func, kwargs):
|
||||
start = time.perf_counter()
|
||||
try:
|
||||
self.session_mgr.pending_query_metric.inc()
|
||||
result = await asyncio.get_running_loop().run_in_executor(
|
||||
self.session_mgr.query_executor, func, kwargs
|
||||
)
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception:
|
||||
log.exception("dear devs, please handle this exception better")
|
||||
metrics = self.get_metrics_or_placeholder_for_api(query_name)
|
||||
metrics.query_error(start, {})
|
||||
self.session_mgr.db_error_metric.inc()
|
||||
raise RPCError(JSONRPC.INTERNAL_ERROR, 'unknown server error')
|
||||
else:
|
||||
if self.env.track_metrics:
|
||||
metrics = self.get_metrics_or_placeholder_for_api(query_name)
|
||||
(result, metrics_data) = result
|
||||
metrics.query_response(start, metrics_data)
|
||||
return base64.b64encode(result).decode()
|
||||
finally:
|
||||
self.session_mgr.pending_query_metric.dec()
|
||||
self.session_mgr.executor_time_metric.observe(time.perf_counter() - start)
|
||||
|
||||
# async def run_and_cache_query(self, query_name, kwargs):
|
||||
# start = time.perf_counter()
|
||||
# if isinstance(kwargs, dict):
|
||||
# kwargs['release_time'] = format_release_time(kwargs.get('release_time'))
|
||||
# try:
|
||||
# self.session_mgr.pending_query_metric.inc()
|
||||
# return await self.db.search_index.session_query(query_name, kwargs)
|
||||
# except ConnectionTimeout:
|
||||
# self.session_mgr.interrupt_count_metric.inc()
|
||||
# raise RPCError(JSONRPC.QUERY_TIMEOUT, 'query timed out')
|
||||
# finally:
|
||||
# self.session_mgr.pending_query_metric.dec()
|
||||
# self.session_mgr.executor_time_metric.observe(time.perf_counter() - start)
|
||||
async def run_and_cache_query(self, query_name, kwargs):
|
||||
start = time.perf_counter()
|
||||
if isinstance(kwargs, dict):
|
||||
kwargs['release_time'] = format_release_time(kwargs.get('release_time'))
|
||||
try:
|
||||
self.session_mgr.pending_query_metric.inc()
|
||||
return await self.db.search_index.session_query(query_name, kwargs)
|
||||
except ConnectionTimeout:
|
||||
self.session_mgr.interrupt_count_metric.inc()
|
||||
raise RPCError(JSONRPC.QUERY_TIMEOUT, 'query timed out')
|
||||
finally:
|
||||
self.session_mgr.pending_query_metric.dec()
|
||||
self.session_mgr.executor_time_metric.observe(time.perf_counter() - start)
|
||||
|
||||
async def mempool_compact_histogram(self):
|
||||
return self.mempool.compact_fee_histogram()
|
||||
|
||||
async def claimtrie_search(self, **kwargs):
|
||||
start = time.perf_counter()
|
||||
if 'release_time' in kwargs:
|
||||
release_time = kwargs.pop('release_time')
|
||||
if kwargs:
|
||||
try:
|
||||
kwargs['release_time'] = format_release_time(release_time)
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
self.session_mgr.pending_query_metric.inc()
|
||||
if 'channel' in kwargs:
|
||||
channel_url = kwargs.pop('channel')
|
||||
_, channel_claim, _, _ = await self.db.resolve(channel_url)
|
||||
if not channel_claim or isinstance(channel_claim, (ResolveCensoredError, LookupError, ValueError)):
|
||||
return Outputs.to_base64([], [], 0, None, None)
|
||||
kwargs['channel_id'] = channel_claim.claim_hash.hex()
|
||||
return await self.db.search_index.cached_search(kwargs)
|
||||
except ConnectionTimeout:
|
||||
self.session_mgr.interrupt_count_metric.inc()
|
||||
raise RPCError(JSONRPC.QUERY_TIMEOUT, 'query timed out')
|
||||
except TooManyClaimSearchParametersError as err:
|
||||
await asyncio.sleep(2)
|
||||
self.logger.warning("Got an invalid query from %s, for %s with more than %d elements.",
|
||||
self.peer_address()[0], err.key, err.limit)
|
||||
return RPCError(1, str(err))
|
||||
finally:
|
||||
self.session_mgr.pending_query_metric.dec()
|
||||
self.session_mgr.executor_time_metric.observe(time.perf_counter() - start)
|
||||
return await self.run_and_cache_query('search', kwargs)
|
||||
except TooManyClaimSearchParametersError as err:
|
||||
await asyncio.sleep(2)
|
||||
self.logger.warning("Got an invalid query from %s, for %s with more than %d elements.",
|
||||
self.peer_address()[0], err.key, err.limit)
|
||||
return RPCError(1, str(err))
|
||||
|
||||
async def _cached_resolve_url(self, url):
|
||||
if url not in self.session_mgr.resolve_cache:
|
||||
self.session_mgr.resolve_cache[url] = await self.loop.run_in_executor(None, self.db._resolve, url)
|
||||
return self.session_mgr.resolve_cache[url]
|
||||
|
||||
async def claimtrie_resolve(self, *urls) -> str:
|
||||
sorted_urls = tuple(sorted(urls))
|
||||
self.session_mgr.urls_to_resolve_count_metric.inc(len(sorted_urls))
|
||||
try:
|
||||
if sorted_urls in self.session_mgr.resolve_outputs_cache:
|
||||
return self.session_mgr.resolve_outputs_cache[sorted_urls]
|
||||
rows, extra = [], []
|
||||
for url in urls:
|
||||
if url not in self.session_mgr.resolve_cache:
|
||||
self.session_mgr.resolve_cache[url] = await self._cached_resolve_url(url)
|
||||
stream, channel, repost, reposted_channel = self.session_mgr.resolve_cache[url]
|
||||
if isinstance(channel, ResolveCensoredError):
|
||||
rows.append(channel)
|
||||
extra.append(channel.censor_row)
|
||||
elif isinstance(stream, ResolveCensoredError):
|
||||
rows.append(stream)
|
||||
extra.append(stream.censor_row)
|
||||
elif channel and not stream:
|
||||
rows.append(channel)
|
||||
# print("resolved channel", channel.name.decode())
|
||||
if repost:
|
||||
extra.append(repost)
|
||||
if reposted_channel:
|
||||
extra.append(reposted_channel)
|
||||
elif stream:
|
||||
# print("resolved stream", stream.name.decode())
|
||||
rows.append(stream)
|
||||
if channel:
|
||||
# print("and channel", channel.name.decode())
|
||||
extra.append(channel)
|
||||
if repost:
|
||||
extra.append(repost)
|
||||
if reposted_channel:
|
||||
extra.append(reposted_channel)
|
||||
await asyncio.sleep(0)
|
||||
self.session_mgr.resolve_outputs_cache[sorted_urls] = result = await self.loop.run_in_executor(
|
||||
None, Outputs.to_base64, rows, extra, 0, None, None
|
||||
)
|
||||
return result
|
||||
finally:
|
||||
self.session_mgr.resolved_url_count_metric.inc(len(sorted_urls))
|
||||
async def claimtrie_resolve(self, *urls):
|
||||
if urls:
|
||||
count = len(urls)
|
||||
try:
|
||||
self.session_mgr.urls_to_resolve_count_metric.inc(count)
|
||||
return await self.run_and_cache_query('resolve', urls)
|
||||
finally:
|
||||
self.session_mgr.resolved_url_count_metric.inc(count)
|
||||
|
||||
async def get_server_height(self):
|
||||
return self.db.db_height
|
||||
return self.bp.height
|
||||
|
||||
async def transaction_get_height(self, tx_hash):
|
||||
self.assert_tx_hash(tx_hash)
|
||||
@@ -1071,15 +1057,6 @@ class LBRYElectrumX(SessionBase):
|
||||
return -1
|
||||
return None
|
||||
|
||||
async def claimtrie_getclaimbyid(self, claim_id):
|
||||
rows = []
|
||||
extra = []
|
||||
stream = await self.db.fs_getclaimbyid(claim_id)
|
||||
if not stream:
|
||||
stream = LookupError(f"Could not find claim at {claim_id}")
|
||||
rows.append(stream)
|
||||
return Outputs.to_base64(rows, extra, 0, None, None)
|
||||
|
||||
def assert_tx_hash(self, value):
|
||||
'''Raise an RPCError if the value is not a valid transaction
|
||||
hash.'''
|
||||
@@ -1207,11 +1184,9 @@ class LBRYElectrumX(SessionBase):
|
||||
address: the address to subscribe to"""
|
||||
if len(addresses) > 1000:
|
||||
raise RPCError(BAD_REQUEST, f'too many addresses in subscription request: {len(addresses)}')
|
||||
results = []
|
||||
for address in addresses:
|
||||
results.append(await self.hashX_subscribe(self.address_to_hashX(address), address))
|
||||
await asyncio.sleep(0)
|
||||
return results
|
||||
return [
|
||||
await self.hashX_subscribe(self.address_to_hashX(address), address) for address in addresses
|
||||
]
|
||||
|
||||
async def address_unsubscribe(self, address):
|
||||
"""Unsubscribe an address.
|
||||
@@ -1460,20 +1435,15 @@ class LBRYElectrumX(SessionBase):
|
||||
raise RPCError(BAD_REQUEST, f'too many tx hashes in request: {len(tx_hashes)}')
|
||||
for tx_hash in tx_hashes:
|
||||
assert_tx_hash(tx_hash)
|
||||
batch_result = await self.db.get_transactions_and_merkles(tx_hashes)
|
||||
batch_result = await self.db.fs_transactions(tx_hashes)
|
||||
needed_merkles = {}
|
||||
|
||||
for tx_hash in tx_hashes:
|
||||
if tx_hash in batch_result and batch_result[tx_hash][0]:
|
||||
continue
|
||||
tx_hash_bytes = bytes.fromhex(tx_hash)[::-1]
|
||||
mempool_tx = self.mempool.txs.get(tx_hash_bytes, None)
|
||||
if mempool_tx:
|
||||
raw_tx, block_hash = mempool_tx.raw_tx.hex(), None
|
||||
else:
|
||||
tx_info = await self.daemon_request('getrawtransaction', tx_hash, 1)
|
||||
raw_tx = tx_info['hex']
|
||||
block_hash = tx_info.get('blockhash')
|
||||
tx_info = await self.daemon_request('getrawtransaction', tx_hash, True)
|
||||
raw_tx = tx_info['hex']
|
||||
block_hash = tx_info.get('blockhash')
|
||||
if block_hash:
|
||||
block = await self.daemon.deserialised_block(block_hash)
|
||||
height = block['height']
|
||||
@@ -1508,7 +1478,7 @@ class LBRYElectrumX(SessionBase):
|
||||
if verbose not in (True, False):
|
||||
raise RPCError(BAD_REQUEST, f'"verbose" must be a boolean')
|
||||
|
||||
return await self.daemon_request('getrawtransaction', tx_hash, int(verbose))
|
||||
return await self.daemon_request('getrawtransaction', tx_hash, verbose)
|
||||
|
||||
def _get_merkle_branch(self, tx_hashes, tx_pos):
|
||||
"""Return a merkle branch to a transaction.
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
# Copyright (c) 2016-2017, the ElectrumX authors
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# See the file "LICENCE" for information about the copyright
|
||||
# and warranty status of this software.
|
||||
|
||||
"""Backend database abstraction."""
|
||||
|
||||
import os
|
||||
from functools import partial
|
||||
|
||||
from lbry.wallet.server import util
|
||||
|
||||
|
||||
def db_class(db_dir, name):
|
||||
"""Returns a DB engine class."""
|
||||
for db_class in util.subclasses(Storage):
|
||||
if db_class.__name__.lower() == name.lower():
|
||||
db_class.import_module()
|
||||
return partial(db_class, db_dir)
|
||||
raise RuntimeError(f'unrecognised DB engine "{name}"')
|
||||
|
||||
|
||||
class Storage:
|
||||
"""Abstract base class of the DB backend abstraction."""
|
||||
|
||||
def __init__(self, db_dir, name, for_sync):
|
||||
self.db_dir = db_dir
|
||||
self.is_new = not os.path.exists(os.path.join(db_dir, name))
|
||||
self.for_sync = for_sync or self.is_new
|
||||
self.open(name, create=self.is_new)
|
||||
|
||||
@classmethod
|
||||
def import_module(cls):
|
||||
"""Import the DB engine module."""
|
||||
raise NotImplementedError
|
||||
|
||||
def open(self, name, create):
|
||||
"""Open an existing database or create a new one."""
|
||||
raise NotImplementedError
|
||||
|
||||
def close(self):
|
||||
"""Close an existing database."""
|
||||
raise NotImplementedError
|
||||
|
||||
def get(self, key):
|
||||
raise NotImplementedError
|
||||
|
||||
def put(self, key, value):
|
||||
raise NotImplementedError
|
||||
|
||||
def write_batch(self):
|
||||
"""Return a context manager that provides `put` and `delete`.
|
||||
|
||||
Changes should only be committed when the context manager
|
||||
closes without an exception.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def iterator(self, prefix=b'', reverse=False):
|
||||
"""Return an iterator that yields (key, value) pairs from the
|
||||
database sorted by key.
|
||||
|
||||
If `prefix` is set, only keys starting with `prefix` will be
|
||||
included. If `reverse` is True the items are returned in
|
||||
reverse order.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class LevelDB(Storage):
|
||||
"""LevelDB database engine."""
|
||||
|
||||
@classmethod
|
||||
def import_module(cls):
|
||||
import plyvel
|
||||
cls.module = plyvel
|
||||
|
||||
def open(self, name, create, lru_cache_size=None):
|
||||
mof = 10000
|
||||
path = os.path.join(self.db_dir, name)
|
||||
# Use snappy compression (the default)
|
||||
self.db = self.module.DB(path, create_if_missing=create, max_open_files=mof)
|
||||
self.close = self.db.close
|
||||
self.get = self.db.get
|
||||
self.put = self.db.put
|
||||
self.iterator = self.db.iterator
|
||||
self.write_batch = partial(self.db.write_batch, transaction=True, sync=True)
|
||||
|
||||
|
||||
class RocksDB(Storage):
|
||||
"""RocksDB database engine."""
|
||||
|
||||
@classmethod
|
||||
def import_module(cls):
|
||||
import rocksdb
|
||||
cls.module = rocksdb
|
||||
|
||||
def open(self, name, create):
|
||||
mof = 512 if self.for_sync else 128
|
||||
path = os.path.join(self.db_dir, name)
|
||||
# Use snappy compression (the default)
|
||||
options = self.module.Options(create_if_missing=create,
|
||||
use_fsync=True,
|
||||
target_file_size_base=33554432,
|
||||
max_open_files=mof)
|
||||
self.db = self.module.DB(path, options)
|
||||
self.get = self.db.get
|
||||
self.put = self.db.put
|
||||
|
||||
def close(self):
|
||||
# PyRocksDB doesn't provide a close method; hopefully this is enough
|
||||
self.db = self.get = self.put = None
|
||||
import gc
|
||||
gc.collect()
|
||||
|
||||
def write_batch(self):
|
||||
return RocksDBWriteBatch(self.db)
|
||||
|
||||
def iterator(self, prefix=b'', reverse=False):
|
||||
return RocksDBIterator(self.db, prefix, reverse)
|
||||
|
||||
|
||||
class RocksDBWriteBatch:
|
||||
"""A write batch for RocksDB."""
|
||||
|
||||
def __init__(self, db):
|
||||
self.batch = RocksDB.module.WriteBatch()
|
||||
self.db = db
|
||||
|
||||
def __enter__(self):
|
||||
return self.batch
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if not exc_val:
|
||||
self.db.write(self.batch)
|
||||
|
||||
|
||||
class RocksDBIterator:
|
||||
"""An iterator for RocksDB."""
|
||||
|
||||
def __init__(self, db, prefix, reverse):
|
||||
self.prefix = prefix
|
||||
if reverse:
|
||||
self.iterator = reversed(db.iteritems())
|
||||
nxt_prefix = util.increment_byte_string(prefix)
|
||||
if nxt_prefix:
|
||||
self.iterator.seek(nxt_prefix)
|
||||
try:
|
||||
next(self.iterator)
|
||||
except StopIteration:
|
||||
self.iterator.seek(nxt_prefix)
|
||||
else:
|
||||
self.iterator.seek_to_last()
|
||||
else:
|
||||
self.iterator = db.iteritems()
|
||||
self.iterator.seek(prefix)
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
k, v = next(self.iterator)
|
||||
if not k.startswith(self.prefix):
|
||||
raise StopIteration
|
||||
return k, v
|
||||
@@ -0,0 +1,82 @@
|
||||
import time
|
||||
|
||||
from lbry.wallet.server import util
|
||||
|
||||
|
||||
def sessions_lines(data):
|
||||
"""A generator returning lines for a list of sessions.
|
||||
|
||||
data is the return value of rpc_sessions()."""
|
||||
fmt = ('{:<6} {:<5} {:>17} {:>5} {:>5} {:>5} '
|
||||
'{:>7} {:>7} {:>7} {:>7} {:>7} {:>9} {:>21}')
|
||||
yield fmt.format('ID', 'Flags', 'Client', 'Proto',
|
||||
'Reqs', 'Txs', 'Subs',
|
||||
'Recv', 'Recv KB', 'Sent', 'Sent KB', 'Time', 'Peer')
|
||||
for (id_, flags, peer, client, proto, reqs, txs_sent, subs,
|
||||
recv_count, recv_size, send_count, send_size, time) in data:
|
||||
yield fmt.format(id_, flags, client, proto,
|
||||
f'{reqs:,d}',
|
||||
f'{txs_sent:,d}',
|
||||
f'{subs:,d}',
|
||||
f'{recv_count:,d}',
|
||||
'{:,d}'.format(recv_size // 1024),
|
||||
f'{send_count:,d}',
|
||||
'{:,d}'.format(send_size // 1024),
|
||||
util.formatted_time(time, sep=''), peer)
|
||||
|
||||
|
||||
def groups_lines(data):
|
||||
"""A generator returning lines for a list of groups.
|
||||
|
||||
data is the return value of rpc_groups()."""
|
||||
|
||||
fmt = ('{:<6} {:>9} {:>9} {:>6} {:>6} {:>8}'
|
||||
'{:>7} {:>9} {:>7} {:>9}')
|
||||
yield fmt.format('ID', 'Sessions', 'Bwidth KB', 'Reqs', 'Txs', 'Subs',
|
||||
'Recv', 'Recv KB', 'Sent', 'Sent KB')
|
||||
for (id_, session_count, bandwidth, reqs, txs_sent, subs,
|
||||
recv_count, recv_size, send_count, send_size) in data:
|
||||
yield fmt.format(id_,
|
||||
f'{session_count:,d}',
|
||||
'{:,d}'.format(bandwidth // 1024),
|
||||
f'{reqs:,d}',
|
||||
f'{txs_sent:,d}',
|
||||
f'{subs:,d}',
|
||||
f'{recv_count:,d}',
|
||||
'{:,d}'.format(recv_size // 1024),
|
||||
f'{send_count:,d}',
|
||||
'{:,d}'.format(send_size // 1024))
|
||||
|
||||
|
||||
def peers_lines(data):
|
||||
"""A generator returning lines for a list of peers.
|
||||
|
||||
data is the return value of rpc_peers()."""
|
||||
def time_fmt(t):
|
||||
if not t:
|
||||
return 'Never'
|
||||
return util.formatted_time(now - t)
|
||||
|
||||
now = time.time()
|
||||
fmt = ('{:<30} {:<6} {:>5} {:>5} {:<17} {:>4} '
|
||||
'{:>4} {:>8} {:>11} {:>11} {:>5} {:>20} {:<15}')
|
||||
yield fmt.format('Host', 'Status', 'TCP', 'SSL', 'Server', 'Min',
|
||||
'Max', 'Pruning', 'Last Good', 'Last Try',
|
||||
'Tries', 'Source', 'IP Address')
|
||||
for item in data:
|
||||
features = item['features']
|
||||
hostname = item['host']
|
||||
host = features['hosts'][hostname]
|
||||
yield fmt.format(hostname[:30],
|
||||
item['status'],
|
||||
host.get('tcp_port') or '',
|
||||
host.get('ssl_port') or '',
|
||||
features['server_version'] or 'unknown',
|
||||
features['protocol_min'],
|
||||
features['protocol_max'],
|
||||
features['pruning'] or '',
|
||||
time_fmt(item['last_good']),
|
||||
time_fmt(item['last_try']),
|
||||
item['try_count'],
|
||||
item['source'][:20],
|
||||
item['ip_addr'] or '')
|
||||
@@ -26,7 +26,7 @@
|
||||
# and warranty status of this software.
|
||||
|
||||
"""Transaction-related classes and functions."""
|
||||
import typing
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
from lbry.wallet.server.hash import sha256, double_sha256, hash_to_hex_str
|
||||
@@ -41,20 +41,11 @@ ZERO = bytes(32)
|
||||
MINUS_1 = 4294967295
|
||||
|
||||
|
||||
class Tx(typing.NamedTuple):
|
||||
version: int
|
||||
inputs: typing.List['TxInput']
|
||||
outputs: typing.List['TxOutput']
|
||||
locktime: int
|
||||
raw: bytes
|
||||
class Tx(namedtuple("Tx", "version inputs outputs locktime raw")):
|
||||
"""Class representing a transaction."""
|
||||
|
||||
|
||||
class TxInput(typing.NamedTuple):
|
||||
prev_hash: bytes
|
||||
prev_idx: int
|
||||
script: bytes
|
||||
sequence: int
|
||||
|
||||
class TxInput(namedtuple("TxInput", "prev_hash prev_idx script sequence")):
|
||||
"""Class representing a transaction input."""
|
||||
def __str__(self):
|
||||
script = self.script.hex()
|
||||
@@ -74,9 +65,7 @@ class TxInput(typing.NamedTuple):
|
||||
))
|
||||
|
||||
|
||||
class TxOutput(typing.NamedTuple):
|
||||
value: int
|
||||
pk_script: bytes
|
||||
class TxOutput(namedtuple("TxOutput", "value pk_script")):
|
||||
|
||||
def serialize(self):
|
||||
return b''.join((
|
||||
|
||||
@@ -340,7 +340,7 @@ pack_le_int64 = struct_le_q.pack
|
||||
pack_le_uint16 = struct_le_H.pack
|
||||
pack_le_uint32 = struct_le_I.pack
|
||||
pack_be_uint64 = lambda x: x.to_bytes(8, byteorder='big')
|
||||
pack_be_uint16 = lambda x: x.to_bytes(2, byteorder='big')
|
||||
pack_be_uint16 = struct_be_H.pack
|
||||
pack_be_uint32 = struct_be_I.pack
|
||||
pack_byte = structB.pack
|
||||
|
||||
|
||||
@@ -459,12 +459,6 @@ class Output(InputOutput):
|
||||
self.signable.signature = channel.private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
|
||||
self.script.generate()
|
||||
|
||||
def sign_data(self, data:bytes, timestamp:str) -> str:
|
||||
pieces = [timestamp.encode(), self.claim_hash, data]
|
||||
digest = sha256(b''.join(pieces))
|
||||
signature = self.private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
|
||||
return hexlify(signature).decode()
|
||||
|
||||
def clear_signature(self):
|
||||
self.channel = None
|
||||
self.signable.clear_signature()
|
||||
|
||||
@@ -40,17 +40,22 @@ def checkrecord(record, expected_winner, expected_claim):
|
||||
|
||||
|
||||
async def checkcontrolling(daemon: Daemon, db: SQLDB):
|
||||
records, names, futs = [], [], []
|
||||
records, claim_ids, names, futs = [], [], [], []
|
||||
for record in db.get_claims('claimtrie.claim_hash as is_controlling, claim.*', is_controlling=True):
|
||||
records.append(record)
|
||||
claim_id = hex_reverted(record['claim_hash'])
|
||||
names.append((record['normalized'], (claim_id,), "", True)) # last parameter is IncludeValues
|
||||
claim_ids.append((claim_id,))
|
||||
names.append((record['normalized'],))
|
||||
if len(names) > 50000:
|
||||
futs.append(daemon._send_vector('getclaimsfornamebyid', names))
|
||||
futs.append(daemon._send_vector('getvalueforname', names[:]))
|
||||
futs.append(daemon._send_vector('getclaimbyid', claim_ids[:]))
|
||||
names.clear()
|
||||
claim_ids.clear()
|
||||
if names:
|
||||
futs.append(daemon._send_vector('getclaimsfornamebyid', names))
|
||||
futs.append(daemon._send_vector('getvalueforname', names[:]))
|
||||
futs.append(daemon._send_vector('getclaimbyid', claim_ids[:]))
|
||||
names.clear()
|
||||
claim_ids.clear()
|
||||
|
||||
while futs:
|
||||
winners, claims = futs.pop(0), futs.pop(0)
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
import asyncio
|
||||
import argparse
|
||||
import logging
|
||||
from typing import Optional
|
||||
from aiohttp import web
|
||||
from prometheus_client import generate_latest as prom_generate_latest, Gauge
|
||||
|
||||
from lbry.dht.constants import generate_id
|
||||
from lbry.dht.node import Node
|
||||
from lbry.dht.peer import PeerManager
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
from lbry.conf import Config
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)-4s %(name)s:%(lineno)d: %(message)s")
|
||||
log = logging.getLogger(__name__)
|
||||
BLOBS_STORED = Gauge(
|
||||
"blobs_stored", "Number of blob info received", namespace="dht_node",
|
||||
labelnames=("method",)
|
||||
)
|
||||
PEERS = Gauge(
|
||||
"known_peers", "Number of peers on routing table", namespace="dht_node",
|
||||
labelnames=("method",)
|
||||
)
|
||||
|
||||
|
||||
class SimpleMetrics:
|
||||
def __init__(self, port):
|
||||
self.prometheus_port = port
|
||||
|
||||
async def handle_metrics_get_request(self, request: web.Request):
|
||||
try:
|
||||
return web.Response(
|
||||
text=prom_generate_latest().decode(),
|
||||
content_type='text/plain; version=0.0.4'
|
||||
)
|
||||
except Exception:
|
||||
log.exception('could not generate prometheus data')
|
||||
raise
|
||||
|
||||
async def start(self):
|
||||
prom_app = web.Application()
|
||||
prom_app.router.add_get('/metrics', self.handle_metrics_get_request)
|
||||
metrics_runner = web.AppRunner(prom_app)
|
||||
await metrics_runner.setup()
|
||||
prom_site = web.TCPSite(metrics_runner, "0.0.0.0", self.prometheus_port)
|
||||
await prom_site.start()
|
||||
|
||||
|
||||
async def main(host: str, port: int, db_file_path: str, bootstrap_node: Optional[str], prometheus_port: int):
|
||||
if prometheus_port > 0:
|
||||
metrics = SimpleMetrics(prometheus_port)
|
||||
await metrics.start()
|
||||
loop = asyncio.get_event_loop()
|
||||
conf = Config()
|
||||
storage = SQLiteStorage(conf, db_file_path, loop, loop.time)
|
||||
if bootstrap_node:
|
||||
nodes = bootstrap_node.split(':')
|
||||
nodes = [(nodes[0], int(nodes[1]))]
|
||||
else:
|
||||
nodes = conf.known_dht_nodes
|
||||
await storage.open()
|
||||
node = Node(
|
||||
loop, PeerManager(loop), generate_id(), port, port, 3333, None,
|
||||
storage=storage
|
||||
)
|
||||
node.start(host, nodes)
|
||||
while True:
|
||||
await asyncio.sleep(10)
|
||||
PEERS.labels('main').set(len(node.protocol.routing_table.get_peers()))
|
||||
BLOBS_STORED.labels('main').set(len(node.protocol.data_store.get_storing_contacts()))
|
||||
log.info("Known peers: %d. Storing contact information for %d blobs from %d peers.",
|
||||
len(node.protocol.routing_table.get_peers()), len(node.protocol.data_store),
|
||||
len(node.protocol.data_store.get_storing_contacts()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Starts a single DHT node, which then can be used as a seed node or just a contributing node.")
|
||||
parser.add_argument("--host", default='0.0.0.0', type=str, help="Host to listen for requests. Default: 0.0.0.0")
|
||||
parser.add_argument("--port", default=4444, type=int, help="Port to listen for requests. Default: 4444")
|
||||
parser.add_argument("--db_file", default='/tmp/dht.db', type=str, help="DB file to save peers. Default: /tmp/dht.db")
|
||||
parser.add_argument("--bootstrap_node", default=None, type=str,
|
||||
help="Node to connect for bootstraping this node. Leave unset to use the default ones. "
|
||||
"Format: host:port Example: lbrynet1.lbry.com:4444")
|
||||
parser.add_argument("--prometheus_port", default=0, type=int, help="Port for Prometheus metrics. 0 to disable. Default: 0")
|
||||
args = parser.parse_args()
|
||||
asyncio.run(main(args.host, args.port, args.db_file, args.bootstrap_node, args.prometheus_port))
|
||||
@@ -13,6 +13,7 @@ from lbry.extras.cli import set_kwargs, get_argument_parser
|
||||
from lbry.extras.daemon.daemon import (
|
||||
Daemon, jsonrpc_dumps_pretty, encode_pagination_doc
|
||||
)
|
||||
from tests.integration.other.test_comment_commands import MockedCommentServer
|
||||
from lbry.extras.daemon.json_response_encoder import (
|
||||
encode_tx_doc, encode_txo_doc, encode_account_doc, encode_file_doc,
|
||||
encode_wallet_doc
|
||||
@@ -66,6 +67,10 @@ class Examples(CommandTestCase):
|
||||
|
||||
async def asyncSetUp(self):
|
||||
await super().asyncSetUp()
|
||||
self.daemon.conf.comment_server = 'http://localhost:2903/api'
|
||||
self.comment_server = MockedCommentServer(2903)
|
||||
await self.comment_server.start()
|
||||
self.addCleanup(self.comment_server.stop)
|
||||
self.recorder = ExampleRecorder(self)
|
||||
|
||||
async def play(self):
|
||||
@@ -325,6 +330,41 @@ class Examples(CommandTestCase):
|
||||
await self.daemon.jsonrpc_channel_abandon(self.get_claim_id(big_stream))
|
||||
await self.generate(1)
|
||||
|
||||
# comments
|
||||
|
||||
comment = await r(
|
||||
'Posting a comment as your channel',
|
||||
'comment', 'create', '--comment="Thank you Based God"',
|
||||
'--channel_name=@channel', f'--claim_id={stream_id}'
|
||||
)
|
||||
|
||||
reply = await r(
|
||||
'Use the parent_id param to make replies',
|
||||
'comment', 'create',
|
||||
'--comment="I have photographic evidence confirming Sasquatch exists"',
|
||||
f'--channel_name=@channel', f'--parent_id={comment["comment_id"]}',
|
||||
f'--claim_id={stream_id}'
|
||||
)
|
||||
|
||||
await r(
|
||||
'List all comments on a claim',
|
||||
'comment', 'list', stream_id, '--include_replies'
|
||||
)
|
||||
|
||||
await r(
|
||||
'List a comment thread replying to a top level comment',
|
||||
'comment', 'list', stream_id,
|
||||
f'--parent_id={comment["comment_id"]}'
|
||||
)
|
||||
|
||||
await r(
|
||||
'Edit the contents of a comment',
|
||||
'comment', 'update', 'Where there was once sasquatch, there is not',
|
||||
f'--comment_id={comment["comment_id"]}'
|
||||
)
|
||||
|
||||
await self.daemon.jsonrpc_comment_abandon(reply['comment_id'])
|
||||
|
||||
# collections
|
||||
collection = await r(
|
||||
'Create a collection of one stream',
|
||||
@@ -391,6 +431,11 @@ class Examples(CommandTestCase):
|
||||
|
||||
# abandon all the things
|
||||
|
||||
await r(
|
||||
'Abandon a comment',
|
||||
'comment', 'abandon', comment['comment_id']
|
||||
)
|
||||
|
||||
abandon_stream = await r(
|
||||
'Abandon a stream claim',
|
||||
'stream', 'abandon', stream_id
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
SNAPSHOT_HEIGHT="1049658"
|
||||
|
||||
HUB_VOLUME_PATH="/var/lib/docker/volumes/${USER}_wallet_server"
|
||||
ES_VOLUME_PATH="/var/lib/docker/volumes/${USER}_es01"
|
||||
|
||||
SNAPSHOT_TAR_NAME="wallet_server_snapshot_${SNAPSHOT_HEIGHT}.tar"
|
||||
ES_SNAPSHOT_TAR_NAME="es_snapshot_${SNAPSHOT_HEIGHT}.tar"
|
||||
|
||||
SNAPSHOT_URL="https://snapshots.lbry.com/hub/${SNAPSHOT_TAR_NAME}"
|
||||
ES_SNAPSHOT_URL="https://snapshots.lbry.com/hub/${ES_SNAPSHOT_TAR_NAME}"
|
||||
|
||||
echo "fetching wallet server snapshot"
|
||||
wget $SNAPSHOT_URL
|
||||
echo "decompressing wallet server snapshot"
|
||||
tar -xf $SNAPSHOT_TAR_NAME
|
||||
sudo mkdir -p $HUB_VOLUME_PATH
|
||||
sudo rm -rf "${HUB_VOLUME_PATH}/_data"
|
||||
sudo chown -R 999:999 "snapshot_${SNAPSHOT_HEIGHT}"
|
||||
sudo mv "snapshot_${SNAPSHOT_HEIGHT}" "${HUB_VOLUME_PATH}/_data"
|
||||
echo "finished setting up wallet server snapshot"
|
||||
|
||||
echo "fetching elasticsearch snapshot"
|
||||
wget $ES_SNAPSHOT_URL
|
||||
echo "decompressing elasticsearch snapshot"
|
||||
tar -xf $ES_SNAPSHOT_TAR_NAME
|
||||
sudo chown -R $USER:root "snapshot_es_${SNAPSHOT_HEIGHT}"
|
||||
sudo chmod -R 775 "snapshot_es_${SNAPSHOT_HEIGHT}"
|
||||
sudo mkdir -p $ES_VOLUME_PATH
|
||||
sudo rm -rf "${ES_VOLUME_PATH}/_data"
|
||||
sudo mv "snapshot_es_${SNAPSHOT_HEIGHT}" "${ES_VOLUME_PATH}/_data"
|
||||
echo "finished setting up elasticsearch snapshot"
|
||||
@@ -5,9 +5,6 @@ branch = True
|
||||
source =
|
||||
lbry
|
||||
.tox/*/lib/python*/site-packages/lbry
|
||||
omit =
|
||||
lbry/wallet/orchstr8/
|
||||
.tox/*/lib/python*/site-packages/lbry/wallet/orchstr8/node.py
|
||||
|
||||
[cryptography.*,coincurve.*,pbkdf2, libtorrent]
|
||||
ignore_missing_imports = True
|
||||
@@ -24,7 +21,6 @@ disable=
|
||||
c-extension-no-member,
|
||||
fixme,
|
||||
broad-except,
|
||||
raise-missing-from,
|
||||
no-else-return,
|
||||
cyclic-import,
|
||||
missing-docstring,
|
||||
@@ -41,6 +37,5 @@ disable=
|
||||
too-many-public-methods,
|
||||
too-many-return-statements,
|
||||
too-many-instance-attributes,
|
||||
unspecified-encoding,
|
||||
protected-access,
|
||||
unused-argument
|
||||
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user