SC CODE: Function Initialize() Uint64
10 IF EXISTS("contract_version") == 1 THEN GOTO 900
20 STORE("contract_version", 1)
30 STORE("total_publishes", 0)
40 STORE("name_0", "")
41 STORE("score_0", 0)
42 STORE("addr_0", "")
43 STORE("time_0", 0)
50 STORE("name_1", "")
51 STORE("score_1", 0)
52 STORE("addr_1", "")
53 STORE("time_1", 0)
60 STORE("name_2", "")
61 STORE("score_2", 0)
62 STORE("addr_2", "")
63 STORE("time_2", 0)
70 STORE("name_3", "")
71 STORE("score_3", 0)
72 STORE("addr_3", "")
73 STORE("time_3", 0)
80 STORE("name_4", "")
81 STORE("score_4", 0)
82 STORE("addr_4", "")
83 STORE("time_4", 0)
900 RETURN 0
End Function
Function Publish(pseudo String, score String) Uint64
10 DIM s0, s1, s2, s3, s4 as Uint64
11 DIM min_slot, min_score, score_val, height as Uint64
20 IF STRLEN(pseudo) < 1 THEN GOTO 900
21 IF STRLEN(pseudo) > 16 THEN GOTO 900
22 IF STRLEN(score) < 1 THEN GOTO 900
30 LET score_val = ATOI(score)
31 IF score_val == 0 THEN GOTO 900
32 LET height = BLOCK_HEIGHT()
40 LET s0 = LOAD("score_0")
41 LET s1 = LOAD("score_1")
42 LET s2 = LOAD("score_2")
43 LET s3 = LOAD("score_3")
44 LET s4 = LOAD("score_4")
50 LET min_slot = 0
51 LET min_score = s0
60 IF s1 >= min_score THEN GOTO 70
61 LET min_slot = 1
62 LET min_score = s1
70 IF s2 >= min_score THEN GOTO 80
71 LET min_slot = 2
72 LET min_score = s2
80 IF s3 >= min_score THEN GOTO 90
81 LET min_slot = 3
82 LET min_score = s3
90 IF s4 >= min_score THEN GOTO 100
91 LET min_slot = 4
92 LET min_score = s4
100 IF score_val <= min_score THEN GOTO 910
110 IF min_slot == 0 THEN GOTO 200
111 IF min_slot == 1 THEN GOTO 300
112 IF min_slot == 2 THEN GOTO 400
113 IF min_slot == 3 THEN GOTO 500
114 IF min_slot == 4 THEN GOTO 600
200 STORE("name_0", pseudo)
201 STORE("score_0", score_val)
202 STORE("addr_0", SIGNER())
203 STORE("time_0", height)
204 GOTO 800
300 STORE("name_1", pseudo)
301 STORE("score_1", score_val)
302 STORE("addr_1", SIGNER())
303 STORE("time_1", height)
304 GOTO 800
400 STORE("name_2", pseudo)
401 STORE("score_2", score_val)
402 STORE("addr_2", SIGNER())
403 STORE("time_2", height)
404 GOTO 800
500 STORE("name_3", pseudo)
501 STORE("score_3", score_val)
502 STORE("addr_3", SIGNER())
503 STORE("time_3", height)
504 GOTO 800
600 STORE("name_4", pseudo)
601 STORE("score_4", score_val)
602 STORE("addr_4", SIGNER())
603 STORE("time_4", height)
604 GOTO 800
800 STORE("total_publishes", LOAD("total_publishes") + 1)
801 RETURN 0
900 RETURN 1
910 RETURN 2
End Function
|
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function Initialize() Uint64
10 IF EXISTS("contract_version") == 1 THEN GOTO 900
20 STORE("contract_version", 1)
30 STORE("total_publishes", 0)
40 STORE("name_0", "")
41 STORE("score_0", 0)
42 STORE("addr_0", "")
43 STORE("time_0", 0)
50 STORE("name_1", "")
51 STORE("score_1", 0)
52 STORE("addr_1", "")
53 STORE("time_1", 0)
60 STORE("name_2", "")
61 STORE("score_2", 0)
62 STORE("addr_2", "")
63 STORE("time_2", 0)
70 STORE("name_3", "")
71 STORE("score_3", 0)
72 STORE("addr_3", "")
73 STORE("time_3", 0)
80 STORE("name_4", "")
81 STORE("score_4", 0)
82 STORE("addr_4", "")
83 STORE("time_4", 0)
900 RETURN 0
End Function
Function Publish(pseudo String, score String) Uint64
10 DIM s0, s1, s2, s3, s4 as Uint64
11 DIM min_slot, min_score, score_val, height as Uint64
20 IF STRLEN(pseudo) < 1 THEN GOTO 900
21 IF STRLEN(pseudo) > 16 THEN GOTO 900
22 IF STRLEN(score) < 1 THEN GOTO 900
30 LET score_val = ATOI(score)
31 IF score_val == 0 THEN GOTO 900
32 LET height = BLOCK_HEIGHT()
40 LET s0 = LOAD("score_0")
41 LET s1 = LOAD("score_1")
42 LET s2 = LOAD("score_2")
43 LET s3 = LOAD("score_3")
44 LET s4 = LOAD("score_4")
50 LET min_slot = 0
51 LET min_score = s0
60 IF s1 >= min_score THEN GOTO 70
61 LET min_slot = 1
62 LET min_score = s1
70 IF s2 >= min_score THEN GOTO 80
71 LET min_slot = 2
72 LET min_score = s2
80 IF s3 >= min_score THEN GOTO 90
81 LET min_slot = 3
82 LET min_score = s3
90 IF s4 >= min_score THEN GOTO 100
91 LET min_slot = 4
92 LET min_score = s4
100 IF score_val <= min_score THEN GOTO 910
110 IF min_slot == 0 THEN GOTO 200
111 IF min_slot == 1 THEN GOTO 300
112 IF min_slot == 2 THEN GOTO 400
113 IF min_slot == 3 THEN GOTO 500
114 IF min_slot == 4 THEN GOTO 600
200 STORE("name_0", pseudo)
201 STORE("score_0", score_val)
202 STORE("addr_0", SIGNER())
203 STORE("time_0", height)
204 GOTO 800
300 STORE("name_1", pseudo)
301 STORE("score_1", score_val)
302 STORE("addr_1", SIGNER())
303 STORE("time_1", height)
304 GOTO 800
400 STORE("name_2", pseudo)
401 STORE("score_2", score_val)
402 STORE("addr_2", SIGNER())
403 STORE("time_2", height)
404 GOTO 800
500 STORE("name_3", pseudo)
501 STORE("score_3", score_val)
502 STORE("addr_3", SIGNER())
503 STORE("time_3", height)
504 GOTO 800
600 STORE("name_4", pseudo)
601 STORE("score_4", score_val)
602 STORE("addr_4", SIGNER())
603 STORE("time_4", height)
604 GOTO 800
800 STORE("total_publishes", LOAD("total_publishes") + 1)
801 RETURN 0
900 RETURN 1
910 RETURN 2
End Function
'] |