-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
295 lines (213 loc) · 11.1 KB
/
doc.go
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/*
Package okatype (i.e., Okanero type) provides basic types used for implementing the Okanero protocol, for the Go programming language.
Overview
With the Okanero protocol, there is a message-oriented layer to the protocol.
An Okanero Message is represented, in the Golang code, by: okatype_message.Type.
However, okatype_message.Type makes more sense in the context of three other types.
In the Golang code, there are 4 major types that you should start with, when
dealing with the Okanero protocol's message-oriented layer:
• okatype_message.Type
• okatype_block.Type
• okatype_datum.Type
• okatype_content.Type
The way that these relate to each other are:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Message ┃
┃ ┃
┃ ┏━━━━━━━━━━━━━━━━━━━━━━━┓ ┃
┃ ┃ Block ┃ ┃
┃ ┃ ┃ ┃
┃ ┃ ┏━━━━━━━━━━━━━━━━━┓ ┃ ┃
┃ ┃ ┃ Datum ┃ ┃ ┃
┃ ┃ ┃ ┃ ┃ ┃
┃ ┃ ┃ ┏━━━━━━━━━━━┓ ┃ ┃ ┃
┃ ┃ ┃ ┃ Content ┃ ┃ ┃ ┃
┃ ┃ ┃ ┗━━━━━━━━━━━┛ ┃ ┃ ┃
┃ ┃ ┗━━━━━━━━━━━━━━━━━┛ ┃ ┃
┃ ┗━━━━━━━━━━━━━━━━━━━━━━━┛ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
You can see nesting with okatype_message.Type as:
package okatype_message
type Type struct {
// ...
Block okatype_block.Type
// ...
}
And with okatype_message.Type as:
package okatype_block
type Type struct {
// ...
Datum okatype_datum.Type
// ...
}
And with okatype_datum.Type as:
package okatype_datum
type Type struct {
// ...
Content okatype_content.Type
// ...
}
To understand this:
• What is sent over or received from the network is an Okanero Message.
• What is endorsed into a Blockchain is an Okanero Block. This is what an agent acting as an endorser would create. (In other related technologies, you might call "endorsers": "miners" or "stakers".)
• What is created by the author is an Okanero Datum. This is what would-be endorsers would try to turn into an Okanero Block.
• Content is where the the author would assert any information the author wishes to assert. (Ex: if the content was an event, then it might have a "name" field (ex: "name"="FOOD_EATEN"), and a "version" field (ex: "verion"="1.0.0"), and possibly some other information (ex: "calories"="240", "sodium"="10g").)
Okanero Message
An Okanero Message is represented by okatype_message.Type.
An Okanero Message is what you would send over or receive from the network.
An Okanero Message is also what you might save to or read from a file.
When serialized into a []byte, an Okanero Message can look like:
[]byte{
7, 'o', 'k', 'a', 'n', 'e', 'r', 'o', // <-- magic, as a Pascal-string.
1, 0, 0, 0, 0, 0, 0, 0, // <-- version, as a little-endian 64 bit (8 byte) integer.
7, 'm', 'a', 'i', 'n', 'n', 'e', 't', // <-- network, as a Pascal-string.
255, 108, 1, 0, 0, 0, 0, 0, // <-- length, as a little-endian 64 bit (8 byte) integer.
// ... Okanero Block ...
}
(Note the nested Okanero Block inside of the Okanero Message.
We will go into more detail about Okanero Blocks shortly.)
You may receive a serialized Okanero Message over a network communication, or stored in (or as part of) a file.
You can think of this as the "native" format of an Okanero Message.
When working with an Okanero Message in Golang code (you probably wouldn't want to work with the serialized Okanero Message
directly, but instead), likely would want to load this kind of data into an okatype_message.Type.
(Also, from the Golang code, likely, you would will not have this serialized Okanero Message data in the form of a []byte,
but instead will have it coming from an io.Reader. So....)
For example:
var r io.Reader
// ...
var message okatype_message.Type
n64, err := message.ReadFrom(r)
You can then more easily work with the different aspects of an Okanero Message more easily. For example:
fmt.Printf("Okanero Message version = %d \n", message.Version)
Okanero Block
An Okanero Message wraps an Okanero Block.
(You could (probably safely) conflate an Okanero Block with a "Block" in a "Blockchain".)
When serialized into a []byte, an Okanero Message can look like:
[]byte{
// ... Okanero Datum ...
0x47,0xc5,0xcc,0xb1,0xda,0xe1,0x7a,0xd5, // trace, as a little-endian 512 bit (64 byte) integer.
0x5a,0x58,0x4b,0x65,0xd2,0xf7,0xe5,0x52, //
0x03,0xc9,0x5b,0x11,0x31,0x41,0xca,0xb2, //
0xc1,0x3d,0xed,0xfd,0x91,0x1d,0x4e,0x32, //
0xd1,0xb3,0x87,0x00,0xb4,0x4a,0x2c,0x71, //
0x35,0xd5,0x58,0x53,0x19,0xee,0xba,0x2a, //
0xc1,0x56,0x94,0x08,0x34,0x2b,0x93,0x26, //
0x32,0x1d,0x64,0x27,0xb2,0x06,0x06,0x8f, //
0x40,0x47,0x93,0x5A,0x53,0x8b,0xbb,0x7b, // <-- time, as a little-endian 128 it (16 byte) integer.
0x60,0x98,0x89,0x15,0x2C,0x00,0x00,0x00, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- ensorser (agent hash), as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- ensorser signature, as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- nonce, as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
}
(Note the nested Okanero Datum inside of the Okanero Message.
We will go into more detail about Okanero Datum shortly.)
Okanero Datum
A serialized Okanero Datum might look like:
[]byte{
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- genesis (block hash), as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- prev (block hash), as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
124, 122, 5, 0, 1, 0, 0, 0, // <-- count, as a little-endian 512 bit (64 byte) integer.
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, //
0x47,0xc5,0xcc,0xb1,0xda,0xe1,0x7a,0xd5, // interaction, as a little-endian 512 bit (64 byte) integer.
0x5a,0x58,0x4b,0x65,0xd2,0xf7,0xe5,0x52, //
0x03,0xc9,0x5b,0x11,0x31,0x41,0xca,0xb2, //
0xc1,0x3d,0xed,0xfd,0x91,0x1d,0x4e,0x32, //
0xd1,0xb3,0x87,0x00,0xb4,0x4a,0x2c,0x71, //
0x35,0xd5,0x58,0x53,0x19,0xee,0xba,0x2a, //
0xc1,0x56,0x94,0x08,0x34,0x2b,0x93,0x26, //
0x32,0x1d,0x64,0x27,0xb2,0x06,0x06,0x8f, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- lateral 1 (block hash), as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- lateral 2 (block hash), as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- lateral 3 (block hash), as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
// ... Okanero Content ...
0x40,0x47,0x93,0x5A,0x53,0x8b,0xbb,0x7b, // <-- time, as a little-endian 128 it (16 byte) integer.
0x60,0x98,0x89,0x15,0x2C,0x00,0x00,0x00, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- author (agent hash), as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- author signature, as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
0x39,0x2e,0x40,0xed,0x3e,0x6f,0x67,0x13, // <-- nonce, as a little-endian 512 bit (64 byte) integer.
0xae,0x6d,0xc1,0x83,0xa7,0xed,0x5d,0x9d, //
0x4f,0x36,0x6d,0x02,0x5b,0xb7,0x8f,0xc7, //
0x9d,0x5a,0x22,0x71,0x29,0x18,0x56,0x0b, //
0x80,0x1e,0x90,0xed,0xda,0x03,0x3e,0x3f, //
0xfb,0x06,0xfb,0x8c,0x85,0x5e,0x02,0x02, //
0x40,0x41,0xba,0xe1,0xe0,0x63,0x9f,0xb1, //
0xcf,0x1a,0x98,0x0b,0x28,0xae,0x55,0xb0, //
}
*/
package okatype