Shell script to fetch Masternodes and Evonodes current voting on a certain proposal

qwizzie

Well-known member
Step 1 : Create a new text file
Step 2 : Choose which code text to use, super majority ruling on budget proposals or simple majority ruling on DCG decision proposals

Super Majority ruling on budget proposals (yes-no votes compared to total number of yes+no+abstain)
Example : Dash Core Group Operations July

Bash:
#!/bin/bash

# Define color codes

ORANGE='\033[0;33m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color


# Use dash-cli if working, else assume a dashmate is to be used.

if dash-cli -version >/dev/null 2>&1;then

    output=$(dash-cli gobject getcurrentvotes 6c4e0f9244f25616128f198ac37ce3daa45bd04055965a54318da8bcc556eb50)

else

    output=$(dashmate core cli "gobject getcurrentvotes 6c4e0f9244f25616128f198ac37ce3daa45bd04055965a54318da8bcc556eb50")

fi

# Show the output on screen

echo -e "${ORANGE}Output:${NC}\n${ORANGE}$output${NC}"
echo
echo -e "${ORANGE}Evonodes have a multiplier of 4 on their votes, this script does not take that into account during counting of Evonodes votes.${NC}"
echo -e "${ORANGE}Having a multiplier of 4 on votes, does not change the super vote majority percentage for Evonodes.${NC}"
echo

# Initialize counters

count_masternodes=0
count_yes_masternodes=0
count_no_masternodes=0
count_abstain_masternodes=0
count_evonodes=0
count_yes_evonodes=0
count_no_evonodes=0
count_abstain_evonodes=0

# Process each line of the content

# Assuming each line contains a key-value pair separated by colon ':'

while IFS=':",' read -r a b c d e f g h i j k l; do

    # $g is yes, no, abstain

    # $h is funding, delete, etc

    # $i is 1 or 4.

    # Update the counters

    [[ $h$i == "funding1" ]] && ((count_masternodes++))

    [[ $g$h$i == "yesfunding1" ]] && ((count_yes_masternodes++))

    [[ $g$h$i == "nofunding1" ]] && ((count_no_masternodes++))

    [[ $g$h$i == "abstainfunding1" ]] && ((count_abstain_masternodes++))

    [[ $h$i == "funding4" ]] && ((count_evonodes++))

    [[ $g$h$i == "yesfunding4" ]] && ((count_yes_evonodes++))

    [[ $g$h$i == "nofunding4" ]] && ((count_no_evonodes++))

    [[ $g$h$i == "abstainfunding4" ]] && ((count_abstain_evonodes++))

done <<< "$output"

# Adjust the total counts to subtract no votes

net_yes_mn=$((count_yes_masternodes-count_no_masternodes))

percent_yes_mn=$(bc<<<"scale=2;$net_yes_mn/$count_masternodes*100")

# Calculate percentages

net_yes_emn=$((count_yes_evonodes-count_no_evonodes))

percent_yes_emn=$(printf '%.2f' $(bc<<<"scale=4;$net_yes_emn/$count_evonodes*100"))

# Print the counts

echo -e "${CYAN}Total count of voted Masternodes : $count_masternodes${NC}"
echo
echo -e " - ${GREEN}Yes: $count_yes_masternodes${NC}"
echo -e " - ${GREEN}No: $count_no_masternodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_masternodes${NC}"
echo -e " - ${GREEN}Net Yes / super vote majority : $net_yes_mn ($percent_yes_mn%)${NC}"

echo

echo -e "${CYAN}Total count of voted Evonodes : $count_evonodes${NC}"
echo
echo -e " - ${GREEN}Yes: $count_yes_evonodes${NC}"
echo -e " - ${GREEN}No: $count_no_evonodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_evonodes${NC}"
echo -e " - ${GREEN}Net Yes / super vote majority : $net_yes_emn ($percent_yes_emn%)${NC}"
echo
Credits to xkcd, see edit.

Knipsel.JPG


Simple Majority ruling on DCG decision proposals (yes votes compared to total number of yes+no)
Example : DCG Evo Accelerated Release Schedule

Bash:
#!/bin/bash

# Define color codes
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# Use dash-cli if working, else assume dashmate is to be used
if dash-cli -version >/dev/null 2>&1; then
    output=$(dash-cli gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90)
else
    output=$(dashmate core cli "gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90")
fi

# Show the output on screen
echo -e "${ORANGE}Output:${NC}\n${ORANGE}$output${NC}"
echo
echo -e "${ORANGE}Evonodes have a multiplier of 4 on their votes, this script does not take that into account during counting of Evonodes votes.${NC}"
echo -e "${ORANGE}Having a multiplier of 4 on votes, does not change the simple vote majority percentage for Evonodes.${NC}"
echo

# Initialize counters
count_masternodes=0
count_yes_masternodes=0
count_no_masternodes=0
count_abstain_masternodes=0
count_evonodes=0
count_yes_evonodes=0
count_no_evonodes=0
count_abstain_evonodes=0

# Process each line of the content
# Assuming each line contains a key-value pair separated by colon ':'
while IFS=':",' read -r a b c d e f g h i j k l; do
    # $g is yes, no, abstain
    # $h is funding, delete, etc
    # $i is 1 or 4.

    # Check update the counters
    [[ $h$i == "funding1" ]] && ((count_masternodes++))
    [[ $g$h$i == "yesfunding1" ]] && ((count_yes_masternodes++))
    [[ $g$h$i == "nofunding1" ]] && ((count_no_masternodes++))
    [[ $g$h$i == "abstainfunding1" ]] && ((count_abstain_masternodes++))
    [[ $h$i == "funding4" ]] && ((count_evonodes++))
    [[ $g$h$i == "yesfunding4" ]] && ((count_yes_evonodes++))
    [[ $g$h$i == "nofunding4" ]] && ((count_no_evonodes++))
    [[ $g$h$i == "abstainfunding4" ]] && ((count_abstain_evonodes++))
done <<< "$output"

# Adjust the total counts to subtract abstain votes
actual_count_masternodes=$((count_masternodes - count_abstain_masternodes))
actual_count_evonodes=$((count_evonodes - count_abstain_evonodes))

# Calculate percentages
percent_yes_mn=$(printf '%.2f' $(bc<<<"scale=4;$count_yes_masternodes/$actual_count_masternodes*100"))
percent_yes_emn=$(printf '%.2f' $(bc<<<"scale=4;$count_yes_evonodes/$actual_count_evonodes*100"))

# Print the counts
echo -e "${CYAN}Total count of voted Masternodes : $actual_count_masternodes${NC}"
echo
echo -e " - ${GREEN}Yes: $count_yes_masternodes (simple vote majority : $percent_yes_mn%)${NC}"
echo -e " - ${GREEN}No: $count_no_masternodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_masternodes${NC}"

echo

echo -e "${CYAN}Total count of voted Evonodes : $actual_count_evonodes${NC}"
echo
echo -e " - ${GREEN}Yes: $count_yes_evonodes (simple vote majority : $percent_yes_emn%)${NC}"
echo -e " - ${GREEN}No: $count_no_evonodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_evonodes${NC}"
echo
Credits to xkcd, see edit

Knipsel.JPG


Step 3 : Save as votes.txt
Step 4 : Rename to votes.sh
Step 5 : Transfer this file to your Ubuntu home directory (i use WinSCP for this)
Step 6 : chmod +x votes.sh
Step 7 : dos2unix votes.sh
(if dos2unix not installed, then install through sudo apt-get install dos2unix but on my Ubuntu system it was already installed)
Step 8 : ./votes.sh

'./votes.sh' command can now be used to fetch the votes (yes, no, abstain) of both Masternodes and Evonodes on a specific proposal

Use dashmate core cli "gobject list all" (dashmate users) or dash-cli gobject list all (other users) to see the proposal hashes of all hashes of active proposals in the budget sytem and replace the hash in '# Use dash-cli if working, else assume a dashmate is to be used' in above shell script, if you want to check this on a different proposal.

Edit : credits to xkcd, who provided me with a better version of the code (already integrated on this post), one that is also compatible to both dashmate users and other users and does not need logging.
 
Last edited:
I have updated the code to make it more better.


Bash:
#!/bin/bash


# Use dash-cli if working, else assume a dashmate is to be used.
if dash-cli -version >/dev/null 2>&1;then
    output=$(dash-cli gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90)
else
    output=$(dashmate core cli "gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90")
fi



# Show the output on screen
echo "Output:"
echo "$output"
echo

# Initialize counters
count_masternodes=0
count_evonodes=0
count_yes_masternodes=0
count_no_masternodes=0
count_abstain_masternodes=0
count_yes_evonodes=0
count_no_evonodes=0
count_abstain_evonodes=0

# Process each line of the content
# Assuming each line contains a key-value pair separated by colon ':'
while IFS= read -r line; do
    # Extract the value part from each line
    value=$(echo "$line" | awk -F'"' '{print $4}')

    # Check if the value contains "funding:1" or "funding:4"
    [[ $value == *"funding:1"* ]] && ((count_masternodes++))
    [[ $value == *"yes:funding:1"* ]] && ((count_yes_masternodes++))
    [[ $value == *"no:funding:1"* ]] && ((count_no_masternodes++))
    [[ $value == *"abstain:funding:1"* ]] && ((count_abstain_masternodes++))
    [[ $value == *"funding:4"* ]] && ((count_evonodes++))
    [[ $value == *"yes:funding:4"* ]] && ((count_yes_evonodes++))
    [[ $value == *"no:funding:4"* ]] && ((count_no_evonodes++))
    [[ $value == *"abstain:funding:4"* ]] && ((count_abstain_evonodes++))
done <<< "$output"
 
@xkcd Thank you.

No need for logging i see. Nice.
Bash:
 ..
also nice for code samples on this forum. Will use that from now on.

Is it okay if i replace the code from my first comment with the code from your comment and give you credits (not Platform credits ;)) in my first post ? Your code sample is missing the '# Print the counts' section of code by the way.
 
Last edited:
Is it okay if i replace the code from my first comment with the code from your comment and give you credits (not Platform credits ;)) in my first post ? Your code sample is missing the '# Print the counts' section of code by the way.


Yep, you can update your original post with the new code, you are right, I missed the print out section, I did not change it. Also, the section initialising the counters is not strictly required, bash will set an uninitialised variable to zero on the first use, so you get the same results, but in fewer lines.
 
and just for fun, I wrote this version where I removed the awk and used bash to tokenise the string on our separators, so we get each item we care about cleanly in 3 different variables. It should be faster and some systems may not have awk, so this is better.


Bash:
#!/bin/bash


# Use dash-cli if working, else assume a dashmate is to be used.
if dash-cli -version >/dev/null 2>&1;then
    output=$(dash-cli gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90)
else
    output=$(dashmate core cli "gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90")
fi



# Show the output on screen
echo "Output:"
echo "$output"
echo


# Process each line of the content
# Assuming each line contains a key-value pair separated by colon ':'
while IFS=':",' read -r a b c d e f g h i j k l; do
    # $g is yes, no, abstain
    # $h is funding, delete, etc
    # $i is 1 or 4.

    # Check update the counters
    [[ $h$i == "funding1" ]] && ((count_masternodes++))
    [[ $g$h$i == "yesfunding1" ]] && ((count_yes_masternodes++))
    [[ $g$h$i == "nofunding1" ]] && ((count_no_masternodes++))
    [[ $g$h$i == "abstainfunding1" ]] && ((count_abstain_masternodes++))
    [[ $h$i == "funding4" ]] && ((count_evonodes++))
    [[ $g$h$i == "yesfunding4" ]] && ((count_yes_evonodes++))
    [[ $g$h$i == "nofunding4" ]] && ((count_no_evonodes++))
    [[ $g$h$i == "abstainfunding4" ]] && ((count_abstain_evonodes++))
done <<< "$output"

# Print the counts
echo "Total count of voted Masternodes : $count_masternodes"
echo " - Yes: $count_yes_masternodes"
echo " - No: $count_no_masternodes"
echo " - Abstain: $count_abstain_masternodes"

echo "Total count of voted Evonodes : $count_evonodes"
echo " - Yes: $count_yes_evonodes"
echo " - No: $count_no_evonodes"
echo " - Abstain: $count_abstain_evonodes"
 
Another update to this script. I am now determining the net yes votes and then taking the percentage of those compared to all that voted, let me know if this is helpful.


Bash:
#!/bin/bash


# Use dash-cli if working, else assume a dashmate is to be used.
if dash-cli -version >/dev/null 2>&1;then
    output=$(dash-cli gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90)
else
    output=$(dashmate core cli "gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90")
fi



# Show the output on screen
echo -e "Output:\n$output\n"


# Process each line of the content
# Assuming each line contains a key-value pair separated by colon ':'
while IFS=':",' read -r a b c d e f g h i j k l; do
    # $g is yes, no, abstain
    # $h is funding, delete, etc
    # $i is 1 or 4.

    # Update the counters
    [[ $h$i == "funding1" ]] && ((count_masternodes++))
    [[ $g$h$i == "yesfunding1" ]] && ((count_yes_masternodes++))
    [[ $g$h$i == "nofunding1" ]] && ((count_no_masternodes++))
    [[ $g$h$i == "abstainfunding1" ]] && ((count_abstain_masternodes++))
    [[ $h$i == "funding4" ]] && ((count_evonodes++))
    [[ $g$h$i == "yesfunding4" ]] && ((count_yes_evonodes++))
    [[ $g$h$i == "nofunding4" ]] && ((count_no_evonodes++))
    [[ $g$h$i == "abstainfunding4" ]] && ((count_abstain_evonodes++))
done <<< "$output"

net_yes_mn=$((count_yes_masternodes-count_no_masternodes))
percent_yes_mn=$(bc<<<"scale=2;$net_yes_mn/$count_masternodes*100")

net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(bc<<<"scale=2;$net_yes_emn/$count_evonodes*100")


# Print the counts
echo "Total count of voted Masternodes : $count_masternodes"
echo " - Yes: $count_yes_masternodes"
echo " - No: $count_no_masternodes"
echo " - Abstain: $count_abstain_masternodes"
echo " - Net Yes: $net_yes_mn ($percent_yes_mn%)"

echo "Total count of voted Evonodes : $count_evonodes"
echo " - Yes: $count_yes_evonodes"
echo " - No: $count_no_evonodes"
echo " - Abstain: $count_abstain_evonodes"
echo " - Net Yes: $net_yes_emn ($percent_yes_emn%)"

Screenshot 2024-06-14 134900.png
 
@xkcd

Thanks.

Integrated, added a few spaces and colorfied the whole thing for prettyness. See first post.
Weird how orange looks very much like yellow on my oled monitor screen, but i like the color.
 
Last edited:
@xkcd See Discord

To calculate simple vote majority (just yes votes compared to total number of voted Evonodes) for the specific DCG decision proposal 'Evo Accelerated Release Schedule') with its 'special' rules' :

Bash:
#!/bin/bash

# Define color codes
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# Use dash-cli if working, else assume dashmate is to be used
if dash-cli -version >/dev/null 2>&1; then
    output=$(dash-cli gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90)
else
    output=$(dashmate core cli "gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90")
fi

# Show the output on screen
echo -e "${ORANGE}Output:${NC}"
echo -e "${ORANGE}$output${NC}"
echo

# Initialize counters
count_masternodes=0
count_yes_masternodes=0
count_no_masternodes=0
count_abstain_masternodes=0
count_evonodes=0
count_yes_evonodes=0
count_no_evonodes=0
count_abstain_evonodes=0

# Process each line of the content
# Assuming each line contains a key-value pair separated by colon ':'
while IFS=':",' read -r a b c d e f g h i j k l; do
    # $g is yes, no, abstain
    # $h is funding, delete, etc
    # $i is 1 or 4.

    # Check update the counters
    [[ $h$i == "funding1" ]] && ((count_masternodes++))
    [[ $g$h$i == "yesfunding1" ]] && ((count_yes_masternodes++))
    [[ $g$h$i == "nofunding1" ]] && ((count_no_masternodes++))
    [[ $g$h$i == "abstainfunding1" ]] && ((count_abstain_masternodes++))
    [[ $h$i == "funding4" ]] && ((count_evonodes++))
    [[ $g$h$i == "yesfunding4" ]] && ((count_yes_evonodes++))
    [[ $g$h$i == "nofunding4" ]] && ((count_no_evonodes++))
    [[ $g$h$i == "abstainfunding4" ]] && ((count_abstain_evonodes++))
done <<< "$output"

net_yes_mn=$((count_yes_masternodes))
percent_yes_mn=$(bc<<<"scale=2;$net_yes_mn/$count_masternodes*100")

net_yes_emn=$((count_yes_evonodes))
percent_yes_emn=$(bc<<<"scale=2;$net_yes_emn/$count_evonodes*100")

# Print the counts
echo -e "${CYAN}Total count of voted Masternodes : $count_masternodes${NC}"
echo

echo -e " - ${GREEN}Yes: $count_yes_masternodes(simple vote majority:$percent_yes_mn%)${NC}"
echo -e " - ${GREEN}No: $count_no_masternodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_masternodes${NC}"

echo

echo -e "${CYAN}Total count of voted Evonodes : $count_evonodes${NC}"
echo
echo -e " - ${GREEN}Yes: $count_yes_evonodes (simple vote majority:$percent_yes_emn%)${NC}"
echo -e " - ${GREEN}No: $count_no_evonodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_evonodes${NC}"

Knipsel.JPG


I am not sure i understand QE mentioned 79%, script with simple vote majority calculate 66%

Knipsel1.JPG



Can you please verify the changes i made in the script in this specific post / comment. By the way : first post still shows your unchanged super majority / yes-no code, i think i will leave that in there for normal budget proposals.

Edit 1 : i suspect it has to do with the abstains getting counted into the 'total count of voted Evonodes' due to [[ $h$i == "funding4" ]] && ((count_evonodes++)). I guess QE only count the yes and no votes into the voting Evonodes, not the abstain votes.

We could bring the yes support percentage more inline with QE, by changing :

echo -e "${CYAN}Total count of voted Masternodes : $count_masternodes${NC}"
echo -e "${CYAN}Total count of voted Evonodes : $count_evonodes${NC}"

To

echo -e "${CYAN}Total count of voted Masternodes : $count_masternodes-$count_abstain_masternodes${NC}"
echo -e "${CYAN}Total count of voted Evonodes : $count_evonodes-$count_abstain_evonodes${NC}"

I still find it a bit weird that those Evonodes that specifically voted the abstain option, do not get added to the total number of voting Evonodes this way, but then again this whole decision proposal is a bit weird.

Edit 2 :

Bash:
# Adjust the total counts to subtract abstain votes
actual_count_masternodes=$((count_masternodes - count_abstain_masternodes))
actual_count_evonodes=$((count_evonodes - count_abstain_evonodes))

# Calculate percentages
percent_yes_mn=$(bc<<<"scale=2;$count_yes_masternodes/$actual_count_masternodes*100")
percent_yes_emn=$(bc<<<"scale=2;$count_yes_evonodes/$actual_count_evonodes*100")

# Print the counts
echo -e " - ${GREEN}Yes: $count_yes_masternodes (simple vote majority : $percent_yes_mn%)${NC}"
echo -e " - ${GREEN}Yes: $count_yes_evonodes (simple vote majority : $percent_yes_emn%)${NC}"

Knipsel.JPG
 
Last edited:
Latest code sample for just calculating simple vote majority, with the total of voted masternodes / evonodes consisting of only yes+no votes (only to be used on the specific DCG 'Evo Accelerated Release Schedule' decision proposal).
You can find this code also on the first post with clear instructions (step 1-8).

Bash:
#!/bin/bash

# Define color codes
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# Use dash-cli if working, else assume dashmate is to be used
if dash-cli -version >/dev/null 2>&1; then
    output=$(dash-cli gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90)
else
    output=$(dashmate core cli "gobject getcurrentvotes 615d8a6d4edafdcee65ff16ab9c7bacef6f5d1b1096466c0957f0441287dcc90")
fi

# Show the output on screen
echo -e "${ORANGE}Output:${NC}\n${ORANGE}$output${NC}"
echo
echo -e "${ORANGE}Evonodes have a multiplier of 4 on their votes, this script does not take that into account during counting of Evonodes votes.${NC}"
echo -e "${ORANGE}Having a multiplier of 4 on votes, does not change the simple vote majority percentage for Evonodes.${NC}"
echo

# Initialize counters
count_masternodes=0
count_yes_masternodes=0
count_no_masternodes=0
count_abstain_masternodes=0
count_evonodes=0
count_yes_evonodes=0
count_no_evonodes=0
count_abstain_evonodes=0

# Process each line of the content
# Assuming each line contains a key-value pair separated by colon ':'
while IFS=':",' read -r a b c d e f g h i j k l; do
    # $g is yes, no, abstain
    # $h is funding, delete, etc
    # $i is 1 or 4.

    # Check update the counters
    [[ $h$i == "funding1" ]] && ((count_masternodes++))
    [[ $g$h$i == "yesfunding1" ]] && ((count_yes_masternodes++))
    [[ $g$h$i == "nofunding1" ]] && ((count_no_masternodes++))
    [[ $g$h$i == "abstainfunding1" ]] && ((count_abstain_masternodes++))
    [[ $h$i == "funding4" ]] && ((count_evonodes++))
    [[ $g$h$i == "yesfunding4" ]] && ((count_yes_evonodes++))
    [[ $g$h$i == "nofunding4" ]] && ((count_no_evonodes++))
    [[ $g$h$i == "abstainfunding4" ]] && ((count_abstain_evonodes++))
done <<< "$output"

# Adjust the total counts to subtract abstain votes
actual_count_masternodes=$((count_masternodes - count_abstain_masternodes))
actual_count_evonodes=$((count_evonodes - count_abstain_evonodes))

# Calculate percentages
percent_yes_mn=$(printf '%.2f' $(bc<<<"scale=4;$count_yes_masternodes/$actual_count_masternodes*100"))
percent_yes_emn=$(printf '%.2f' $(bc<<<"scale=4;$count_yes_evonodes/$actual_count_evonodes*100"))

# Print the counts
echo -e "${CYAN}Total count of voted Masternodes : $actual_count_masternodes${NC}"
echo
echo -e " - ${GREEN}Yes: $count_yes_masternodes (simple vote majority : $percent_yes_mn%)${NC}"
echo -e " - ${GREEN}No: $count_no_masternodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_masternodes${NC}"

echo

echo -e "${CYAN}Total count of voted Evonodes : $actual_count_evonodes${NC}"
echo
echo -e " - ${GREEN}Yes: $count_yes_evonodes (simple vote majority : $percent_yes_emn%)${NC}"
echo -e " - ${GREEN}No: $count_no_evonodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_evonodes${NC}"
echo

DCG decision proposal 'Evo Accelerated Release Schedule' currently at 65.95% support from Evonodes (a few more Evonode owners voted no recently, see post 1). Could get interesting coming days untill end of voting period (6 days from now).

download.jpg
 
Last edited:
@xkcd I totally forgot to multiply the yes,no,abstain votes for Evonodes by 4 in the code.

x4
Knipsel.JPG


versus :

x1
Knipsel.JPG



Adjusted the code in the first post, should be correct now.
 
Last edited:
The 4x multiple is not required, unless we are adding votes to the MN votes.
Some suggestions, change

echo -e "${ORANGE}Output:${NC}"
echo -e "${ORANGE}$output${NC}"
echo


to

echo -e "${ORANGE}Output:${NC}\n${ORANGE}$output${NC}"


Saves two lines and change,

percent_yes_mn=$(bc<<<"scale=2;$count_yes_masternodes/$actual_count_masternodes*100")
percent_yes_emn=$(bc<<<"scale=2;$count_yes_evonodes/$actual_count_evonodes*100")

to

percent_yes_mn=$(printf '%.2f' $(bc<<<"scale=4;$count_yes_masternodes/$actual_count_masternodes*100"))
percent_yes_emn=$(printf '%.2f' $(bc<<<"scale=4;$count_yes_evonodes/$actual_count_evonodes*100"))

Gives us two decimal places of precision, there is a quirk in bc that I cannot solve otherwise.
 
@xkcd

All Done and reverted back changes i did before, thinking 4x multiple was needed.

By the way, with regards to the code for Super Majority ruling on budget proposals (see first post),
does below need changing as well, to get two decimal places of precision ?

Bash:
# Calculate percentages
net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(bc<<<"scale=2;$net_yes_emn/$count_evonodes*100")
 
Last edited:
@xkcd

All Done and reverted back changes i did before, thinking 4x multiple was needed.

By the way, with regards to the code for Super Majority ruling on budget proposals (see first post),
does below need changing as well, to get two decimal places of precision ?

Bash:
# Calculate percentages
net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(bc<<<"scale=2;$net_yes_emn/$count_evonodes*100")


Yeah, the variable percent_yes_emn needs what I posted above to show the correct level of precision.

Here is the latest tally.

Screenshot 2024-06-16 010344.png
 
@xkcd

So what is the correct change for that slightly different code piece that is more related to budget proposals (super majority), not decision proposals (simple majority) :

From :

# Calculate percentages
net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(bc<<<"scale=2;$net_yes_emn/$count_evonodes*100")

To :

net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(printf '%.2f' $(bc<<<"scale=4;$net_yes_emn/$count_evonodes*100"))

Is this correct ?
 
Last edited:
@xkcd

So what is the correct change for that slightly different code piece that is more related to budget proposals (super majority), not decision proposals (simple majority) :

From :

# Calculate percentages
net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(bc<<<"scale=2;$net_yes_emn/$count_evonodes*100")

To :

??


The code in this post https://www.dash.org/forum/index.ph...oting-on-a-certain-proposal.54991/post-238678 looks perfect to me, the percentages have two decimal places of precision. The code can be shortened by removing the several lines that initialise vars to zero, since that is implied when you do the first increment on them.
 
@xkcd
I was not talking about that post, i was talking about this post (see first post) with regards to calculate percentages :

Super Majority ruling on budget proposals (yes-no votes compared to total number of yes+no+abstain)
Example : Dash Core Group Operations July

Bash:
#!/bin/bash

# Define color codes
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# Use dash-cli if working, else assume a dashmate is to be used.
if dash-cli -version >/dev/null 2>&1;then
    output=$(dash-cli gobject getcurrentvotes 6c4e0f9244f25616128f198ac37ce3daa45bd04055965a54318da8bcc556eb50)
else
    output=$(dashmate core cli "gobject getcurrentvotes 6c4e0f9244f25616128f198ac37ce3daa45bd04055965a54318da8bcc556eb50")
fi

# Show the output on screen
echo -e "${ORANGE}Output:${NC}\n${ORANGE}$output${NC}"

# Initialize counters
count_masternodes=0
count_yes_masternodes=0
count_no_masternodes=0
count_abstain_masternodes=0
count_evonodes=0
count_yes_evonodes=0
count_no_evonodes=0
count_abstain_evonodes=0

# Process each line of the content
# Assuming each line contains a key-value pair separated by colon ':'
while IFS=':",' read -r a b c d e f g h i j k l; do
    # $g is yes, no, abstain
    # $h is funding, delete, etc
    # $i is 1 or 4.

    # Update the counters
    [[ $h$i == "funding1" ]] && ((count_masternodes++))
    [[ $g$h$i == "yesfunding1" ]] && ((count_yes_masternodes++))
    [[ $g$h$i == "nofunding1" ]] && ((count_no_masternodes++))
    [[ $g$h$i == "abstainfunding1" ]] && ((count_abstain_masternodes++))
    [[ $h$i == "funding4" ]] && ((count_evonodes++))
    [[ $g$h$i == "yesfunding4" ]] && ((count_yes_evonodes++))
    [[ $g$h$i == "nofunding4" ]] && ((count_no_evonodes++))
    [[ $g$h$i == "abstainfunding4" ]] && ((count_abstain_evonodes++))
done <<< "$output"

# Adjust the total counts to subtract no votes
net_yes_mn=$((count_yes_masternodes-count_no_masternodes))
percent_yes_mn=$(bc<<<"scale=2;$net_yes_mn/$count_masternodes*100")

# Calculate percentages
net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(bc<<<"scale=2;$net_yes_emn/$count_evonodes*100")

# Print the counts
echo -e "${CYAN}Total count of voted Masternodes : $count_masternodes${NC}"
echo -e " - ${GREEN}Yes: $count_yes_masternodes${NC}"
echo -e " - ${GREEN}No: $count_no_masternodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_masternodes${NC}"
echo -e " - ${GREEN}Net Yes: $net_yes_mn ($percent_yes_mn%)${NC}"

echo -e "${CYAN}Total count of voted Evonodes : $count_evonodes${NC}"
echo -e " - ${GREEN}Yes: $count_yes_evonodes${NC}"
echo -e " - ${GREEN}No: $count_no_evonodes${NC}"
echo -e " - ${GREEN}Abstain: $count_abstain_evonodes${NC}"
echo -e " - ${GREEN}Net Yes: $net_yes_emn ($percent_yes_emn%)${NC}"

I assume the #calculate percentages needs to be changed here as well, maybe to :

Bash:
net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(printf '%.2f' $(bc<<<"scale=4;$net_yes_emn/$count_evonodes*100"))

** i am providing users a choice now on first post, between using code to fetch votes for a budget proposal and code to fetch votes for a DCG decision proposal.**
 
Last edited:
I assume the #calculate percentages needs to be changed here as well, maybe to :

Bash:
net_yes_emn=$((count_yes_evonodes-count_no_evonodes))
percent_yes_emn=$(printf '%.2f' $(bc<<<"scale=4;$net_yes_emn/$count_evonodes*100"))

* i am providing users a choice now on first post, between using code to fetch votes for a budget proposal and code to fetch votes for a DCG decision proposal.

Yes! You are right, same change there.
 
Updated code yesterday (both for super majority ruling on normal budget proposals and simple majority ruling on DCG decision proposal(s) to include following echo's below raw votes :

super majority
Bash:
echo -e "${ORANGE}Output:${NC}\n${ORANGE}$output${NC}"
echo
echo -e "${ORANGE}Evonodes have a multiplier of 4 on their votes, this script does not take that into account during counting of Evonodes votes.${NC}"
echo -e "${ORANGE}Having a multiplier of 4 on votes, does not change the super vote majority percentage for Evonodes.${NC}"
echo
+ slightly changed the echo in # Print the counts

simple majority
Bash:
# Show the output on screen
echo -e "${ORANGE}Output:${NC}\n${ORANGE}$output${NC}"
echo
echo -e "${ORANGE}Evonodes have a multiplier of 4 on their votes, this script does not take that into account during counting of Evonodes votes.${NC}"
echo -e "${ORANGE}Having a multiplier of 4 on votes, does not change the simple vote majority percentage for Evonodes.${NC}"
echo

See post 1 screenshots (just know the screenshots still have Evonode votes instead of Evonodes votes, i was too lazy to make new screenshots for that)
 
Last edited:
Back
Top