-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.cddl
96 lines (80 loc) · 2.37 KB
/
messages.cddl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
; messages (or events) sent from the server to the client
msg
= msgFree
\ msgLock
\ msgInput
\ msgOutput
\ msgMutexSuccess
\ msgMutexFailure
\ msgClose
\ msgError
\ msgSubSuccess
\ msgSubFailure;
clientReq = clientReqFree \ clientReqLock;
msgFree = [ 0, utxoRef, addr ]
msgLock = [ 1, utxoRef, addr ]
msgInput = [ 2, utxoRef, addr, txHash ]; txHash of the tx that spent the utxo
msgOutput = [ 3, utxoRef, addr ];
msgMutexSuccess = [ 4, id, mutexOp, successData ];
msgMutexFailure = [ 5, id, mutexOp, failureData ];
msgClose = [ 6 ];
msgError = [ 7, errorCode ];
msgSubSuccess = [ 8, id ];
msgSubFailure = [ 9, id, errorCode ];
clientReq
= clientReqFree
\ clientReqLock
\ clientSub
\ clientUnsub
\ clientClose
; messages sent from the client to the server
clientReqFree = [ 0, id, [ + utxoRef ] ];
clientReqLock = [ 1, id, [ + utxoRef ], ? required_number ];
clientSub = [ 2, id, eventType, [ * filter ] ];
clientUnsub = [ 3, id, eventType, [ * filter ] ];
clientClose = msgClose; [ 6 ];
required_number = uint; (optional) number of required utxos to lock in order to succeed, defaults to `1`
eventType = uint .size 1 ; unsigned integer 1 byte
; 0: Free
; 1: Lock
; 2: MutexoInput
; 3: MutexoOutput
; 4: Success
; 5: Failure
; 6: Close
; 7: Error
; 8: SubSuccess
; 9: SubFailure
filter
= [ 0, addr ]
\ [ 1, utxoRef ]
failureData = [* utxoRef];
; = [ 0, [* utxoRef] ]; no utxos were freed, sending back utxo requested
; \ [ 1, [* utxoRef] ]; no utxos were locked, sending back utxo requested
successData = [+ utxoRef];
; = [ 0, [+ utxoRef] ]; utxos were freed
; \ [ 1, [+ utxoRef] ]; utxos were locked
mutexOp = (
0; free
\ 1; lock
);
; errorCode = uint .size 1 ; unsigned integer 1 byte
errorCode = (
0 ; not authenticated
\ 1 ; missing Ip
\ 2 ; invalid auth token
\ 3 ; too many requests, rate limited
\ 4 ; address is not followed
\ 5 ; utxo not found
\ 6 ; unkown event to subscribe by address
\ 7 ; unkown event to subscribe by utxoRef
\ 8 ; unkown event to un-subscribe by address
\ 9 ; unkown event to un-subscribe by utxoRef
\ 10 ; unsub message sent; but no event specified
\ 11 ; unkown filter
)
utxoRef = [ hash32, uint ]
txHash = hash32;
id = uint .size 8;
hash32 = bytes .size 32;
addr = bytes; according to the cardano-ledger cddl (babbage)