teambean / BeanCash

Bean Cash, Digital Currency re-branded from BitBean (Main Production Branch)
http://www.beancash.org
MIT License
13 stars 18 forks source link

DNS seeds do not provide good nodes. #3

Open MatthewLM opened 6 years ago

MatthewLM commented 6 years ago

When starting a fresh wallet, it is not possible to connect to the network and start synchronisation because the DNS seeds provide bad nodes. This is a major concern to all new users.

Multiple dynamic DNS seeders should be used. My advice is to adapt sipa's bitcoin seeder to Bean Cash: https://github.com/sipa/bitcoin-seeder

In the short term, the DNS servers can at least provide some reasonable node addresses.

LouisCyfer commented 6 years ago

I also ran into the issue of beeing unable to connect to more than 2 or 3 active nodes for syching the blockchain so I wrote myself a routine that is capable of reading a txt file (addNodes.txt) placed in the same folder with the starting script (run.sh).

Now my GUI has 16 active connections every time I start it.

It then scans the following beancash explorer websites for active nodes every start:

and finally puts all nodes which are no duplicates into .data/Beancash.conf

In my case my folder looks like: ./ (beancash root folder) ./.data (beancash blockchain data folder) ./run.sh (for starting the main wallet gui) ./addNodes.txt ./Beancash-qt ./Beancashd

addNotes.txt is totally optional for my script to work (also can be empty or missing) and looks like:

# new nodes
addnode=5.104.108.71
addnode=206.189.17.21
addnode=89.163.152.130
addnode=69.197.184.34
addnode=89.163.152.147
addnode=144.76.24.250
addnode=46.4.113.143
addnode=51.254.36.84
addnode=2001:41d0:8:6952::
addnode=207.126.164.32
addnode=159.203.3.121
addnode=107.191.44.183

run.sh looks like:

cd $(dirname "$0")
wDir=$(pwd)

dataDir="dataDir="$wDir/.data"
allNodes=()
echo "building node list .."

if [ -f "addNodes.txt" ]; then

    echo -e "\taddNodes.txt found, parsing .."

    allNodes+=($(cat "addNodes.txt" | grep "addnode="))
    echo -e "\t${#allNodes[@]} items added"
fi

echo -e "\n\tgetting a fresh node list from https://chainz.cryptoid.info/bean"

nodeSrc=$(curl -s -L "https://chainz.cryptoid.info/bean/api.dws?q=nodes")
nodes=($(jq -n "$nodeSrc" | jq '.[] | select(.subver=="'"/Bean Core:$vNumber/"'")' | jq -r ".nodes[]")) # jq -r '{[.subver]}')
idx=0

for entry in "${nodes[@]}"; do
    nodes[$idx]="addnode=$entry"

    allNodes+=("${nodes[$idx]}")
    let idx++
done
echo -e "\t${#nodes[@]} node(s) found\n"

echo -e "\tgetting a fresh node list from https://www.coinexchange.io/network/peers/BITB"
fOutput+="\n\n# nodes added from https://www.coinexchange.io/network/peers/BITB"

nodes=($(curl -s -L "https://www.coinexchange.io/network/peers/BITB" | grep "addnode=" | tr -d "<br>" | tr -d " "))
idx=0

for entry in "${nodes[@]}"; do
    allNodes+=("${nodes[$idx]}")
    let idx++
done
echo -e "\t${#nodes[@]} node(s) found"

itemCount=${#allNodes[@]}
allNodes=($(printf "%s\n" "${allNodes[@]}" | sort -u))
echo -e "\n\t\t${#allNodes[@]} entries found (removed "$(expr $itemCount - ${#allNodes[@]})" duplicates)"

echo -e "\twriting ${#allNodes[@]} entries to '$dataDir/Beancash.conf' ..."
printf "%s\n" "${allNodes[@]}" > "$dataDir/Beancash.conf"

./Beancash-qt -datadir=$wDir/.data -sprout=1 -stake=1 -dns -timeout=200 -printtoconsole

hope this helps