Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
c4ba3f34
Commit
c4ba3f34
authored
Apr 25, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
85666824
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
216 additions
and
200 deletions
+216
-200
go/neo/proto-marshal.go
go/neo/proto-marshal.go
+188
-188
go/neo/proto.go
go/neo/proto.go
+5
-3
go/neo/proto_test.go
go/neo/proto_test.go
+6
-2
go/neo/protogen.go
go/neo/protogen.go
+10
-5
go/neo/storage.go
go/neo/storage.go
+7
-2
No files found.
go/neo/proto-marshal.go
View file @
c4ba3f34
...
...
@@ -14,8 +14,8 @@ import (
// 0. Address
func
(
p
*
Address
)
NEOEncoded
Len
()
int
{
return
6
+
len
(
p
.
Host
)
func
(
p
*
Address
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
0
,
6
+
len
(
p
.
Host
)
}
func
(
p
*
Address
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -53,8 +53,8 @@ overflow:
// 1. NodeInfo
func
(
p
*
NodeInfo
)
NEOEncoded
Len
()
int
{
return
26
+
len
(
p
.
Address
.
Host
)
func
(
p
*
NodeInfo
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
1
,
26
+
len
(
p
.
Address
.
Host
)
}
func
(
p
*
NodeInfo
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -100,8 +100,8 @@ overflow:
// 2. CellInfo
func
(
p
*
CellInfo
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
CellInfo
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
2
,
8
}
func
(
p
*
CellInfo
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -123,8 +123,8 @@ overflow:
// 3. RowInfo
func
(
p
*
RowInfo
)
NEOEncoded
Len
()
int
{
return
8
+
len
(
p
.
CellList
)
*
8
func
(
p
*
RowInfo
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
3
,
8
+
len
(
p
.
CellList
)
*
8
}
func
(
p
*
RowInfo
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -171,12 +171,12 @@ overflow:
// 4. XXXTest
func
(
p
*
XXXTest
)
NEOEncoded
Len
()
int
{
func
(
p
*
XXXTest
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
var
size
int
for
key
:=
range
p
.
Zzz
{
size
+=
len
(
p
.
Zzz
[
key
])
}
return
12
+
len
(
p
.
Zzz
)
*
8
+
size
return
4
,
12
+
len
(
p
.
Zzz
)
*
8
+
size
}
func
(
p
*
XXXTest
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -243,8 +243,8 @@ overflow:
// 5. Notify
func
(
p
*
Notify
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
Message
)
func
(
p
*
Notify
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
5
,
4
+
len
(
p
.
Message
)
}
func
(
p
*
Notify
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -280,8 +280,8 @@ overflow:
// 6. Error
func
(
p
*
Error
)
NEOEncoded
Len
()
int
{
return
8
+
len
(
p
.
Message
)
func
(
p
*
Error
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
6
,
8
+
len
(
p
.
Message
)
}
func
(
p
*
Error
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -319,8 +319,8 @@ overflow:
// 7. Ping
func
(
p
*
Ping
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
Ping
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
7
,
0
}
func
(
p
*
Ping
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -332,8 +332,8 @@ func (p *Ping) NEODecode(data []byte) (int, error) {
// 8. CloseClient
func
(
p
*
CloseClient
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
CloseClient
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
8
,
0
}
func
(
p
*
CloseClient
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -345,8 +345,8 @@ func (p *CloseClient) NEODecode(data []byte) (int, error) {
// 9. RequestIdentification
func
(
p
*
RequestIdentification
)
NEOEncoded
Len
()
int
{
return
30
+
len
(
p
.
Address
.
Host
)
+
len
(
p
.
Name
)
func
(
p
*
RequestIdentification
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
9
,
30
+
len
(
p
.
Address
.
Host
)
+
len
(
p
.
Name
)
}
func
(
p
*
RequestIdentification
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -409,13 +409,13 @@ overflow:
// 10. AcceptIdentification
func
(
p
*
AcceptIdentification
)
NEOEncoded
Len
()
int
{
func
(
p
*
AcceptIdentification
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
KnownMasterList
);
i
++
{
a
:=
&
p
.
KnownMasterList
[
i
]
size
+=
len
((
*
a
)
.
Address
.
Host
)
}
return
30
+
len
(
p
.
Primary
.
Host
)
+
len
(
p
.
KnownMasterList
)
*
10
+
size
return
10
,
30
+
len
(
p
.
Primary
.
Host
)
+
len
(
p
.
KnownMasterList
)
*
10
+
size
}
func
(
p
*
AcceptIdentification
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -509,8 +509,8 @@ overflow:
// 11. PrimaryMaster
func
(
p
*
PrimaryMaster
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
PrimaryMaster
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
11
,
0
}
func
(
p
*
PrimaryMaster
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -522,8 +522,8 @@ func (p *PrimaryMaster) NEODecode(data []byte) (int, error) {
// 12. AnswerPrimary
func
(
p
*
AnswerPrimary
)
NEOEncoded
Len
()
int
{
return
4
func
(
p
*
AnswerPrimary
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
12
,
4
}
func
(
p
*
AnswerPrimary
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -543,8 +543,8 @@ overflow:
// 13. AnnouncePrimary
func
(
p
*
AnnouncePrimary
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
AnnouncePrimary
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
13
,
0
}
func
(
p
*
AnnouncePrimary
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -556,8 +556,8 @@ func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) {
// 14. ReelectPrimary
func
(
p
*
ReelectPrimary
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
ReelectPrimary
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
14
,
0
}
func
(
p
*
ReelectPrimary
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -569,8 +569,8 @@ func (p *ReelectPrimary) NEODecode(data []byte) (int, error) {
// 15. Recovery
func
(
p
*
Recovery
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
Recovery
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
15
,
0
}
func
(
p
*
Recovery
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -582,8 +582,8 @@ func (p *Recovery) NEODecode(data []byte) (int, error) {
// 16. AnswerRecovery
func
(
p
*
AnswerRecovery
)
NEOEncoded
Len
()
int
{
return
24
func
(
p
*
AnswerRecovery
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
16
,
24
}
func
(
p
*
AnswerRecovery
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -607,8 +607,8 @@ overflow:
// 17. LastIDs
func
(
p
*
LastIDs
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
LastIDs
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
17
,
0
}
func
(
p
*
LastIDs
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -620,8 +620,8 @@ func (p *LastIDs) NEODecode(data []byte) (int, error) {
// 18. AnswerLastIDs
func
(
p
*
AnswerLastIDs
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
AnswerLastIDs
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
1
8
,
1
6
}
func
(
p
*
AnswerLastIDs
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -643,8 +643,8 @@ overflow:
// 19. PartitionTable
func
(
p
*
PartitionTable
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
PartitionTable
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
19
,
0
}
func
(
p
*
PartitionTable
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -656,13 +656,13 @@ func (p *PartitionTable) NEODecode(data []byte) (int, error) {
// 20. AnswerPartitionTable
func
(
p
*
AnswerPartitionTable
)
NEOEncoded
Len
()
int
{
func
(
p
*
AnswerPartitionTable
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
size
+=
len
((
*
a
)
.
CellList
)
*
8
}
return
12
+
len
(
p
.
RowList
)
*
8
+
size
return
20
,
12
+
len
(
p
.
RowList
)
*
8
+
size
}
func
(
p
*
AnswerPartitionTable
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -732,13 +732,13 @@ overflow:
// 21. NotifyPartitionTable
func
(
p
*
NotifyPartitionTable
)
NEOEncoded
Len
()
int
{
func
(
p
*
NotifyPartitionTable
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
size
+=
len
((
*
a
)
.
CellList
)
*
8
}
return
12
+
len
(
p
.
RowList
)
*
8
+
size
return
21
,
12
+
len
(
p
.
RowList
)
*
8
+
size
}
func
(
p
*
NotifyPartitionTable
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -808,8 +808,8 @@ overflow:
// 22. PartitionChanges
func
(
p
*
PartitionChanges
)
NEOEncoded
Len
()
int
{
return
12
+
len
(
p
.
CellList
)
*
12
func
(
p
*
PartitionChanges
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
22
,
12
+
len
(
p
.
CellList
)
*
12
}
func
(
p
*
PartitionChanges
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -862,8 +862,8 @@ overflow:
// 23. StartOperation
func
(
p
*
StartOperation
)
NEOEncoded
Len
()
int
{
return
1
func
(
p
*
StartOperation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
23
,
1
}
func
(
p
*
StartOperation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -883,8 +883,8 @@ overflow:
// 24. StopOperation
func
(
p
*
StopOperation
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
StopOperation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
24
,
0
}
func
(
p
*
StopOperation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -896,8 +896,8 @@ func (p *StopOperation) NEODecode(data []byte) (int, error) {
// 25. UnfinishedTransactions
func
(
p
*
UnfinishedTransactions
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
RowList
)
*
4
func
(
p
*
UnfinishedTransactions
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
25
,
4
+
len
(
p
.
RowList
)
*
4
}
func
(
p
*
UnfinishedTransactions
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -940,8 +940,8 @@ overflow:
// 26. AnswerUnfinishedTransactions
func
(
p
*
AnswerUnfinishedTransactions
)
NEOEncoded
Len
()
int
{
return
12
+
len
(
p
.
TidList
)
*
8
func
(
p
*
AnswerUnfinishedTransactions
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
26
,
12
+
len
(
p
.
TidList
)
*
8
}
func
(
p
*
AnswerUnfinishedTransactions
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -986,8 +986,8 @@ overflow:
// 27. LockedTransactions
func
(
p
*
LockedTransactions
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
LockedTransactions
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
27
,
0
}
func
(
p
*
LockedTransactions
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -999,8 +999,8 @@ func (p *LockedTransactions) NEODecode(data []byte) (int, error) {
// 28. AnswerLockedTransactions
func
(
p
*
AnswerLockedTransactions
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
TidDict
)
*
16
func
(
p
*
AnswerLockedTransactions
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
28
,
4
+
len
(
p
.
TidDict
)
*
16
}
func
(
p
*
AnswerLockedTransactions
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1049,8 +1049,8 @@ overflow:
// 29. FinalTID
func
(
p
*
FinalTID
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
FinalTID
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
29
,
8
}
func
(
p
*
FinalTID
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1070,8 +1070,8 @@ overflow:
// 30. AnswerFinalTID
func
(
p
*
AnswerFinalTID
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
AnswerFinalTID
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
30
,
8
}
func
(
p
*
AnswerFinalTID
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1091,8 +1091,8 @@ overflow:
// 31. ValidateTransaction
func
(
p
*
ValidateTransaction
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
ValidateTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
31
,
16
}
func
(
p
*
ValidateTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1114,8 +1114,8 @@ overflow:
// 32. BeginTransaction
func
(
p
*
BeginTransaction
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
BeginTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
32
,
8
}
func
(
p
*
BeginTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1135,8 +1135,8 @@ overflow:
// 33. AnswerBeginTransaction
func
(
p
*
AnswerBeginTransaction
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
AnswerBeginTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
33
,
8
}
func
(
p
*
AnswerBeginTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1156,8 +1156,8 @@ overflow:
// 34. FailedVote
func
(
p
*
FailedVote
)
NEOEncoded
Len
()
int
{
return
12
+
len
(
p
.
UUIDList
)
*
4
func
(
p
*
FailedVote
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
34
,
12
+
len
(
p
.
UUIDList
)
*
4
}
func
(
p
*
FailedVote
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1202,8 +1202,8 @@ overflow:
// 35. FinishTransaction
func
(
p
*
FinishTransaction
)
NEOEncoded
Len
()
int
{
return
16
+
len
(
p
.
OIDList
)
*
8
+
len
(
p
.
CheckedList
)
*
8
func
(
p
*
FinishTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
35
,
16
+
len
(
p
.
OIDList
)
*
8
+
len
(
p
.
CheckedList
)
*
8
}
func
(
p
*
FinishTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1272,8 +1272,8 @@ overflow:
// 36. AnswerFinishTransaction
func
(
p
*
AnswerFinishTransaction
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
AnswerFinishTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
36
,
16
}
func
(
p
*
AnswerFinishTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1295,8 +1295,8 @@ overflow:
// 37. NotifyTransactionFinished
func
(
p
*
NotifyTransactionFinished
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
NotifyTransactionFinished
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
37
,
16
}
func
(
p
*
NotifyTransactionFinished
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1318,8 +1318,8 @@ overflow:
// 38. LockInformation
func
(
p
*
LockInformation
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
LockInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
38
,
16
}
func
(
p
*
LockInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1341,8 +1341,8 @@ overflow:
// 39. AnswerLockInformation
func
(
p
*
AnswerLockInformation
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
AnswerLockInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
39
,
8
}
func
(
p
*
AnswerLockInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1362,8 +1362,8 @@ overflow:
// 40. InvalidateObjects
func
(
p
*
InvalidateObjects
)
NEOEncoded
Len
()
int
{
return
12
+
len
(
p
.
OidList
)
*
8
func
(
p
*
InvalidateObjects
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
40
,
12
+
len
(
p
.
OidList
)
*
8
}
func
(
p
*
InvalidateObjects
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1408,8 +1408,8 @@ overflow:
// 41. UnlockInformation
func
(
p
*
UnlockInformation
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
UnlockInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
41
,
8
}
func
(
p
*
UnlockInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1429,8 +1429,8 @@ overflow:
// 42. GenerateOIDs
func
(
p
*
GenerateOIDs
)
NEOEncoded
Len
()
int
{
return
4
func
(
p
*
GenerateOIDs
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
4
2
,
4
}
func
(
p
*
GenerateOIDs
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1450,8 +1450,8 @@ overflow:
// 43. AnswerGenerateOIDs
func
(
p
*
AnswerGenerateOIDs
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
OidList
)
*
8
func
(
p
*
AnswerGenerateOIDs
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
4
3
,
4
+
len
(
p
.
OidList
)
*
8
}
func
(
p
*
AnswerGenerateOIDs
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1494,8 +1494,8 @@ overflow:
// 44. Deadlock
func
(
p
*
Deadlock
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
Deadlock
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
44
,
16
}
func
(
p
*
Deadlock
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1517,8 +1517,8 @@ overflow:
// 45. RebaseTransaction
func
(
p
*
RebaseTransaction
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
RebaseTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
45
,
16
}
func
(
p
*
RebaseTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1540,8 +1540,8 @@ overflow:
// 46. AnswerRebaseTransaction
func
(
p
*
AnswerRebaseTransaction
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
OidList
)
*
8
func
(
p
*
AnswerRebaseTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
4
6
,
4
+
len
(
p
.
OidList
)
*
8
}
func
(
p
*
AnswerRebaseTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1584,8 +1584,8 @@ overflow:
// 47. RebaseObject
func
(
p
*
RebaseObject
)
NEOEncoded
Len
()
int
{
return
16
func
(
p
*
RebaseObject
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
47
,
16
}
func
(
p
*
RebaseObject
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1607,8 +1607,8 @@ overflow:
// 48. AnswerRebaseObject
func
(
p
*
AnswerRebaseObject
)
NEOEncoded
Len
()
int
{
return
41
+
len
(
p
.
Data
)
func
(
p
*
AnswerRebaseObject
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
4
8
,
4
1
+
len
(
p
.
Data
)
}
func
(
p
*
AnswerRebaseObject
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1653,8 +1653,8 @@ overflow:
// 49. StoreObject
func
(
p
*
StoreObject
)
NEOEncoded
Len
()
int
{
return
57
+
len
(
p
.
Data
)
func
(
p
*
StoreObject
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
49
,
57
+
len
(
p
.
Data
)
}
func
(
p
*
StoreObject
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1703,8 +1703,8 @@ overflow:
// 50. AnswerStoreObject
func
(
p
*
AnswerStoreObject
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
AnswerStoreObject
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
50
,
8
}
func
(
p
*
AnswerStoreObject
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1724,8 +1724,8 @@ overflow:
// 51. AbortTransaction
func
(
p
*
AbortTransaction
)
NEOEncoded
Len
()
int
{
return
12
+
len
(
p
.
UUIDList
)
*
4
func
(
p
*
AbortTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
51
,
12
+
len
(
p
.
UUIDList
)
*
4
}
func
(
p
*
AbortTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1770,8 +1770,8 @@ overflow:
// 52. StoreTransaction
func
(
p
*
StoreTransaction
)
NEOEncoded
Len
()
int
{
return
24
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
func
(
p
*
StoreTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
52
,
24
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
}
func
(
p
*
StoreTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1867,8 +1867,8 @@ overflow:
// 53. VoteTransaction
func
(
p
*
VoteTransaction
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
VoteTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
53
,
8
}
func
(
p
*
VoteTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1888,8 +1888,8 @@ overflow:
// 54. GetObject
func
(
p
*
GetObject
)
NEOEncoded
Len
()
int
{
return
24
func
(
p
*
GetObject
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
54
,
24
}
func
(
p
*
GetObject
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1913,8 +1913,8 @@ overflow:
// 55. AnswerGetObject
func
(
p
*
AnswerGetObject
)
NEOEncoded
Len
()
int
{
return
57
+
len
(
p
.
Data
)
func
(
p
*
AnswerGetObject
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
5
5
,
5
7
+
len
(
p
.
Data
)
}
func
(
p
*
AnswerGetObject
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1963,8 +1963,8 @@ overflow:
// 56. TIDList
func
(
p
*
TIDList
)
NEOEncoded
Len
()
int
{
return
20
func
(
p
*
TIDList
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
56
,
20
}
func
(
p
*
TIDList
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -1988,8 +1988,8 @@ overflow:
// 57. AnswerTIDList
func
(
p
*
AnswerTIDList
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
TIDList
)
*
8
func
(
p
*
AnswerTIDList
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
57
,
4
+
len
(
p
.
TIDList
)
*
8
}
func
(
p
*
AnswerTIDList
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2032,8 +2032,8 @@ overflow:
// 58. TIDListFrom
func
(
p
*
TIDListFrom
)
NEOEncoded
Len
()
int
{
return
24
func
(
p
*
TIDListFrom
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
58
,
24
}
func
(
p
*
TIDListFrom
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2059,8 +2059,8 @@ overflow:
// 59. AnswerTIDListFrom
func
(
p
*
AnswerTIDListFrom
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
TidList
)
*
8
func
(
p
*
AnswerTIDListFrom
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
59
,
4
+
len
(
p
.
TidList
)
*
8
}
func
(
p
*
AnswerTIDListFrom
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2103,8 +2103,8 @@ overflow:
// 60. TransactionInformation
func
(
p
*
TransactionInformation
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
TransactionInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
60
,
8
}
func
(
p
*
TransactionInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2124,8 +2124,8 @@ overflow:
// 61. AnswerTransactionInformation
func
(
p
*
AnswerTransactionInformation
)
NEOEncoded
Len
()
int
{
return
25
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
func
(
p
*
AnswerTransactionInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
61
,
25
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
}
func
(
p
*
AnswerTransactionInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2223,8 +2223,8 @@ overflow:
// 62. ObjectHistory
func
(
p
*
ObjectHistory
)
NEOEncoded
Len
()
int
{
return
24
func
(
p
*
ObjectHistory
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
62
,
24
}
func
(
p
*
ObjectHistory
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2248,8 +2248,8 @@ overflow:
// 63. AnswerObjectHistory
func
(
p
*
AnswerObjectHistory
)
NEOEncoded
Len
()
int
{
return
12
+
len
(
p
.
HistoryList
)
*
12
func
(
p
*
AnswerObjectHistory
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
63
,
12
+
len
(
p
.
HistoryList
)
*
12
}
func
(
p
*
AnswerObjectHistory
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2299,8 +2299,8 @@ overflow:
// 64. PartitionList
func
(
p
*
PartitionList
)
NEOEncoded
Len
()
int
{
return
12
func
(
p
*
PartitionList
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
64
,
12
}
func
(
p
*
PartitionList
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2324,13 +2324,13 @@ overflow:
// 65. AnswerPartitionList
func
(
p
*
AnswerPartitionList
)
NEOEncoded
Len
()
int
{
func
(
p
*
AnswerPartitionList
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
RowList
);
i
++
{
a
:=
&
p
.
RowList
[
i
]
size
+=
len
((
*
a
)
.
CellList
)
*
8
}
return
12
+
len
(
p
.
RowList
)
*
8
+
size
return
65
,
12
+
len
(
p
.
RowList
)
*
8
+
size
}
func
(
p
*
AnswerPartitionList
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2400,8 +2400,8 @@ overflow:
// 66. X_NodeList
func
(
p
*
X_NodeList
)
NEOEncoded
Len
()
int
{
return
4
func
(
p
*
X_NodeList
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
66
,
4
}
func
(
p
*
X_NodeList
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2421,13 +2421,13 @@ overflow:
// 67. AnswerNodeList
func
(
p
*
AnswerNodeList
)
NEOEncoded
Len
()
int
{
func
(
p
*
AnswerNodeList
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
size
+=
len
((
*
a
)
.
Address
.
Host
)
}
return
4
+
len
(
p
.
NodeList
)
*
26
+
size
return
67
,
4
+
len
(
p
.
NodeList
)
*
26
+
size
}
func
(
p
*
AnswerNodeList
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2495,8 +2495,8 @@ overflow:
// 68. SetNodeState
func
(
p
*
SetNodeState
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
SetNodeState
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
68
,
8
}
func
(
p
*
SetNodeState
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2518,8 +2518,8 @@ overflow:
// 69. AddPendingNodes
func
(
p
*
AddPendingNodes
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
UUIDList
)
*
4
func
(
p
*
AddPendingNodes
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
69
,
4
+
len
(
p
.
UUIDList
)
*
4
}
func
(
p
*
AddPendingNodes
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2562,8 +2562,8 @@ overflow:
// 70. TweakPartitionTable
func
(
p
*
TweakPartitionTable
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
UUIDList
)
*
4
func
(
p
*
TweakPartitionTable
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
70
,
4
+
len
(
p
.
UUIDList
)
*
4
}
func
(
p
*
TweakPartitionTable
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2606,13 +2606,13 @@ overflow:
// 71. NotifyNodeInformation
func
(
p
*
NotifyNodeInformation
)
NEOEncoded
Len
()
int
{
func
(
p
*
NotifyNodeInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
size
+=
len
((
*
a
)
.
Address
.
Host
)
}
return
12
+
len
(
p
.
NodeList
)
*
26
+
size
return
71
,
12
+
len
(
p
.
NodeList
)
*
26
+
size
}
func
(
p
*
NotifyNodeInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2682,8 +2682,8 @@ overflow:
// 72. NodeInformation
func
(
p
*
NodeInformation
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
NodeInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
72
,
0
}
func
(
p
*
NodeInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2695,8 +2695,8 @@ func (p *NodeInformation) NEODecode(data []byte) (int, error) {
// 73. SetClusterState
func
(
p
*
SetClusterState
)
NEOEncoded
Len
()
int
{
return
4
func
(
p
*
SetClusterState
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
73
,
4
}
func
(
p
*
SetClusterState
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2716,8 +2716,8 @@ overflow:
// 74. repairFlags
func
(
p
*
repairFlags
)
NEOEncoded
Len
()
int
{
return
1
func
(
p
*
repairFlags
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
74
,
1
}
func
(
p
*
repairFlags
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2737,8 +2737,8 @@ overflow:
// 75. Repair
func
(
p
*
Repair
)
NEOEncoded
Len
()
int
{
return
5
+
len
(
p
.
UUIDList
)
*
4
func
(
p
*
Repair
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
75
,
5
+
len
(
p
.
UUIDList
)
*
4
}
func
(
p
*
Repair
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2783,8 +2783,8 @@ overflow:
// 76. RepairOne
func
(
p
*
RepairOne
)
NEOEncoded
Len
()
int
{
return
1
func
(
p
*
RepairOne
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
76
,
1
}
func
(
p
*
RepairOne
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2804,8 +2804,8 @@ overflow:
// 77. ClusterInformation
func
(
p
*
ClusterInformation
)
NEOEncoded
Len
()
int
{
return
4
func
(
p
*
ClusterInformation
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
77
,
4
}
func
(
p
*
ClusterInformation
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2825,8 +2825,8 @@ overflow:
// 78. X_ClusterState
func
(
p
*
X_ClusterState
)
NEOEncoded
Len
()
int
{
return
4
func
(
p
*
X_ClusterState
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
78
,
4
}
func
(
p
*
X_ClusterState
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2846,8 +2846,8 @@ overflow:
// 79. ObjectUndoSerial
func
(
p
*
ObjectUndoSerial
)
NEOEncoded
Len
()
int
{
return
28
+
len
(
p
.
OidList
)
*
8
func
(
p
*
ObjectUndoSerial
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
79
,
28
+
len
(
p
.
OidList
)
*
8
}
func
(
p
*
ObjectUndoSerial
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2896,8 +2896,8 @@ overflow:
// 80. AnswerObjectUndoSerial
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncoded
Len
()
int
{
return
4
+
len
(
p
.
ObjectTIDDict
)
*
25
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
80
,
4
+
len
(
p
.
ObjectTIDDict
)
*
25
}
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2960,8 +2960,8 @@ overflow:
// 81. CheckCurrentSerial
func
(
p
*
CheckCurrentSerial
)
NEOEncoded
Len
()
int
{
return
24
func
(
p
*
CheckCurrentSerial
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
81
,
24
}
func
(
p
*
CheckCurrentSerial
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -2985,8 +2985,8 @@ overflow:
// 82. Pack
func
(
p
*
Pack
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
Pack
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
8
2
,
8
}
func
(
p
*
Pack
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3006,8 +3006,8 @@ overflow:
// 83. AnswerPack
func
(
p
*
AnswerPack
)
NEOEncoded
Len
()
int
{
return
1
func
(
p
*
AnswerPack
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
83
,
1
}
func
(
p
*
AnswerPack
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3027,8 +3027,8 @@ overflow:
// 84. CheckReplicas
func
(
p
*
CheckReplicas
)
NEOEncoded
Len
()
int
{
return
20
+
len
(
p
.
PartitionDict
)
*
8
func
(
p
*
CheckReplicas
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
84
,
20
+
len
(
p
.
PartitionDict
)
*
8
}
func
(
p
*
CheckReplicas
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3081,8 +3081,8 @@ overflow:
// 85. CheckPartition
func
(
p
*
CheckPartition
)
NEOEncoded
Len
()
int
{
return
30
+
len
(
p
.
Source
.
UpstreamName
)
+
len
(
p
.
Source
.
Address
.
Host
)
func
(
p
*
CheckPartition
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
85
,
30
+
len
(
p
.
Source
.
UpstreamName
)
+
len
(
p
.
Source
.
Address
.
Host
)
}
func
(
p
*
CheckPartition
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3143,8 +3143,8 @@ overflow:
// 86. CheckTIDRange
func
(
p
*
CheckTIDRange
)
NEOEncoded
Len
()
int
{
return
24
func
(
p
*
CheckTIDRange
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
86
,
24
}
func
(
p
*
CheckTIDRange
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3170,8 +3170,8 @@ overflow:
// 87. AnswerCheckTIDRange
func
(
p
*
AnswerCheckTIDRange
)
NEOEncoded
Len
()
int
{
return
32
func
(
p
*
AnswerCheckTIDRange
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
87
,
32
}
func
(
p
*
AnswerCheckTIDRange
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3195,8 +3195,8 @@ overflow:
// 88. CheckSerialRange
func
(
p
*
CheckSerialRange
)
NEOEncoded
Len
()
int
{
return
32
func
(
p
*
CheckSerialRange
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
88
,
32
}
func
(
p
*
CheckSerialRange
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3224,8 +3224,8 @@ overflow:
// 89. AnswerCheckSerialRange
func
(
p
*
AnswerCheckSerialRange
)
NEOEncoded
Len
()
int
{
return
60
func
(
p
*
AnswerCheckSerialRange
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
89
,
60
}
func
(
p
*
AnswerCheckSerialRange
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3253,8 +3253,8 @@ overflow:
// 90. PartitionCorrupted
func
(
p
*
PartitionCorrupted
)
NEOEncoded
Len
()
int
{
return
8
+
len
(
p
.
CellList
)
*
4
func
(
p
*
PartitionCorrupted
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
90
,
8
+
len
(
p
.
CellList
)
*
4
}
func
(
p
*
PartitionCorrupted
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3299,8 +3299,8 @@ overflow:
// 91. LastTransaction
func
(
p
*
LastTransaction
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
LastTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
91
,
0
}
func
(
p
*
LastTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3312,8 +3312,8 @@ func (p *LastTransaction) NEODecode(data []byte) (int, error) {
// 92. AnswerLastTransaction
func
(
p
*
AnswerLastTransaction
)
NEOEncoded
Len
()
int
{
return
8
func
(
p
*
AnswerLastTransaction
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
92
,
8
}
func
(
p
*
AnswerLastTransaction
)
NEOEncode
(
data
[]
byte
)
{
...
...
@@ -3333,8 +3333,8 @@ overflow:
// 93. NotifyReady
func
(
p
*
NotifyReady
)
NEOEncoded
Len
()
int
{
return
0
func
(
p
*
NotifyReady
)
NEOEncoded
Info
()
(
uint16
,
int
)
{
return
93
,
0
}
func
(
p
*
NotifyReady
)
NEOEncode
(
data
[]
byte
)
{
...
...
go/neo/proto.go
View file @
c4ba3f34
...
...
@@ -91,11 +91,13 @@ var ErrDecodeOverflow = errors.New("decode: bufer overflow")
// NEOEncoder is interface for marshaling objects to wire format
type
NEOEncoder
interface
{
// compute how much space is needed to encode
NEOEncodedLen
()
int
// NEOEncodedInfo returns message code needed to be used for the packet
// on the wire and how much space is needed to encode payload
// XXX naming?
NEOEncodedInfo
()
(
msgCode
uint16
,
payloadLen
int
)
// perform the encoding.
// len(buf) must be >=
NEOEncodedLen()
// len(buf) must be >=
payloadLen returned by NEOEncodedInfo
NEOEncode
(
buf
[]
byte
)
}
...
...
go/neo/proto_test.go
View file @
c4ba3f34
...
...
@@ -82,7 +82,11 @@ func testPktMarshal(t *testing.T, pkt NEOCodec, encoded string) {
}()
// pkt.encode() == expected
n
:=
pkt
.
NEOEncodedLen
()
msgCode
,
n
:=
pkt
.
NEOEncodedInfo
()
msgType
:=
pktTypeRegistry
[
msgCode
]
if
msgType
!=
typ
{
t
.
Errorf
(
"%v: msgCode = %v which corresponds to %v"
,
typ
,
msgCode
,
msgType
)
}
if
n
!=
len
(
encoded
)
{
t
.
Errorf
(
"%v: encodedLen = %v ; want %v"
,
typ
,
n
,
len
(
encoded
))
}
...
...
@@ -266,7 +270,7 @@ func TestPktMarshalAllOverflowLightly(t *testing.T) {
for
_
,
typ
:=
range
pktTypeRegistry
{
// zero-value for a type
pkt
:=
reflect
.
New
(
typ
)
.
Interface
()
.
(
NEOCodec
)
l
:=
pkt
.
NEOEncodedLen
()
_
,
l
:=
pkt
.
NEOEncodedInfo
()
zerol
:=
make
([]
byte
,
l
)
// decoding will turn nil slice & map into empty allocated ones.
// we need it so that reflect.DeepEqual works for pkt encode/decode comparison
...
...
go/neo/protogen.go
View file @
c4ba3f34
...
...
@@ -19,7 +19,7 @@ This program generates marshalling code for packet types defined in proto.go .
For every type 3 methods are generated in accordance with NEOEncoder and
NEODecoder interfaces:
NEOEncoded
Len() int
NEOEncoded
Info() (msgCode uint16, payloadLen int)
NEOEncode(buf []byte)
NEODecode(data []byte) (nread int, err error)
...
...
@@ -192,7 +192,7 @@ import (
case
*
ast
.
StructType
:
fmt
.
Fprintf
(
&
buf
,
"// %d. %s
\n\n
"
,
pktCode
,
typename
)
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
sizer
{}))
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
sizer
{
msgCode
:
pktCode
}))
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
encoder
{}))
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
decoder
{}))
...
...
@@ -455,13 +455,18 @@ func (o *OverflowCheck) AddExpr(format string, a ...interface{}) {
type
sizer
struct
{
commonCodeGen
size
SymSize
// currently accumulated packet size
// which code to also return as packet msgCode
// (sizer does not compute this - it is emitted as-is given by caller)
msgCode
int
}
// encoder generates code to encode a packet
//
// when type is recursively walked, for every case code to update `data[n:]` is generated.
// no overflow checks are generated as by NEOEncoder interface provided data
// buffer should have at least NEOEncodedLen() length (the size computed by sizer).
// buffer should have at least payloadLen length returned by NEOEncodedInfo()
// (the size computed by sizer).
//
// the code emitted looks like:
//
...
...
@@ -517,7 +522,7 @@ var _ CodeGenerator = (*decoder)(nil)
func
(
s
*
sizer
)
generatedCode
()
string
{
code
:=
Buffer
{}
// prologue
code
.
emit
(
"func (%s *%s) NEOEncoded
Len() int
{"
,
s
.
recvName
,
s
.
typeName
)
code
.
emit
(
"func (%s *%s) NEOEncoded
Info() (uint16, int)
{"
,
s
.
recvName
,
s
.
typeName
)
if
s
.
varUsed
[
"size"
]
{
code
.
emit
(
"var %s int"
,
s
.
var_
(
"size"
))
}
...
...
@@ -529,7 +534,7 @@ func (s *sizer) generatedCode() string {
if
s
.
varUsed
[
"size"
]
{
size
+=
" + "
+
s
.
var_
(
"size"
)
}
code
.
emit
(
"return %v
"
,
size
)
code
.
emit
(
"return %v
, %v"
,
s
.
msgCode
,
size
)
code
.
emit
(
"}
\n
"
)
return
code
.
String
()
...
...
go/neo/storage.go
View file @
c4ba3f34
...
...
@@ -126,8 +126,13 @@ func RecvAndDecode(conn *Conn) (interface{}, error) { // XXX interface{} -> NEOD
func
EncodeAndSend
(
conn
*
Conn
,
pkt
NEOEncoder
)
error
{
// TODO encode pkt
l
:=
pkt
.
NEOEncodedLen
()
buf
:=
PktBuf
{
make
([]
byte
,
PktHeadLen
+
l
)}
// XXX -> freelist
msgCode
,
l
:=
pkt
.
NEOEncodedInfo
()
l
+=
PktHeadLen
buf
:=
PktBuf
{
make
([]
byte
,
l
)}
// XXX -> freelist
h
:=
buf
.
Header
()
h
.
MsgCode
=
hton16
(
msgCode
)
h
.
Len
=
hton32
(
uint32
(
l
))
// XXX casting: think again
pkt
.
NEOEncode
(
buf
.
Payload
())
return
conn
.
Send
(
&
buf
)
// XXX why pointer?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment