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 TestStore() Uint64
10 STORE("last_test", "ok")
20 STORE("last_test_height", BLOCK_HEIGHT())
30 RETURN 0
End Function
Function Publish(pseudo String, score Uint64) Uint64
10 IF STRLEN(pseudo) < 1 THEN GOTO 900
20 IF STRLEN(pseudo) > 16 THEN GOTO 900
30 IF score == 0 THEN GOTO 900
40 DIM score_u as Uint64
41 LET score_u = score + 0
50 DIM s0 as Uint64
51 DIM s1 as Uint64
52 DIM s2 as Uint64
53 DIM s3 as Uint64
54 DIM s4 as Uint64
60 LET s0 = LOAD("score_0") + 0
61 LET s1 = LOAD("score_1") + 0
62 LET s2 = LOAD("score_2") + 0
63 LET s3 = LOAD("score_3") + 0
64 LET s4 = LOAD("score_4") + 0
70 DIM min_slot as Uint64
71 DIM min_score as Uint64
80 LET min_slot = 0
81 LET min_score = s0
90 IF s1 >= min_score THEN GOTO 100
91 LET min_slot = 1
92 LET min_score = s1
100 IF s2 >= min_score THEN GOTO 110
101 LET min_slot = 2
102 LET min_score = s2
110 IF s3 >= min_score THEN GOTO 120
111 LET min_slot = 3
112 LET min_score = s3
120 IF s4 >= min_score THEN GOTO 200
121 LET min_slot = 4
122 LET min_score = s4
200 IF score_u <= min_score THEN GOTO 910
210 IF min_slot == 0 THEN GOTO 300
211 IF min_slot == 1 THEN GOTO 400
212 IF min_slot == 2 THEN GOTO 500
213 IF min_slot == 3 THEN GOTO 600
214 IF min_slot == 4 THEN GOTO 700
300 STORE("name_0", pseudo)
301 STORE("score_0", score_u)
302 STORE("addr_0", SIGNER())
303 STORE("time_0", BLOCK_HEIGHT())
304 GOTO 800
400 STORE("name_1", pseudo)
401 STORE("score_1", score_u)
402 STORE("addr_1", SIGNER())
403 STORE("time_1", BLOCK_HEIGHT())
404 GOTO 800
500 STORE("name_2", pseudo)
501 STORE("score_2", score_u)
502 STORE("addr_2", SIGNER())
503 STORE("time_2", BLOCK_HEIGHT())
504 GOTO 800
600 STORE("name_3", pseudo)
601 STORE("score_3", score_u)
602 STORE("addr_3", SIGNER())
603 STORE("time_3", BLOCK_HEIGHT())
604 GOTO 800
700 STORE("name_4", pseudo)
701 STORE("score_4", score_u)
702 STORE("addr_4", SIGNER())
703 STORE("time_4", BLOCK_HEIGHT())
704 GOTO 800
800 DIM tp as Uint64
801 LET tp = LOAD("total_publishes") + 1
802 STORE("total_publishes", tp)
803 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 TestStore() Uint64
10 STORE("last_test", "ok")
20 STORE("last_test_height", BLOCK_HEIGHT())
30 RETURN 0
End Function
Function Publish(pseudo String, score Uint64) Uint64
10 IF STRLEN(pseudo) < 1 THEN GOTO 900
20 IF STRLEN(pseudo) > 16 THEN GOTO 900
30 IF score == 0 THEN GOTO 900
40 DIM score_u as Uint64
41 LET score_u = score + 0
50 DIM s0 as Uint64
51 DIM s1 as Uint64
52 DIM s2 as Uint64
53 DIM s3 as Uint64
54 DIM s4 as Uint64
60 LET s0 = LOAD("score_0") + 0
61 LET s1 = LOAD("score_1") + 0
62 LET s2 = LOAD("score_2") + 0
63 LET s3 = LOAD("score_3") + 0
64 LET s4 = LOAD("score_4") + 0
70 DIM min_slot as Uint64
71 DIM min_score as Uint64
80 LET min_slot = 0
81 LET min_score = s0
90 IF s1 >= min_score THEN GOTO 100
91 LET min_slot = 1
92 LET min_score = s1
100 IF s2 >= min_score THEN GOTO 110
101 LET min_slot = 2
102 LET min_score = s2
110 IF s3 >= min_score THEN GOTO 120
111 LET min_slot = 3
112 LET min_score = s3
120 IF s4 >= min_score THEN GOTO 200
121 LET min_slot = 4
122 LET min_score = s4
200 IF score_u <= min_score THEN GOTO 910
210 IF min_slot == 0 THEN GOTO 300
211 IF min_slot == 1 THEN GOTO 400
212 IF min_slot == 2 THEN GOTO 500
213 IF min_slot == 3 THEN GOTO 600
214 IF min_slot == 4 THEN GOTO 700
300 STORE("name_0", pseudo)
301 STORE("score_0", score_u)
302 STORE("addr_0", SIGNER())
303 STORE("time_0", BLOCK_HEIGHT())
304 GOTO 800
400 STORE("name_1", pseudo)
401 STORE("score_1", score_u)
402 STORE("addr_1", SIGNER())
403 STORE("time_1", BLOCK_HEIGHT())
404 GOTO 800
500 STORE("name_2", pseudo)
501 STORE("score_2", score_u)
502 STORE("addr_2", SIGNER())
503 STORE("time_2", BLOCK_HEIGHT())
504 GOTO 800
600 STORE("name_3", pseudo)
601 STORE("score_3", score_u)
602 STORE("addr_3", SIGNER())
603 STORE("time_3", BLOCK_HEIGHT())
604 GOTO 800
700 STORE("name_4", pseudo)
701 STORE("score_4", score_u)
702 STORE("addr_4", SIGNER())
703 STORE("time_4", BLOCK_HEIGHT())
704 GOTO 800
800 DIM tp as Uint64
801 LET tp = LOAD("total_publishes") + 1
802 STORE("total_publishes", tp)
803 RETURN 0
900 RETURN 1
910 RETURN 2
End Function
'] |