MCPcopy Create free account
hub / github.com/dsg-titech/simblock / main

Method main

simulator/src/main/java/simblock/simulator/Main.java:117–242  ·  view source on GitHub ↗

The entry point. @param args the input arguments

(String[] args)

Source from the content-addressed store, hash-verified

115 * @param args the input arguments
116 */
117 public static void main(String[] args) {
118 final long start = System.currentTimeMillis();
119 setTargetInterval(INTERVAL);
120
121 //start json format
122 OUT_JSON_FILE.print("[");
123 OUT_JSON_FILE.flush();
124
125 // Log regions
126 printRegion();
127
128 // Setup network
129 constructNetworkWithAllNodes(NUM_OF_NODES);
130
131 // Initial block height, we stop at END_BLOCK_HEIGHT
132 int currentBlockHeight = 1;
133
134 // Iterate over tasks and handle
135 while (getTask() != null) {
136 if (getTask() instanceof AbstractMintingTask) {
137 AbstractMintingTask task = (AbstractMintingTask) getTask();
138 if (task.getParent().getHeight() == currentBlockHeight) {
139 currentBlockHeight++;
140 }
141 if (currentBlockHeight > END_BLOCK_HEIGHT) {
142 break;
143 }
144 // Log every 100 blocks and at the second block
145 // TODO use constants here
146 if (currentBlockHeight % 100 == 0 || currentBlockHeight == 2) {
147 writeGraph(currentBlockHeight);
148 }
149 }
150 // Execute task
151 runTask();
152 }
153
154 // Print propagation information about all blocks
155 printAllPropagation();
156
157 //TODO logger
158 System.out.println();
159
160 Set<Block> blocks = new HashSet<>();
161
162 // Get the latest block from the first simulated node
163 Block block = getSimulatedNodes().get(0).getBlock();
164
165 //Update the list of known blocks by adding the parents of the aforementioned block
166 while (block.getParent() != null) {
167 blocks.add(block);
168 block = block.getParent();
169 }
170
171 Set<Block> orphans = new HashSet<>();
172 int averageOrphansSize = 0;
173 // Gather all known orphans
174 for (Node node : getSimulatedNodes()) {

Callers

nothing calls this directly

Calls 15

getParentMethod · 0.95
writeGraphMethod · 0.95
getParentMethod · 0.95
setTargetIntervalMethod · 0.80
printRegionMethod · 0.80
getHeightMethod · 0.80
runTaskMethod · 0.80
printAllPropagationMethod · 0.80
getSimulatedNodesMethod · 0.80
getOrphansMethod · 0.80
getTimeMethod · 0.80

Tested by

no test coverage detected