create account

V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest by brianoflondon

View this thread on: hive.blogpeakd.comecency.com
· @brianoflondon ·
$23.11
V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest
**[Support Proposal 342 on PeakD](https://peakd.com/me/proposals/342)
[Vote for Brianoflondon's Witness KeyChain or HiveSigner](https://vote.hive.uno/@brianoflondon)**

***This is a value for value post: see the explanation in the footer.***


![docker container frustration in the forest from grok.jpg](https://files.peakd.com/file/peakd-hive/brianoflondon/EpEKDkoxz3JiRraBS45RgBHKFQkK61FQoqKSLzaE9KnZ9AbnRqLgKeXp2JDNn4xJ9V8.jpg)


---

## Working on @v4vapp and @vsc.network 

I'm still here! I'm still working! I've not been posting much but I should. So here's a post and a very quick update.

I'm working on rebuilding the entire back end of @v4vapp both to be public source and (one day) runnable by others. And I'm working toward the direction of using @vsc.network as the BTC/Hive/HBD exchange as and when those features become available. This is a pretty huge change for me.

That's also why I'm deeply involved with @vaultec and his crew to make sure we keep heading in the same direction.

## Minor changes to @v4vapp 

I didn't really mention it but the front end got a few tweaks like zoom controls on the camera for scanning QR Codes. Also the system now copes properly with internal transfers (even if these are via Lightning). It's crazy how Lightning does this internally, but I'm coping with it now. It just means that if you try using [v4v.app](https://v4v.app/) to send Lightning to another Hive user's Lightning address (mine is `brianoflondon@sats.v4v.app` it works.

I'm working most of the time on by `v4vapp-backend-v2` which is a public Github repo. It's not really decipherable right now, but a lot of work is going into it.

## Nectar replacing Beem

There is a whole push for new dev tools with @blocktrades team having come up with some great new code but it's not finished and really ready. In the mean time the old Python library called Beem remained my main working system but it has problems.

In steps @thecrazygm and starts converting it into something called [Nectar](https://github.com/TheCrazyGM/hive-nectar) `pip install hive-nectar`. This is great and I've put in a couple of pull requests already and have more I'll be sending in.

### Async streaming of blocks

Chief amongst this will be an async block stream which I'm using in my code and is starting to be really really reliable. It's public already but burried in my code, I'll work with @thecrazygm to put this direct into the **Nectar** code.

## Code lesson for today: MongodDB Replica Set locally and on Github Actions

Do let me know in the comments if any of this is helpful to you!

This took me far longer than you'd think to get work. With a million prompts to Co-Pilot and Grok you'd be surprised at just how bad these two things were at really understanding the underlying complexity of this.

### MongoDB Replica Sets

MongoDB is easy peasy to set up for a single instance running in a docker container. But in production and for certain of the more advanced features of this database like "change streams" you need something called a replica set. This is designed to run on multiple computers simultaneously and copies all its data around the whole "cluster" automatically.

But when you're writing software you really need a local copy of this running on your machine and you probably don't want three of these. Docker containers are perfect for this and it should be easy, right?

### The big gotcha

The big gotcha that took me hours to really get to grips with is that the usually distinct internal network name and port inside the Docker container, and the external name by which you address the replica set cluster (even though it's only one machine). MUST BE THE SAME!

So if you're connecting on `localhost:37017` outside the container, you must ensure that `localhost37017` is the same name used when setting up the replica set in the container.

Trust me on this (past those two paragraphs into Grok and ask it why I'm right).

### So here's the answer: localhost and Github Actions

#### The Connection string

If you use the two config files below, the connection string for connecting to your MongoDB on both Github actions and your local machine will be:

`mongodb://127.0.0.1:37017/?replicaSet=rsPytest`

#### docker_compose.yaml 

```yaml
services:
  mongo-pytest-local:
    image: mongo:8.0
    command: >
      bash -c "
        mongod --replSet rsPytest --bind_ip_all --port 37017 &
        sleep 10 &&
        mongosh --port 37017 --eval 'rs.initiate({
          _id: \"rsPytest\",
          members: [{ _id: 0, host: \"127.0.0.1:37017\" }]
        })' &&
        wait
      "
    ports:
      - "127.0.0.1:37017:37017"
      - "${LOCAL_TAILSCALE_IP}:37017:37017"
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.runCommand({ ping: 1 })"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped
    networks:
      - v4vapp-backend
    volumes:
      - mongo_data:/data/db
      - mongo_config:/data/configdb

volumes:
  mongo_data:
  mongo_config:

networks:
  v4vapp-backend:
    driver: bridge

```

#### .github/workflows/pytest.yaml

This includes the code for running my code using `uv` but I'm giving the whole file for completeness, you can see the docker setup for MongoDB (and Redis too).

```yaml
name: Pytest

on:
  push:
    branches:
      - main
      - develop
    tags:
      - "v*"
  pull_request:
    branches:
      - main
      - develop
    paths-ignore:
      - "**.md"
      - ".gitignore"
      - "LICENSE"
      - ".env*"

jobs:
  test:
    runs-on: ubuntu-latest
    services:
      redis:
        image: redis:latest
        ports:
          - "6379:6379"

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      # Install UV
      - name: Install UV
        run: |
          curl -LsSf https://astral.sh/uv/install.sh | sh
          echo "$HOME/.cargo/bin" >> $GITHUB_PATH

      # Cache virtual environment
      - name: Cache UV virtual environment
        id: cache-venv
        uses: actions/cache@v4
        with:
          path: .venv
          key: uv-venv-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }}

      # Set up virtual environment and sync dependencies
      - name: Set up UV environment and install dependencies
        if: steps.cache-venv.outputs.cache-hit != 'true'
        run: |
          uv venv --python 3.12
          uv sync --group dev

      # Ensure UV is available and sync if cache is hit
      - name: Sync UV dependencies (post-cache)
        run: |
          uv sync --group dev

      # Check UV version
      - name: Check UV version
        run: uv --version

      # List installed packages
      - name: List installed packages
        run: uv pip list

      # Start MongoDB with replica set
      - name: Start MongoDB
        uses: supercharge/mongodb-github-action@1.12.0
        with:
          mongodb-version: '8.0'
          mongodb-replica-set: rsPytest
          mongodb-port: 37017

      # Set PYTHONPATH
      - name: Set PYTHONPATH
        run: echo "PYTHONPATH=$PWD/src" >> $GITHUB_ENV

      # Run tests
      - name: Test with pytest
        env:
          HIVE_ACC_TEST: ${{ secrets.HIVE_ACC_TEST }}
          HIVE_MEMO_TEST_KEY: ${{ secrets.HIVE_MEMO_TEST_KEY }}
        run: |
          uv run pytest

      # Print service container logs only if tests fail
      - name: Print service container logs
        if: failure()
        run: |
          echo "MongoDB logs:"
          docker logs $(docker ps -q --filter "ancestor=mongo:8.0")
          echo "Redis logs:"
          docker logs $(docker ps -q --filter "ancestor=redis:latest")
```


-------

## Value for Value

For the last few months while building @v4vapp I was generously supported by the DHF. Going forward I have a much more modest support which covers direct server costs and a little of my time.

If you appreciate the work I do on and around Hive, you can express this directly: upvoting posts on Hive is great. Also consider a direct donation (there's a Tip button on Hive or a Lightning Address) on all my posts.

<div class="pull-right">


![hivebuzz-orca-120.png](https://files.peakd.com/file/peakd-hive/brianoflondon/AJmtP4HQY8c2Ej3D2k6ZxhKZqUh6R2hDWcVDkpVacwCbt5c9R9R2LowiycVhAM7.png)

</div>

<div class="pull-right">

https://images.hive.blog/130x130/http://hivebuzz.me/badges/birthday-6.png

</div>

**[Support Proposal 342 on PeakD](https://peakd.com/me/proposals/342)
[Support Proposal 342 with Hivesigner](https://hivesigner.com/sign/update-proposal-votes?proposal_ids=%5B342%5D&approve=true)
[Support Proposal 303 on Ecency](https://ecency.com/proposals/303)
[Vote for Brianoflondon's Witness KeyChain or HiveSigner](https://vote.hive.uno/@brianoflondon)**

-------

<div class="pull-right">

![Send Lightning to Me!](https://files.peakd.com/file/peakd-hive/brianoflondon/AK3gcbmQA5oP28nnfgu5MiW8JCXw1XA6tYghwFWbSkPW2P6hXto5i7TDRTkPRVa.png)
</div>

- [Find me on Telegram](https://t.me/brianoflondon)
- [V4VAPP Support on Telegram](https://t.me/v4vapp_support)
- [Vote for Brianoflondon's Witness KeyChain or HiveSigner](https://vote.hive.uno/@brianoflondon)
- [Vote for Brianoflondon's Witness direct with HiveSigner](https://hivesigner.com/sign/account-witness-vote?witness=brianoflondon&approve=1)
- [Find my videos on 3speak](https://3speak.tv/user/brianoflondon)
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 131 others
properties (23)
authorbrianoflondon
permlinkv4vapp-update-plus-how-to-mongoddb-replica-set-on-a-local-machine-and-github-actions-pytest
categoryhive-110369
json_metadata"{"app":"peakd/2025.4.6","format":"markdown","description":"`localhost:37017` outside the container, you must ensure that `localhost37017` is the same name in the container.","tags":["v4vapp","python","github","docker","leofinance","proofofbrain","mongodb","replicasets"],"users":["brianoflondon","v4vapp","vsc.network","vaultec","sats.v4v.app","blocktrades","thecrazygm","1.12.0"],"image":["https://files.peakd.com/file/peakd-hive/brianoflondon/EpEKDkoxz3JiRraBS45RgBHKFQkK61FQoqKSLzaE9KnZ9AbnRqLgKeXp2JDNn4xJ9V8.jpg","https://files.peakd.com/file/peakd-hive/brianoflondon/AJmtP4HQY8c2Ej3D2k6ZxhKZqUh6R2hDWcVDkpVacwCbt5c9R9R2LowiycVhAM7.png","https://images.hive.blog/130x130/http://hivebuzz.me/badges/birthday-6.png","https://files.peakd.com/file/peakd-hive/brianoflondon/AK3gcbmQA5oP28nnfgu5MiW8JCXw1XA6tYghwFWbSkPW2P6hXto5i7TDRTkPRVa.png"]}"
created2025-04-20 10:06:51
last_update2025-04-20 10:06:51
depth0
children13
last_payout2025-04-27 10:06:51
cashout_time1969-12-31 23:59:59
total_payout_value11.564 HBD
curator_payout_value11.543 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9,424
author_reputation759,674,214,959,955
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,203,572
net_rshares65,963,479,292,860
author_curate_reward""
vote details (195)
@apshamilton ·
$2.63
Very impressive, although I only understood about half of it! :-)
πŸ‘  
properties (23)
authorapshamilton
permlinkre-brianoflondon-sv11ic
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.4.6","image":[],"users":[]}
created2025-04-20 17:20:39
last_update2025-04-20 17:20:39
depth1
children0
last_payout2025-04-27 17:20:39
cashout_time1969-12-31 23:59:59
total_payout_value1.316 HBD
curator_payout_value1.316 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length65
author_reputation212,404,184,641,750
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,210,867
net_rshares7,521,196,131,269
author_curate_reward""
vote details (1)
@borsengelaber ·
$3.06
Hey Brian, 
good to hear from you again. Those things you are working on sound very promising though I don’t get too much of the coding deep dive. But I understood its still the plan to decentralize v4vapp, which I think is very valuable. πŸ’ͺ🏻

What I wanted to try is sending literally Sats to another Hive Account. How does that work? Is the LN adress always username@sats.v4vapp?

Have a great sunday and talk soon 
Thomas 
πŸ‘  
properties (23)
authorborsengelaber
permlinkre-brianoflondon-2025420t122643600z
categoryhive-110369
json_metadata{"type":"comment","tags":["hive-110369","v4vapp","python","github","docker","leofinance","proofofbrain","mongodb","replicasets"],"app":"ecency/3.3.0-mobile","format":"markdown+html"}
created2025-04-20 10:26:42
last_update2025-04-20 10:26:42
depth1
children2
last_payout2025-04-27 10:26:42
cashout_time1969-12-31 23:59:59
total_payout_value1.532 HBD
curator_payout_value1.532 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length424
author_reputation316,895,270,302,807
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,203,798
net_rshares8,737,577,541,385
author_curate_reward""
vote details (1)
@brianoflondon ·
The internal transfers are useful for programmatic stuff which @sstarker others are doing for on boarding btc communities. 
properties (22)
authorbrianoflondon
permlinkre-borsengelaber-sv0zz1
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.4.6"}
created2025-04-20 16:47:27
last_update2025-04-20 16:47:27
depth2
children1
last_payout2025-04-27 16:47:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length123
author_reputation759,674,214,959,955
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,210,457
net_rshares0
@borsengelaber ·
Ah, so nothing for regular use and β€žnormal Hiversβ€œ?
properties (22)
authorborsengelaber
permlinkre-brianoflondon-2025420t185514851z
categoryhive-110369
json_metadata{"type":"comment","tags":["hive-110369"],"app":"ecency/3.3.0-mobile","format":"markdown+html"}
created2025-04-20 16:55:15
last_update2025-04-20 16:55:15
depth3
children0
last_payout2025-04-27 16:55:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length51
author_reputation316,895,270,302,807
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,210,557
net_rshares0
@consistency ·
$1.59
This is a very big news
Keep up doing the great work and I am really super proud
You are a big inspiration 
πŸ‘  
properties (23)
authorconsistency
permlinkre-brianoflondon-sv0vbc
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.4.6","image":[],"users":[]}
created2025-04-20 15:06:51
last_update2025-04-20 15:06:51
depth1
children0
last_payout2025-04-27 15:06:51
cashout_time1969-12-31 23:59:59
total_payout_value0.794 HBD
curator_payout_value0.795 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length107
author_reputation9,615,801,994,776
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,207,931
net_rshares4,502,289,330,126
author_curate_reward""
vote details (1)
@cwow2 ·
$3.01
I have a question. If I swap my BNB on BSC to BTC, can I then transfer it to Hive via V4V? 
I am having trouble transferring BNB to HE xD
πŸ‘  
πŸ‘Ž  
properties (23)
authorcwow2
permlinkre-brianoflondon-sv0jvw
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.4.6","image":[],"users":[]}
created2025-04-20 10:59:54
last_update2025-04-20 10:59:54
depth1
children2
last_payout2025-04-27 10:59:54
cashout_time1969-12-31 23:59:59
total_payout_value1.502 HBD
curator_payout_value1.503 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length137
author_reputation207,069,606,942,377
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,204,194
net_rshares8,563,021,829,304
author_curate_reward""
vote details (2)
@brianoflondon ·
$0.03
My system is only good for sats in the form of Lightning. If you can send as lightning to @v4vapp you can get Hive or HBD. 
πŸ‘  
properties (23)
authorbrianoflondon
permlinkre-cwow2-sv1012
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.4.6"}
created2025-04-20 16:48:39
last_update2025-04-20 16:48:39
depth2
children1
last_payout2025-04-27 16:48:39
cashout_time1969-12-31 23:59:59
total_payout_value0.016 HBD
curator_payout_value0.016 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length123
author_reputation759,674,214,959,955
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,210,471
net_rshares95,527,908,102
author_curate_reward""
vote details (1)
@cwow2 ·
Dude, I don't fking know these things haha :D
I am so bad at crypto in generel its a laugh. I am only on Hive xD
properties (22)
authorcwow2
permlinkre-brianoflondon-sv11ub
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.4.6","image":[],"users":[]}
created2025-04-20 17:27:48
last_update2025-04-20 17:27:48
depth3
children0
last_payout2025-04-27 17:27:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length113
author_reputation207,069,606,942,377
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,210,970
net_rshares0
@epodcaster ·
$2.59
You've been quiet lately, so I figured you must be busy both in the real world and on the back end of things. It was good to get an update on what's been going on. Cheers!
πŸ‘  
properties (23)
authorepodcaster
permlinkre-brianoflondon-sv4mgt
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.4.6","image":[],"users":[]}
created2025-04-22 15:46:06
last_update2025-04-22 15:46:06
depth1
children1
last_payout2025-04-29 15:46:06
cashout_time1969-12-31 23:59:59
total_payout_value1.294 HBD
curator_payout_value1.295 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length171
author_reputation49,498,520,148,425
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,249,217
net_rshares7,370,836,873,738
author_curate_reward""
vote details (1)
@brianoflondon ·
$0.03
Building!<div><a href="https://engage.hivechain.app">![](https://i.imgur.com/XsrNmcl.png)</a></div>
πŸ‘  
properties (23)
authorbrianoflondon
permlinkre-1745386746320
categoryhive-110369
json_metadata{"app":"engage"}
created2025-04-23 05:39:06
last_update2025-04-23 05:39:06
depth2
children0
last_payout2025-04-30 05:39:06
cashout_time1969-12-31 23:59:59
total_payout_value0.016 HBD
curator_payout_value0.016 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length99
author_reputation759,674,214,959,955
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,264,731
net_rshares94,284,927,718
author_curate_reward""
vote details (1)
@nellybestie ·
$1.55
Keep up the good work πŸ’ͺ sir and a big thank you on engaging in our post by upvoting.

This project will surely be of benefit to everyone... welldone πŸ‘
πŸ‘  
properties (23)
authornellybestie
permlinkre-brianoflondon-2025420t1379721z
categoryhive-110369
json_metadata{"type":"comment","tags":["hive-110369","v4vapp","python","github","docker","leofinance","proofofbrain","mongodb","replicasets"],"app":"ecency/3.3.0-mobile","format":"markdown+html"}
created2025-04-20 12:07:09
last_update2025-04-20 12:07:09
depth1
children0
last_payout2025-04-27 12:07:09
cashout_time1969-12-31 23:59:59
total_payout_value0.774 HBD
curator_payout_value0.775 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length150
author_reputation12,737,339,403,933
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,205,042
net_rshares4,411,932,205,474
author_curate_reward""
vote details (1)
@revisesociology ·
Hi is the site down ATM....? I just tried pasting in my lightening address but can't figure out any way to enter an amount...? In Send currency? 

I know there are changes/ new integrations on the way...
properties (22)
authorrevisesociology
permlinkre-brianoflondon-swp86f
categoryhive-110369
json_metadata{"tags":["hive-110369"],"app":"peakd/2025.5.7","image":[],"users":[]}
created2025-05-23 05:20:42
last_update2025-05-23 05:20:42
depth1
children0
last_payout2025-05-30 05:20:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length203
author_reputation2,259,716,985,207,714
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,912,990
net_rshares0
@tht ·
$1.61
I voted for proposals. I hope it gets the votes it deserves.

VSC will greatly facilitate the hive ecosystem.
πŸ‘  
properties (23)
authortht
permlinksv0utb
categoryhive-110369
json_metadata{"app":"hiveblog/0.1"}
created2025-04-20 14:56:00
last_update2025-04-20 14:56:00
depth1
children0
last_payout2025-04-27 14:56:00
cashout_time1969-12-31 23:59:59
total_payout_value0.802 HBD
curator_payout_value0.803 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length109
author_reputation107,807,724,217,243
root_title"V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id142,207,521
net_rshares4,546,445,718,148
author_curate_reward""
vote details (1)