Skip to content

Commit

Permalink
This simulation with 100 Giraffes takes 50 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Apr 19, 2024
1 parent 8cb011f commit fbd8fe9
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ The strategies are tested in different network models and with different network
npm install
npm test
npm run build
node ./build/src/run.js
node ../ledgerloops/src/network-generator.js > __tests__/fixtures/testnet.csv
time node ./build/src/run.js
```

## Network simulators
Expand Down
176 changes: 168 additions & 8 deletions __tests__/fixtures/testnet.csv
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,187 @@ from to fromMaxBalance fromExchangeRate toMaxBalance toExchangeRate
14 15
16 17
18 19
19 0
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
51 52
52 53
53 54
54 55
55 56
57 58
60 61
61 62
62 63
63 64
64 65
65 66
66 67
68 69
70 71
71 72
72 73
73 74
74 75
75 76
76 77
77 78
78 79
79 80
80 81
82 83
83 84
85 86
86 87
87 88
88 89
90 91
91 92
92 93
93 94
94 95
95 96
96 97
97 98
98 99
99 0
0 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
8 10
9 11
10 12
11 13
12 14
13 15
14 16
15 17
16 18
17 19
19 1
18 20
19 21
20 22
21 23
22 24
23 25
24 26
25 27
26 28
27 29
28 30
29 31
30 32
31 33
32 34
33 35
34 36
35 37
36 38
37 39
38 40
39 41
40 42
41 43
42 44
43 45
44 46
45 47
47 49
48 50
49 51
50 52
51 53
52 54
55 57
56 58
58 60
59 61
60 62
62 64
63 65
64 66
65 67
66 68
67 69
68 70
69 71
70 72
71 73
72 74
73 75
75 77
76 78
77 79
78 80
79 81
80 82
81 83
82 84
83 85
84 86
85 87
86 88
87 89
88 90
89 91
90 92
92 94
94 96
95 97
96 98
97 99
98 0
99 1
8 0
15 9
17 2
18 4
15 49
17 12
38 24
50 63
56 9
58 51
59 82
67 77
69 43
81 52
84 49
89 30
7 0
9 91
14 18
46 28
53 20
54 96
57 79
61 88
74 98
91 61
93 22
18 changes: 9 additions & 9 deletions src/giraffe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ export class Giraffe extends EventEmitter implements NetworkNode {
probesengine.on('message', (to: string, message: string) => {
this.emit('message', to, message);
});
probesengine.on('debug', (message: string) => {
this.debugLog.push(message);
});
// probesengine.on('debug', (message: string) => {
// this.debugLog.push(message);
// });
return probesengine;
}
protected connectTracesEngine(probesengine: ProbesEngine): TracesEngine {
const tracesengine = new TracesEngine();
probesengine.on('probe-loopback', (probeId: string): void => {
tracesengine.handleProbeLoopback(probeId);
});
tracesengine.on('debug', (message: string) => {
this.debugLog.push(message);
});
// tracesengine.on('debug', (message: string) => {
// this.debugLog.push(message);
// });
tracesengine.on('lookup-probe', (probeId: string, callback: (probeFrom: string[], probeTo: string[]) => void) => {
this.debugLog.push(`[Node#lookup-probe] ${this.name} is looking up probe ${probeId}`);
const probe = probesengine.get(probeId);
Expand All @@ -60,9 +60,9 @@ export class Giraffe extends EventEmitter implements NetworkNode {
traceEngine.on('loop-found', (probeId: string, traceId: string) => {
loopsEngine.handleLoopFound(probeId, traceId);
});
loopsEngine.on('debug', (message: string) => {
this.debugLog.push(message);
});
// loopsEngine.on('debug', (message: string) => {
// this.debugLog.push(message);
// });
return loopsEngine;
}
process(sender: string, message: string): void {
Expand Down

0 comments on commit fbd8fe9

Please sign in to comment.