-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulator.py
51 lines (43 loc) · 1.48 KB
/
simulator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from Constants import *
from hashRate import *
from blockChain import *
from simulation import *
import random
import operator as op
import functools
import time
import os
import csv
import numpy
import sys
import math
import errno
def letsGetThisPartyStarted(params=None):
if params==None:
#print("No parameters passed when party getting started. Using defaults.")
s = simulation([])
else:
#print("Parameters passed in to get a party started! Indeed, params = " + str(params))
s = simulation(params)
s.runSim()
###########################################################
def printToLog(self, text):
self.logFile = open(self.logFileName, "a")
if(not self.logFile):
print("Error in (simulator __printToLog__): Log file is an empty object!")
else:
self.logFile.write(text + "\n")
self.logFile.close()
def make_sure_path_exists(self, path):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
###########################################################
fifths = MAX_RUN_TIME*0.2
thisTime = [0.0, 1.0*fifths, 2.0*fifths, 3.0*fifths, 4.0*fifths, 5.0*fifths]
theseValues = [10.0, 20.0, 40.0, 80.0, 100.0]
thisHashRate = hashRate([thisTime,theseValues,DESC_EXAMPLE,MAX_RUN_TIME])
params = [MAX_RUN_TIME, LAMBDA_TARGET, DIFFICULTY_FORMULA, STARTING_DIFFICULTY, DIFF_ADJ_PERIOD, DIFF_SAMPLE_SIZE, TIME_SAMPLE_SIZE, thisHashRate]
letsGetThisPartyStarted(params)