I have updated my records search script to include BiTwin chains. Please note that initial runs will show lots of 'world records' for TWN07. See my previous post for resolution.
from jsonrpc import ServiceProxy
import json
USER = ''
PASS = ''
PORT = 9912
fname = 'worldrecords.txt'
# Searching for new world records
def main():
ip = '127.0.0.1'
addy = 'http://%s:%s@%s:%i' % (USER,PASS,ip,PORT)
p = ServiceProxy(addy)
# http://users.cybercity.dk/~dsl522332/math/Cunningham_Chain_records.htm
# http://www.primenumbers.net/Henri/fr-us/BiTwinRec.htm
records = {
# Length 6
'1CC06':{
'digits':633,
'block':None
},
'2CC06':{
'digits':475,
'block':None
},
# BiTwin chain of 6 primes, 2 links
'TWN06':{
'digits':399,
'block':None
},
# Length 7
'1CC07':{
'digits':356,
'block':None
},
'2CC07':{
'digits':251,
'block':None
},
# Length 8
'1CC08':{
'digits':186,
'block':None
},
'2CC08':{
'digits':224,
'block':None
},
# BiTwin chain of 8 primes, 3 links
'TWN08':{
'digits':177,
'block':None
},
# Length 9
'1CC09':{
'digits':185,
'block':None
},
'2CC09':{
'digits':111,
'block':None
},
# Length 10
'1CC0a':{
'digits':99,
'block':None
},
'2CC0a':{
'digits':109,
'block':None
},
# BiTwin chain of 10 primes, 4 links
'TWN0a':{
'digits':92,
'block':None
},
# Length 11
'1CC0b':{
'digits':50,
'block':None
},
'2CC0b':{
'digits':63,
'block':None
},
# Length 12
'1CC0c':{
'digits':42,
'block':None
},
'2CC0c':{
'digits':62,
'block':None
},
# BiTwin chain of 12 primes, 5 links
'TWN0c':{
'digits':47,
'block':None
},
# Length 13
'1CC0d':{
'digits':39,
'block':None
},
'2CC0d':{
'digits':33,
'block':None
},
# Length 14
'1CC0e':{
'digits':25,
'block':None
},
'2CC0e':{
'digits':33,
'block':None
},
# BiTwin chain of 14 primes, 6 links
'TWN0e':{
'digits':29,
'block':None
},
# Length 15
'1CC0f':{
'digits':24,
'block':None
},
'2CC0f':{
'digits':32,
'block':None
},
# Length 16
'1CC10':{
'digits':23,
'block':None
},
'2CC10':{
'digits':28,
'block':None
},
# BiTwin chain of 16 primes, 7 links
'TWN10':{
'digits':24,
'block':None
},
# Length 17
'1CC11':{
'digits':22,
'block':None
},
'2CC11':{
'digits':25,
'block':None
},
# Length 18
'1CC12':{
'digits':None,
'block':None
},
'2CC12':{
'digits':None,
'block':None
},
# BiTwin chain of 18 primes, 8 links
'TWN12':{
'digits':24,
'block':None
}
}
data = {}
try:
with open(fname, 'r') as f:
data = json.load(f)
except:
pass
height = 1
if 'height' in data:
height = data['height']
if 'records' in data:
records = data['records']
blockHash = p.getblockhash(height)
block = p.getblock(blockHash)
while 'nextblockhash' in block:
chain = block['primechain'].split('.')[0]
chainlength = 0
try:
chainlength = int(chain[3:5],16)
except:
print('Error with chain: %s, Block %i' % (chain,block['height']))
origin = block['primeorigin']
digits = len(origin)
height = block['height']
if chain in records:
if digits > records[chain]['digits']:
print('New World Record!')
print(' Block %i, Chain %s (%i primes), %i digits' %
(height, chain, chainlength, digits))
if records[chain]['block'] is not None:
print(' *Previous record held by Primecoin, Block %i' %
(records[chain]['block'],))
print(' Previous record: %i digits' % (records[chain]['digits']))
records[chain]['digits'] = digits
records[chain]['block'] = height
else:
print('New Chain Type: %s, Block %i, %i digits' %
(chain, height, digits))
records[chain] = {
'digits':digits,
'block': height
}
block = p.getblock(block['nextblockhash'])
print('End of block chain reached.')
data = {
'records': records,
'height': block['height']
}
with open(fname, 'w') as f:
json.dump(data, f)
print('\n\n=== Current Records ===\n')
types = ['1CC', '2CC', 'TWN']
s = ' '
for t in types:
s = '%s%7s' % (s, t)
print('%s\n' % (s,))
for i in range(6,20):
s = ' %.2i' % (i,)
for t in types:
chain = '%s%s' % (t,hex(i)[2:].zfill(2))
if chain not in records or records[chain]['digits'] is None:
s = '%s%7s' % (s,'--')
else:
if records[chain]['block'] is not None:
s = '%s%7s' % (s, ('*%i' % (records[chain]['digits'])).rjust(7))
else:
s = '%s%7i' % (s, records[chain]['digits'])
print(s)
print('\n*Found by Primecoin network\n')
if __name__ == '__main__':
main()