Skip to content

Instantly share code, notes, and snippets.

View EggPool's full-sized avatar

EggPool EggPool

  • EggPool
View GitHub Profile
@EggPool
EggPool / gist:98ffb4db24c3b8b3309f71ad99fe4782
Created February 18, 2018 10:31
Python Ascii85 Variant, Safe encoding
"""Python implementation of an Ascii85 encoding
See https://en.wikipedia.org/wiki/Ascii85
Uses classic Ascii85 Algorithm, but a custom alphabet to be used as part of a bismuth bis:// url or json string.
(no / \ " ')
Inspiration from PyZMQ, BSD Licence
Data length to encode must be a multiple of 4, padding with non significant char of #0 has to be added if needed.
"""
Async TCP Client for Bismuth Wallet
Eggdrasyl
Bismuth Foundation
July 2018
"""
# add manual refresh, objectify
# icons created using http://www.winterdrache.de/freeware/png2ico/
# import sqlite3
import PIL.Image, PIL.ImageTk, pyqrcode, os, time, socks, ast, options, tarfile, essentials, platform
import hashlib, base64, icons, log, glob, re
# import connections
from tokensv2 import *
@EggPool
EggPool / mining_condition.py
Created July 10, 2018 09:28
mining_condition.py
mining_hash = bin_convert(hashlib.sha224((miner_address + nonce + db_block_hash)
.encode("utf-8")).hexdigest())
diff_drop_time = 180
mining_condition = bin_convert(db_block_hash)[:diff]
if mining_condition in mining_hash: # simplified comparison, no backwards mining
app_log.info("Difficulty requirement satisfied for block {} from {}".format (block_height_new, peer_ip))
diff_save = diff
# Tail Removal Condition Check Starts Here
@EggPool
EggPool / diff_get.py
Created July 10, 2018 09:41
diff get
def difficulty(c):
execute(c, "SELECT block_height, timestamp FROM transactions WHERE reward != 0 ORDER BY block_height DESC LIMIT 2")
block_height, timestamp_last = c.fetchone()
timestamp_before_last = c.fetchone()[1]
execute_param(c, "SELECT timestamp FROM transactions WHERE block_height > ? AND reward != 0 ORDER BY timestamp ASC LIMIT 2", (block_height - 1441,))
timestamp_1441 = c.fetchone()[0]
block_time_prev = (timestamp_before_last - timestamp_1441) / 1440
timestamp_1440 = c.fetchone()[0]
block_time = (timestamp_last - timestamp_1440) / 1440
# never remove the str() conversion in data evaluation or database inserts or you will debug for 14 days as signed types mismatch
# if you raise in the server thread, the server will die and node will stop
# never use codecs, they are bugged and do not provide proper serialization
# must unify node and client now that connections parameters are function parameters
# if you have a block of data and want to insert it into sqlite, you must use a single "commit" for the whole batch, it's 100x faster
# do not isolation_level=None/WAL hdd levels, it makes saving slow
VERSION = "4.2.5.4R" # 4.2.5.4 + rollbacks hooks
@EggPool
EggPool / no_ec2.md
Created July 25, 2018 13:24
block amazon IPs

Block amazon's IP at OS level to avoid botnet attacks

Ubuntu, iptables

Prerequisites

sudo apt install jq wget

Install (user dir)

# never remove the str() conversion in data evaluation or database inserts or you will debug for 14 days as signed types mismatch
# if you raise in the server thread, the server will die and node will stop
# never use codecs, they are bugged and do not provide proper serialization
# must unify node and client now that connections parameters are function parameters
# if you have a block of data and want to insert it into sqlite, you must use a single "commit" for the whole batch, it's 100x faster
# do not isolation_level=None/WAL hdd levels, it makes saving slow
VERSION = "4.2.6" # .025 - more hooks
@EggPool
EggPool / node_sentinel.py
Created September 14, 2018 12:41
Bismuth Node Sentinel
"""
Bismuth Node
Cron sentinel by @iyomisc
To be run every minute.
"""
import subprocess
# Edit this if you are not using the standard invocation
PYTHON_EXECUTABLE='python3'
@EggPool
EggPool / Bismuth-multi-mining.md
Last active September 14, 2018 15:31
Proposal: multi-mining algorithm management for Bismuth crypto-currency

EggdraSyl - Sept 2018
From earlier unpublished notes.

What?

Instead of having a single simple mining algorithm like now, move to a dual (or more) mining algorithm system.

Why?

The current BIS mining algo is pretty simple (2 sha rounds + diff matching) and can be ported to fpgas and asics with little difficulty and a huge increase in hash/w.