@@ -3,12 +3,13 @@ icon: material/hub
3
3
---
4
4
5
5
# Pseudocode
6
- Building blocks in the form of * pseudocode* ;
6
+ Building blocks in the form of * pseudocode* ;
7
7
Intended to make the conceptual design more concrete; not setting rules.
8
8
9
9
## Node
10
10
11
11
Restart node with new config
12
+
12
13
``` rust
13
14
fn restart_node (config : Config ) -> Result <(), Err >{
14
15
// graceful restart
@@ -18,6 +19,7 @@ fn restart_node(config: Config) -> Result<(), Err>{
18
19
## Config
19
20
20
21
Check if config exists; all orchestration is coordinated via the DB, more specifically the config.
22
+
21
23
``` rust
22
24
fn config_exists (db : DBHandler ) -> Option <Config > {
23
25
// lock db
@@ -28,6 +30,7 @@ fn config_exists(db: DBHandler) -> Option<Config> {
28
30
```
29
31
30
32
Node polls for config until it exists in database
33
+
31
34
``` rust
32
35
fn poll_config (db : DBHandler ) -> Option <Config > {
33
36
loop {
@@ -39,6 +42,7 @@ fn poll_config(db: DBHandler) -> Option<Config> {
39
42
```
40
43
41
44
Check if config has been updated
45
+
42
46
``` rust
43
47
fn config_updated (db : DBHandler ) -> Option <Config > {
44
48
// lock db
@@ -51,6 +55,7 @@ fn config_updated(db: DBHandler) -> Option<Config> {
51
55
## Updates
52
56
53
57
Continually race to update database
58
+
54
59
``` rust
55
60
fn index_follower_data (db : DBHandler , stream : FollowerIo )-> Result <(), Err > {
56
61
loop {
@@ -63,6 +68,7 @@ fn index_follower_data(db: DBHandler, stream: FollowerIo)-> Result<(), Err> {
63
68
64
69
Check most recent update on cardano update table
65
70
If it falls within the threshold boundary, node should update db with latest data
71
+
66
72
``` rust
67
73
fn database_ready_to_update (db : DBHandler ) -> bool {
68
74
// lock db
@@ -73,6 +79,7 @@ fn database_ready_to_update(db: DBHandler) -> bool {
73
79
```
74
80
75
81
Update database with follower data
82
+
76
83
``` rust
77
84
fn update_database (db : DBHandler , stream : FollowerIo ) -> Result <(), Err > {
78
85
// lock db
@@ -85,13 +92,15 @@ fn update_database(db: DBHandler, stream: FollowerIo) -> Result<(), Err> {
85
92
```
86
93
87
94
Parse block
95
+
88
96
``` rust
89
97
fn parse (block : Block ) -> Result <MetaBlock , Err > {
90
98
// extract era, UTXO, spent TXs and registration metadata
91
99
}
92
100
```
93
101
94
102
Calculate if threshold conditional has been met
103
+
95
104
``` rust
96
105
fn update_threshold (last_updated : ThresholdMetric ) -> bool {
97
106
// threshold calculation
0 commit comments