Skip to content

Instantly share code, notes, and snippets.

@cryptagoras
Created January 31, 2021 22:55
Show Gist options
  • Save cryptagoras/45b2839a1f662c769b94b868ce222d3d to your computer and use it in GitHub Desktop.
Save cryptagoras/45b2839a1f662c769b94b868ce222d3d to your computer and use it in GitHub Desktop.
Generating the asmap file for Bitcoin 0.20+ ASN-based bucketing of peers

Thanks to Gleb Naumenko (@naumenkogs) via https://blog.bitmex.com/call-to-action-testing-and-improving-asmap/

(fit the commands for your case, probably won't work for everybody)

1. Install Rust & compile deps for Bitcoin core

2. Build bitcoin-asmap tool using sipa's branch off Bitcoin Core

mkdir ~/asmap-work
git clone https://github.com/sipa/bitcoin -b 202004_asmap_tool && cd bitcoin
./autogen.sh
./configure --disable-shared --without-gui --disable-wallet
make
sudo cp src/bitcoin-asmap /usr/bin/.

3. Build asmap-rs that downloads all raw needed data and generates the ASN bottleneck

cd ~/asmap-work
git clone https://github.com/rrybarczyk/asmap-rs && cd asmap-rs
cargo run --release download && mkdir bottleneck
cargo run --release find-bottleneck -d dump -o bottleneck

(WARNING: cargo run --release download will download several GBs of data)

4. Encode the ASN bottleneck to the final form using sipa's bitcoin-asmap tool

bitcoin-asmap encode ~/asmap-work/asmap.dat < bottleneck/bottleneck.*.txt

5. Add option to bitcoin.conf

asmap=/path/to/asmap-work/asmap.dat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment