Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Vu Vo <[email protected]>
  • Loading branch information
vuvoth committed Jan 16, 2025
1 parent 1a54b5d commit f7a8bef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions contrib/bitcoin-mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ bitcoin-cli -regtest -rpcuser=user -rpcpassword=password -generate <number-block

More information in [developer.bitcoin.org -> testing](https://developer.bitcoin.org/examples/testing.html).

### Create BTC fork for testing

Check failure on line 67 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Trailing spaces

contrib/bitcoin-mock.md:67:32 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md009.md

In a few cases, we must create a BTC fork for testing. The create-fork.sh script helps you to do this. We support two functions:

Check failure on line 69 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Trailing spaces

contrib/bitcoin-mock.md:69:129 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md009.md

#### Create fork

Check failure on line 71 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Headings should be surrounded by blank lines

contrib/bitcoin-mock.md:71 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "#### Create fork"] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md022.md
Create a new fork start at the latest block in the snapshot data.

Check failure on line 72 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Trailing spaces

contrib/bitcoin-mock.md:72:66 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md009.md
```sh

Check failure on line 73 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Fenced code blocks should be surrounded by blank lines

contrib/bitcoin-mock.md:73 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```sh"] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md031.md
./create-fork.sh create <fork-name> <number-block>
```

Check failure on line 75 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Fenced code blocks should be surrounded by blank lines

contrib/bitcoin-mock.md:75 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md031.md
### Extract fork

Check failure on line 76 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Trailing spaces

contrib/bitcoin-mock.md:76:17 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md009.md

Check failure on line 76 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Headings should be surrounded by blank lines

contrib/bitcoin-mock.md:76 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Above] [Context: "### Extract fork"] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md022.md

Check failure on line 76 in contrib/bitcoin-mock.md

View workflow job for this annotation

GitHub Actions / markdown-lint

Headings should be surrounded by blank lines

contrib/bitcoin-mock.md:76 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Extract fork"] https://github.com/DavidAnson/markdownlint/blob/v0.37.2/doc/md022.md
We can extract any block between a specific range. This command below returns the list of block headers in this range.

```sh
./create-fork.sh extract <fork-name> <start> <end>
```

### Reference

- [Running Bitcoind with ZMQ](https://bitcoindev.network/accessing-bitcoins-zeromq-interface/)
Expand Down
6 changes: 3 additions & 3 deletions contrib/create-fork.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash


# Create fork
function createFork() {
forkName="./fork-"$1
forkLength=$2
echo $forkName

cp -rf ./bitcoind-snapshot/ $forkName
BITCOIND_DATA=$forkName docker-compose up -d
docker exec -it bitcoind-node bitcoin-cli -generate $forkLength
docker-compose down
}

# Extract block between range
function extractFork() {
forkName="./fork-"$1
start=$2
end=$3

echo $forkName
BITCOIND_DATA=$forkName docker-compose up -d
docker exec -it bitcoind-node bitcoin-cli -generate $forkLength

Expand Down

0 comments on commit f7a8bef

Please sign in to comment.