Commit cd42a2aa authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4a177116
...@@ -10,9 +10,7 @@ import ( ...@@ -10,9 +10,7 @@ import (
// 0. Address // 0. Address
func (p *Address) NEOEncodedLen() int { func (p *Address) NEOEncodedLen() int {
var size int return 6 + len(p.Host)
size += 4 + len(p.Host)
return size + 2
} }
func (p *Address) NEOEncode(data []byte) { func (p *Address) NEOEncode(data []byte) {
...@@ -55,9 +53,7 @@ overflow: ...@@ -55,9 +53,7 @@ overflow:
// 1. NodeInfo // 1. NodeInfo
func (p *NodeInfo) NEOEncodedLen() int { func (p *NodeInfo) NEOEncodedLen() int {
var size int return 26 + len(p.Address.Host)
size += 8 + len(p.Address.Host)
return size + 18
} }
func (p *NodeInfo) NEOEncode(data []byte) { func (p *NodeInfo) NEOEncode(data []byte) {
...@@ -120,8 +116,7 @@ overflow: ...@@ -120,8 +116,7 @@ overflow:
// 2. CellInfo // 2. CellInfo
func (p *CellInfo) NEOEncodedLen() int { func (p *CellInfo) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *CellInfo) NEOEncode(data []byte) { func (p *CellInfo) NEOEncode(data []byte) {
...@@ -149,9 +144,7 @@ overflow: ...@@ -149,9 +144,7 @@ overflow:
// 3. RowInfo // 3. RowInfo
func (p *RowInfo) NEOEncodedLen() int { func (p *RowInfo) NEOEncodedLen() int {
var size int return 8 + len(p.CellList)*8
size += 4 + len(p.CellList)*8
return size + 4
} }
func (p *RowInfo) NEOEncode(data []byte) { func (p *RowInfo) NEOEncode(data []byte) {
...@@ -207,9 +200,7 @@ overflow: ...@@ -207,9 +200,7 @@ overflow:
// 4. Notify // 4. Notify
func (p *Notify) NEOEncodedLen() int { func (p *Notify) NEOEncodedLen() int {
var size int return 4 + len(p.Message)
size += 4 + len(p.Message)
return size + 0
} }
func (p *Notify) NEOEncode(data []byte) { func (p *Notify) NEOEncode(data []byte) {
...@@ -247,9 +238,7 @@ overflow: ...@@ -247,9 +238,7 @@ overflow:
// 5. Error // 5. Error
func (p *Error) NEOEncodedLen() int { func (p *Error) NEOEncodedLen() int {
var size int return 8 + len(p.Message)
size += 8 + len(p.Message)
return size + 0
} }
func (p *Error) NEOEncode(data []byte) { func (p *Error) NEOEncode(data []byte) {
...@@ -292,8 +281,7 @@ overflow: ...@@ -292,8 +281,7 @@ overflow:
// 6. Ping // 6. Ping
func (p *Ping) NEOEncodedLen() int { func (p *Ping) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *Ping) NEOEncode(data []byte) { func (p *Ping) NEOEncode(data []byte) {
...@@ -311,8 +299,7 @@ overflow: ...@@ -311,8 +299,7 @@ overflow:
// 7. CloseClient // 7. CloseClient
func (p *CloseClient) NEOEncodedLen() int { func (p *CloseClient) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *CloseClient) NEOEncode(data []byte) { func (p *CloseClient) NEOEncode(data []byte) {
...@@ -330,10 +317,7 @@ overflow: ...@@ -330,10 +317,7 @@ overflow:
// 8. RequestIdentification // 8. RequestIdentification
func (p *RequestIdentification) NEOEncodedLen() int { func (p *RequestIdentification) NEOEncodedLen() int {
var size int return 30 + len(p.Address.Host) + len(p.Name)
size += 16 + len(p.Address.Host)
size += 6 + len(p.Name)
return size + 8
} }
func (p *RequestIdentification) NEOEncode(data []byte) { func (p *RequestIdentification) NEOEncode(data []byte) {
...@@ -416,15 +400,12 @@ overflow: ...@@ -416,15 +400,12 @@ overflow:
// 9. AcceptIdentification // 9. AcceptIdentification
func (p *AcceptIdentification) NEOEncodedLen() int { func (p *AcceptIdentification) NEOEncodedLen() int {
var size int size += 30
size += 24 + len(p.Primary.Host)
size += 2 + 4
for i := 0; i < len(p.KnownMasterList); i++ { for i := 0; i < len(p.KnownMasterList); i++ {
a := &p.KnownMasterList[i] a := &p.KnownMasterList[i]
size += 4 + len((*a).Address.Host) size += 10
size += 6
} }
return size + 0 return 0 + len(p.Primary.Host) + len((*a).Address.Host) + size
} }
func (p *AcceptIdentification) NEOEncode(data []byte) { func (p *AcceptIdentification) NEOEncode(data []byte) {
...@@ -548,8 +529,7 @@ overflow: ...@@ -548,8 +529,7 @@ overflow:
// 10. PrimaryMaster // 10. PrimaryMaster
func (p *PrimaryMaster) NEOEncodedLen() int { func (p *PrimaryMaster) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *PrimaryMaster) NEOEncode(data []byte) { func (p *PrimaryMaster) NEOEncode(data []byte) {
...@@ -567,8 +547,7 @@ overflow: ...@@ -567,8 +547,7 @@ overflow:
// 11. AnswerPrimary // 11. AnswerPrimary
func (p *AnswerPrimary) NEOEncodedLen() int { func (p *AnswerPrimary) NEOEncodedLen() int {
var size int return 4
return size + 4
} }
func (p *AnswerPrimary) NEOEncode(data []byte) { func (p *AnswerPrimary) NEOEncode(data []byte) {
...@@ -591,8 +570,7 @@ overflow: ...@@ -591,8 +570,7 @@ overflow:
// 12. AnnouncePrimary // 12. AnnouncePrimary
func (p *AnnouncePrimary) NEOEncodedLen() int { func (p *AnnouncePrimary) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *AnnouncePrimary) NEOEncode(data []byte) { func (p *AnnouncePrimary) NEOEncode(data []byte) {
...@@ -610,8 +588,7 @@ overflow: ...@@ -610,8 +588,7 @@ overflow:
// 13. ReelectPrimary // 13. ReelectPrimary
func (p *ReelectPrimary) NEOEncodedLen() int { func (p *ReelectPrimary) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *ReelectPrimary) NEOEncode(data []byte) { func (p *ReelectPrimary) NEOEncode(data []byte) {
...@@ -629,8 +606,7 @@ overflow: ...@@ -629,8 +606,7 @@ overflow:
// 14. Recovery // 14. Recovery
func (p *Recovery) NEOEncodedLen() int { func (p *Recovery) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *Recovery) NEOEncode(data []byte) { func (p *Recovery) NEOEncode(data []byte) {
...@@ -648,8 +624,7 @@ overflow: ...@@ -648,8 +624,7 @@ overflow:
// 15. AnswerRecovery // 15. AnswerRecovery
func (p *AnswerRecovery) NEOEncodedLen() int { func (p *AnswerRecovery) NEOEncodedLen() int {
var size int return 24
return size + 24
} }
func (p *AnswerRecovery) NEOEncode(data []byte) { func (p *AnswerRecovery) NEOEncode(data []byte) {
...@@ -682,8 +657,7 @@ overflow: ...@@ -682,8 +657,7 @@ overflow:
// 16. LastIDs // 16. LastIDs
func (p *LastIDs) NEOEncodedLen() int { func (p *LastIDs) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *LastIDs) NEOEncode(data []byte) { func (p *LastIDs) NEOEncode(data []byte) {
...@@ -701,8 +675,7 @@ overflow: ...@@ -701,8 +675,7 @@ overflow:
// 17. AnswerLastIDs // 17. AnswerLastIDs
func (p *AnswerLastIDs) NEOEncodedLen() int { func (p *AnswerLastIDs) NEOEncodedLen() int {
var size int return 16
return size + 16
} }
func (p *AnswerLastIDs) NEOEncode(data []byte) { func (p *AnswerLastIDs) NEOEncode(data []byte) {
...@@ -730,8 +703,7 @@ overflow: ...@@ -730,8 +703,7 @@ overflow:
// 18. PartitionTable // 18. PartitionTable
func (p *PartitionTable) NEOEncodedLen() int { func (p *PartitionTable) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *PartitionTable) NEOEncode(data []byte) { func (p *PartitionTable) NEOEncode(data []byte) {
...@@ -749,14 +721,12 @@ overflow: ...@@ -749,14 +721,12 @@ overflow:
// 19. AnswerPartitionTable // 19. AnswerPartitionTable
func (p *AnswerPartitionTable) NEOEncodedLen() int { func (p *AnswerPartitionTable) NEOEncodedLen() int {
var size int size += 12
size += 8 + 4
for i := 0; i < len(p.RowList); i++ { for i := 0; i < len(p.RowList); i++ {
a := &p.RowList[i] a := &p.RowList[i]
size += 4 + len((*a).CellList)*8 size += 8
size += 4
} }
return size + 0 return 0 + len((*a).CellList)*8 + size
} }
func (p *AnswerPartitionTable) NEOEncode(data []byte) { func (p *AnswerPartitionTable) NEOEncode(data []byte) {
...@@ -840,14 +810,12 @@ overflow: ...@@ -840,14 +810,12 @@ overflow:
// 20. NotifyPartitionTable // 20. NotifyPartitionTable
func (p *NotifyPartitionTable) NEOEncodedLen() int { func (p *NotifyPartitionTable) NEOEncodedLen() int {
var size int size += 12
size += 8 + 4
for i := 0; i < len(p.RowList); i++ { for i := 0; i < len(p.RowList); i++ {
a := &p.RowList[i] a := &p.RowList[i]
size += 4 + len((*a).CellList)*8 size += 8
size += 4
} }
return size + 0 return 0 + len((*a).CellList)*8 + size
} }
func (p *NotifyPartitionTable) NEOEncode(data []byte) { func (p *NotifyPartitionTable) NEOEncode(data []byte) {
...@@ -931,9 +899,7 @@ overflow: ...@@ -931,9 +899,7 @@ overflow:
// 21. PartitionChanges // 21. PartitionChanges
func (p *PartitionChanges) NEOEncodedLen() int { func (p *PartitionChanges) NEOEncodedLen() int {
var size int return 12 + len(p.CellList)*12
size += 4 + len(p.CellList)*12
return size + 8
} }
func (p *PartitionChanges) NEOEncode(data []byte) { func (p *PartitionChanges) NEOEncode(data []byte) {
...@@ -998,8 +964,7 @@ overflow: ...@@ -998,8 +964,7 @@ overflow:
// 22. StartOperation // 22. StartOperation
func (p *StartOperation) NEOEncodedLen() int { func (p *StartOperation) NEOEncodedLen() int {
var size int return 1
return size + 1
} }
func (p *StartOperation) NEOEncode(data []byte) { func (p *StartOperation) NEOEncode(data []byte) {
...@@ -1022,8 +987,7 @@ overflow: ...@@ -1022,8 +987,7 @@ overflow:
// 23. StopOperation // 23. StopOperation
func (p *StopOperation) NEOEncodedLen() int { func (p *StopOperation) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *StopOperation) NEOEncode(data []byte) { func (p *StopOperation) NEOEncode(data []byte) {
...@@ -1041,8 +1005,7 @@ overflow: ...@@ -1041,8 +1005,7 @@ overflow:
// 24. UnfinishedTransactions // 24. UnfinishedTransactions
func (p *UnfinishedTransactions) NEOEncodedLen() int { func (p *UnfinishedTransactions) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *UnfinishedTransactions) NEOEncode(data []byte) { func (p *UnfinishedTransactions) NEOEncode(data []byte) {
...@@ -1060,9 +1023,7 @@ overflow: ...@@ -1060,9 +1023,7 @@ overflow:
// 25. AnswerUnfinishedTransactions // 25. AnswerUnfinishedTransactions
func (p *AnswerUnfinishedTransactions) NEOEncodedLen() int { func (p *AnswerUnfinishedTransactions) NEOEncodedLen() int {
var size int return 12 + len(p.TidList)*8
size += 4 + len(p.TidList)*8
return size + 8
} }
func (p *AnswerUnfinishedTransactions) NEOEncode(data []byte) { func (p *AnswerUnfinishedTransactions) NEOEncode(data []byte) {
...@@ -1113,8 +1074,7 @@ overflow: ...@@ -1113,8 +1074,7 @@ overflow:
// 26. LockedTransactions // 26. LockedTransactions
func (p *LockedTransactions) NEOEncodedLen() int { func (p *LockedTransactions) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *LockedTransactions) NEOEncode(data []byte) { func (p *LockedTransactions) NEOEncode(data []byte) {
...@@ -1132,9 +1092,8 @@ overflow: ...@@ -1132,9 +1092,8 @@ overflow:
// 27. AnswerLockedTransactions // 27. AnswerLockedTransactions
func (p *AnswerLockedTransactions) NEOEncodedLen() int { func (p *AnswerLockedTransactions) NEOEncodedLen() int {
var size int
size += 4 + len(p.TidDict)*16 size += 4 + len(p.TidDict)*16
return size + 0 return 0
} }
func (p *AnswerLockedTransactions) NEOEncode(data []byte) { func (p *AnswerLockedTransactions) NEOEncode(data []byte) {
...@@ -1189,8 +1148,7 @@ overflow: ...@@ -1189,8 +1148,7 @@ overflow:
// 28. FinalTID // 28. FinalTID
func (p *FinalTID) NEOEncodedLen() int { func (p *FinalTID) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *FinalTID) NEOEncode(data []byte) { func (p *FinalTID) NEOEncode(data []byte) {
...@@ -1213,8 +1171,7 @@ overflow: ...@@ -1213,8 +1171,7 @@ overflow:
// 29. AnswerFinalTID // 29. AnswerFinalTID
func (p *AnswerFinalTID) NEOEncodedLen() int { func (p *AnswerFinalTID) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *AnswerFinalTID) NEOEncode(data []byte) { func (p *AnswerFinalTID) NEOEncode(data []byte) {
...@@ -1237,8 +1194,7 @@ overflow: ...@@ -1237,8 +1194,7 @@ overflow:
// 30. ValidateTransaction // 30. ValidateTransaction
func (p *ValidateTransaction) NEOEncodedLen() int { func (p *ValidateTransaction) NEOEncodedLen() int {
var size int return 16
return size + 16
} }
func (p *ValidateTransaction) NEOEncode(data []byte) { func (p *ValidateTransaction) NEOEncode(data []byte) {
...@@ -1266,8 +1222,7 @@ overflow: ...@@ -1266,8 +1222,7 @@ overflow:
// 31. BeginTransaction // 31. BeginTransaction
func (p *BeginTransaction) NEOEncodedLen() int { func (p *BeginTransaction) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *BeginTransaction) NEOEncode(data []byte) { func (p *BeginTransaction) NEOEncode(data []byte) {
...@@ -1290,8 +1245,7 @@ overflow: ...@@ -1290,8 +1245,7 @@ overflow:
// 32. AnswerBeginTransaction // 32. AnswerBeginTransaction
func (p *AnswerBeginTransaction) NEOEncodedLen() int { func (p *AnswerBeginTransaction) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *AnswerBeginTransaction) NEOEncode(data []byte) { func (p *AnswerBeginTransaction) NEOEncode(data []byte) {
...@@ -1314,10 +1268,7 @@ overflow: ...@@ -1314,10 +1268,7 @@ overflow:
// 33. FinishTransaction // 33. FinishTransaction
func (p *FinishTransaction) NEOEncodedLen() int { func (p *FinishTransaction) NEOEncodedLen() int {
var size int return 16 + len(p.OIDList)*8 + len(p.CheckedList)*8
size += 4 + len(p.OIDList)*8
size += 4 + len(p.CheckedList)*8
return size + 8
} }
func (p *FinishTransaction) NEOEncode(data []byte) { func (p *FinishTransaction) NEOEncode(data []byte) {
...@@ -1396,8 +1347,7 @@ overflow: ...@@ -1396,8 +1347,7 @@ overflow:
// 34. AnswerFinishTransaction // 34. AnswerFinishTransaction
func (p *AnswerFinishTransaction) NEOEncodedLen() int { func (p *AnswerFinishTransaction) NEOEncodedLen() int {
var size int return 16
return size + 16
} }
func (p *AnswerFinishTransaction) NEOEncode(data []byte) { func (p *AnswerFinishTransaction) NEOEncode(data []byte) {
...@@ -1425,8 +1375,7 @@ overflow: ...@@ -1425,8 +1375,7 @@ overflow:
// 35. NotifyTransactionFinished // 35. NotifyTransactionFinished
func (p *NotifyTransactionFinished) NEOEncodedLen() int { func (p *NotifyTransactionFinished) NEOEncodedLen() int {
var size int return 16
return size + 16
} }
func (p *NotifyTransactionFinished) NEOEncode(data []byte) { func (p *NotifyTransactionFinished) NEOEncode(data []byte) {
...@@ -1454,8 +1403,7 @@ overflow: ...@@ -1454,8 +1403,7 @@ overflow:
// 36. LockInformation // 36. LockInformation
func (p *LockInformation) NEOEncodedLen() int { func (p *LockInformation) NEOEncodedLen() int {
var size int return 16
return size + 16
} }
func (p *LockInformation) NEOEncode(data []byte) { func (p *LockInformation) NEOEncode(data []byte) {
...@@ -1483,8 +1431,7 @@ overflow: ...@@ -1483,8 +1431,7 @@ overflow:
// 37. AnswerLockInformation // 37. AnswerLockInformation
func (p *AnswerLockInformation) NEOEncodedLen() int { func (p *AnswerLockInformation) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *AnswerLockInformation) NEOEncode(data []byte) { func (p *AnswerLockInformation) NEOEncode(data []byte) {
...@@ -1507,9 +1454,7 @@ overflow: ...@@ -1507,9 +1454,7 @@ overflow:
// 38. InvalidateObjects // 38. InvalidateObjects
func (p *InvalidateObjects) NEOEncodedLen() int { func (p *InvalidateObjects) NEOEncodedLen() int {
var size int return 12 + len(p.OidList)*8
size += 4 + len(p.OidList)*8
return size + 8
} }
func (p *InvalidateObjects) NEOEncode(data []byte) { func (p *InvalidateObjects) NEOEncode(data []byte) {
...@@ -1560,8 +1505,7 @@ overflow: ...@@ -1560,8 +1505,7 @@ overflow:
// 39. UnlockInformation // 39. UnlockInformation
func (p *UnlockInformation) NEOEncodedLen() int { func (p *UnlockInformation) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *UnlockInformation) NEOEncode(data []byte) { func (p *UnlockInformation) NEOEncode(data []byte) {
...@@ -1584,8 +1528,7 @@ overflow: ...@@ -1584,8 +1528,7 @@ overflow:
// 40. GenerateOIDs // 40. GenerateOIDs
func (p *GenerateOIDs) NEOEncodedLen() int { func (p *GenerateOIDs) NEOEncodedLen() int {
var size int return 4
return size + 4
} }
func (p *GenerateOIDs) NEOEncode(data []byte) { func (p *GenerateOIDs) NEOEncode(data []byte) {
...@@ -1608,9 +1551,7 @@ overflow: ...@@ -1608,9 +1551,7 @@ overflow:
// 41. AnswerGenerateOIDs // 41. AnswerGenerateOIDs
func (p *AnswerGenerateOIDs) NEOEncodedLen() int { func (p *AnswerGenerateOIDs) NEOEncodedLen() int {
var size int return 4 + len(p.OidList)*8
size += 4 + len(p.OidList)*8
return size + 0
} }
func (p *AnswerGenerateOIDs) NEOEncode(data []byte) { func (p *AnswerGenerateOIDs) NEOEncode(data []byte) {
...@@ -1656,9 +1597,7 @@ overflow: ...@@ -1656,9 +1597,7 @@ overflow:
// 42. StoreObject // 42. StoreObject
func (p *StoreObject) NEOEncodedLen() int { func (p *StoreObject) NEOEncodedLen() int {
var size int return 58 + len(p.Data)*1
size += 4 + len(p.Data)*1
return size + 54
} }
func (p *StoreObject) NEOEncode(data []byte) { func (p *StoreObject) NEOEncode(data []byte) {
...@@ -1834,8 +1773,7 @@ overflow: ...@@ -1834,8 +1773,7 @@ overflow:
// 43. AnswerStoreObject // 43. AnswerStoreObject
func (p *AnswerStoreObject) NEOEncodedLen() int { func (p *AnswerStoreObject) NEOEncodedLen() int {
var size int return 17
return size + 17
} }
func (p *AnswerStoreObject) NEOEncode(data []byte) { func (p *AnswerStoreObject) NEOEncode(data []byte) {
...@@ -1868,8 +1806,7 @@ overflow: ...@@ -1868,8 +1806,7 @@ overflow:
// 44. AbortTransaction // 44. AbortTransaction
func (p *AbortTransaction) NEOEncodedLen() int { func (p *AbortTransaction) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *AbortTransaction) NEOEncode(data []byte) { func (p *AbortTransaction) NEOEncode(data []byte) {
...@@ -1892,12 +1829,7 @@ overflow: ...@@ -1892,12 +1829,7 @@ overflow:
// 45. StoreTransaction // 45. StoreTransaction
func (p *StoreTransaction) NEOEncodedLen() int { func (p *StoreTransaction) NEOEncodedLen() int {
var size int return 24 + len(p.User) + len(p.Description) + len(p.Extension) + len(p.OidList)*8
size += 12 + len(p.User)
size += 4 + len(p.Description)
size += 4 + len(p.Extension)
size += 4 + len(p.OidList)*8
return size + 0
} }
func (p *StoreTransaction) NEOEncode(data []byte) { func (p *StoreTransaction) NEOEncode(data []byte) {
...@@ -2008,8 +1940,7 @@ overflow: ...@@ -2008,8 +1940,7 @@ overflow:
// 46. VoteTransaction // 46. VoteTransaction
func (p *VoteTransaction) NEOEncodedLen() int { func (p *VoteTransaction) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *VoteTransaction) NEOEncode(data []byte) { func (p *VoteTransaction) NEOEncode(data []byte) {
...@@ -2032,8 +1963,7 @@ overflow: ...@@ -2032,8 +1963,7 @@ overflow:
// 47. GetObject // 47. GetObject
func (p *GetObject) NEOEncodedLen() int { func (p *GetObject) NEOEncodedLen() int {
var size int return 24
return size + 24
} }
func (p *GetObject) NEOEncode(data []byte) { func (p *GetObject) NEOEncode(data []byte) {
...@@ -2066,9 +1996,7 @@ overflow: ...@@ -2066,9 +1996,7 @@ overflow:
// 48. AnswerGetObject // 48. AnswerGetObject
func (p *AnswerGetObject) NEOEncodedLen() int { func (p *AnswerGetObject) NEOEncodedLen() int {
var size int return 57 + len(p.Data)*1
size += 4 + len(p.Data)*1
return size + 53
} }
func (p *AnswerGetObject) NEOEncode(data []byte) { func (p *AnswerGetObject) NEOEncode(data []byte) {
...@@ -2239,8 +2167,7 @@ overflow: ...@@ -2239,8 +2167,7 @@ overflow:
// 49. TIDList // 49. TIDList
func (p *TIDList) NEOEncodedLen() int { func (p *TIDList) NEOEncodedLen() int {
var size int return 20
return size + 20
} }
func (p *TIDList) NEOEncode(data []byte) { func (p *TIDList) NEOEncode(data []byte) {
...@@ -2273,9 +2200,7 @@ overflow: ...@@ -2273,9 +2200,7 @@ overflow:
// 50. AnswerTIDList // 50. AnswerTIDList
func (p *AnswerTIDList) NEOEncodedLen() int { func (p *AnswerTIDList) NEOEncodedLen() int {
var size int return 4 + len(p.TIDList)*8
size += 4 + len(p.TIDList)*8
return size + 0
} }
func (p *AnswerTIDList) NEOEncode(data []byte) { func (p *AnswerTIDList) NEOEncode(data []byte) {
...@@ -2321,8 +2246,7 @@ overflow: ...@@ -2321,8 +2246,7 @@ overflow:
// 51. TIDListFrom // 51. TIDListFrom
func (p *TIDListFrom) NEOEncodedLen() int { func (p *TIDListFrom) NEOEncodedLen() int {
var size int return 24
return size + 24
} }
func (p *TIDListFrom) NEOEncode(data []byte) { func (p *TIDListFrom) NEOEncode(data []byte) {
...@@ -2360,9 +2284,7 @@ overflow: ...@@ -2360,9 +2284,7 @@ overflow:
// 52. AnswerTIDListFrom // 52. AnswerTIDListFrom
func (p *AnswerTIDListFrom) NEOEncodedLen() int { func (p *AnswerTIDListFrom) NEOEncodedLen() int {
var size int return 4 + len(p.TidList)*8
size += 4 + len(p.TidList)*8
return size + 0
} }
func (p *AnswerTIDListFrom) NEOEncode(data []byte) { func (p *AnswerTIDListFrom) NEOEncode(data []byte) {
...@@ -2408,8 +2330,7 @@ overflow: ...@@ -2408,8 +2330,7 @@ overflow:
// 53. TransactionInformation // 53. TransactionInformation
func (p *TransactionInformation) NEOEncodedLen() int { func (p *TransactionInformation) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *TransactionInformation) NEOEncode(data []byte) { func (p *TransactionInformation) NEOEncode(data []byte) {
...@@ -2432,12 +2353,7 @@ overflow: ...@@ -2432,12 +2353,7 @@ overflow:
// 54. AnswerTransactionInformation // 54. AnswerTransactionInformation
func (p *AnswerTransactionInformation) NEOEncodedLen() int { func (p *AnswerTransactionInformation) NEOEncodedLen() int {
var size int return 25 + len(p.User) + len(p.Description) + len(p.Extension) + len(p.OidList)*8
size += 12 + len(p.User)
size += 4 + len(p.Description)
size += 4 + len(p.Extension)
size += 4 + len(p.OidList)*8
return size + 1
} }
func (p *AnswerTransactionInformation) NEOEncode(data []byte) { func (p *AnswerTransactionInformation) NEOEncode(data []byte) {
...@@ -2553,8 +2469,7 @@ overflow: ...@@ -2553,8 +2469,7 @@ overflow:
// 55. ObjectHistory // 55. ObjectHistory
func (p *ObjectHistory) NEOEncodedLen() int { func (p *ObjectHistory) NEOEncodedLen() int {
var size int return 24
return size + 24
} }
func (p *ObjectHistory) NEOEncode(data []byte) { func (p *ObjectHistory) NEOEncode(data []byte) {
...@@ -2587,9 +2502,7 @@ overflow: ...@@ -2587,9 +2502,7 @@ overflow:
// 56. AnswerObjectHistory // 56. AnswerObjectHistory
func (p *AnswerObjectHistory) NEOEncodedLen() int { func (p *AnswerObjectHistory) NEOEncodedLen() int {
var size int return 12 + len(p.HistoryList)*12
size += 4 + len(p.HistoryList)*12
return size + 8
} }
func (p *AnswerObjectHistory) NEOEncode(data []byte) { func (p *AnswerObjectHistory) NEOEncode(data []byte) {
...@@ -2648,8 +2561,7 @@ overflow: ...@@ -2648,8 +2561,7 @@ overflow:
// 57. PartitionList // 57. PartitionList
func (p *PartitionList) NEOEncodedLen() int { func (p *PartitionList) NEOEncodedLen() int {
var size int return 12
return size + 12
} }
func (p *PartitionList) NEOEncode(data []byte) { func (p *PartitionList) NEOEncode(data []byte) {
...@@ -2682,14 +2594,12 @@ overflow: ...@@ -2682,14 +2594,12 @@ overflow:
// 58. AnswerPartitionList // 58. AnswerPartitionList
func (p *AnswerPartitionList) NEOEncodedLen() int { func (p *AnswerPartitionList) NEOEncodedLen() int {
var size int size += 12
size += 8 + 4
for i := 0; i < len(p.RowList); i++ { for i := 0; i < len(p.RowList); i++ {
a := &p.RowList[i] a := &p.RowList[i]
size += 4 + len((*a).CellList)*8 size += 8
size += 4
} }
return size + 0 return 0 + len((*a).CellList)*8 + size
} }
func (p *AnswerPartitionList) NEOEncode(data []byte) { func (p *AnswerPartitionList) NEOEncode(data []byte) {
...@@ -2773,8 +2683,7 @@ overflow: ...@@ -2773,8 +2683,7 @@ overflow:
// 59. X_NodeList // 59. X_NodeList
func (p *X_NodeList) NEOEncodedLen() int { func (p *X_NodeList) NEOEncodedLen() int {
var size int return 4
return size + 4
} }
func (p *X_NodeList) NEOEncode(data []byte) { func (p *X_NodeList) NEOEncode(data []byte) {
...@@ -2797,14 +2706,12 @@ overflow: ...@@ -2797,14 +2706,12 @@ overflow:
// 60. AnswerNodeList // 60. AnswerNodeList
func (p *AnswerNodeList) NEOEncodedLen() int { func (p *AnswerNodeList) NEOEncodedLen() int {
var size int size += 4
size += 0 + 4
for i := 0; i < len(p.NodeList); i++ { for i := 0; i < len(p.NodeList); i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
size += 8 + len((*a).Address.Host) size += 26
size += 18
} }
return size + 0 return 0 + len((*a).Address.Host) + size
} }
func (p *AnswerNodeList) NEOEncode(data []byte) { func (p *AnswerNodeList) NEOEncode(data []byte) {
...@@ -2890,8 +2797,7 @@ overflow: ...@@ -2890,8 +2797,7 @@ overflow:
// 61. SetNodeState // 61. SetNodeState
func (p *SetNodeState) NEOEncodedLen() int { func (p *SetNodeState) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *SetNodeState) NEOEncode(data []byte) { func (p *SetNodeState) NEOEncode(data []byte) {
...@@ -2919,9 +2825,7 @@ overflow: ...@@ -2919,9 +2825,7 @@ overflow:
// 62. AddPendingNodes // 62. AddPendingNodes
func (p *AddPendingNodes) NEOEncodedLen() int { func (p *AddPendingNodes) NEOEncodedLen() int {
var size int return 4 + len(p.UUIDList)*4
size += 4 + len(p.UUIDList)*4
return size + 0
} }
func (p *AddPendingNodes) NEOEncode(data []byte) { func (p *AddPendingNodes) NEOEncode(data []byte) {
...@@ -2967,9 +2871,7 @@ overflow: ...@@ -2967,9 +2871,7 @@ overflow:
// 63. TweakPartitionTable // 63. TweakPartitionTable
func (p *TweakPartitionTable) NEOEncodedLen() int { func (p *TweakPartitionTable) NEOEncodedLen() int {
var size int return 4 + len(p.UUIDList)*4
size += 4 + len(p.UUIDList)*4
return size + 0
} }
func (p *TweakPartitionTable) NEOEncode(data []byte) { func (p *TweakPartitionTable) NEOEncode(data []byte) {
...@@ -3015,14 +2917,12 @@ overflow: ...@@ -3015,14 +2917,12 @@ overflow:
// 64. NotifyNodeInformation // 64. NotifyNodeInformation
func (p *NotifyNodeInformation) NEOEncodedLen() int { func (p *NotifyNodeInformation) NEOEncodedLen() int {
var size int size += 4
size += 0 + 4
for i := 0; i < len(p.NodeList); i++ { for i := 0; i < len(p.NodeList); i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
size += 8 + len((*a).Address.Host) size += 26
size += 18
} }
return size + 0 return 0 + len((*a).Address.Host) + size
} }
func (p *NotifyNodeInformation) NEOEncode(data []byte) { func (p *NotifyNodeInformation) NEOEncode(data []byte) {
...@@ -3108,8 +3008,7 @@ overflow: ...@@ -3108,8 +3008,7 @@ overflow:
// 65. NodeInformation // 65. NodeInformation
func (p *NodeInformation) NEOEncodedLen() int { func (p *NodeInformation) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *NodeInformation) NEOEncode(data []byte) { func (p *NodeInformation) NEOEncode(data []byte) {
...@@ -3127,8 +3026,7 @@ overflow: ...@@ -3127,8 +3026,7 @@ overflow:
// 66. SetClusterState // 66. SetClusterState
func (p *SetClusterState) NEOEncodedLen() int { func (p *SetClusterState) NEOEncodedLen() int {
var size int return 4
return size + 4
} }
func (p *SetClusterState) NEOEncode(data []byte) { func (p *SetClusterState) NEOEncode(data []byte) {
...@@ -3151,8 +3049,7 @@ overflow: ...@@ -3151,8 +3049,7 @@ overflow:
// 67. ClusterInformation // 67. ClusterInformation
func (p *ClusterInformation) NEOEncodedLen() int { func (p *ClusterInformation) NEOEncodedLen() int {
var size int return 4
return size + 4
} }
func (p *ClusterInformation) NEOEncode(data []byte) { func (p *ClusterInformation) NEOEncode(data []byte) {
...@@ -3175,8 +3072,7 @@ overflow: ...@@ -3175,8 +3072,7 @@ overflow:
// 68. X_ClusterState // 68. X_ClusterState
func (p *X_ClusterState) NEOEncodedLen() int { func (p *X_ClusterState) NEOEncodedLen() int {
var size int return 4
return size + 4
} }
func (p *X_ClusterState) NEOEncode(data []byte) { func (p *X_ClusterState) NEOEncode(data []byte) {
...@@ -3199,9 +3095,7 @@ overflow: ...@@ -3199,9 +3095,7 @@ overflow:
// 69. ObjectUndoSerial // 69. ObjectUndoSerial
func (p *ObjectUndoSerial) NEOEncodedLen() int { func (p *ObjectUndoSerial) NEOEncodedLen() int {
var size int return 28 + len(p.OidList)*8
size += 4 + len(p.OidList)*8
return size + 24
} }
func (p *ObjectUndoSerial) NEOEncode(data []byte) { func (p *ObjectUndoSerial) NEOEncode(data []byte) {
...@@ -3262,9 +3156,8 @@ overflow: ...@@ -3262,9 +3156,8 @@ overflow:
// 70. AnswerObjectUndoSerial // 70. AnswerObjectUndoSerial
func (p *AnswerObjectUndoSerial) NEOEncodedLen() int { func (p *AnswerObjectUndoSerial) NEOEncodedLen() int {
var size int
size += 4 + len(p.ObjectTIDDict)*25 size += 4 + len(p.ObjectTIDDict)*25
return size + 0 return 0
} }
func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) { func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) {
...@@ -3339,8 +3232,7 @@ overflow: ...@@ -3339,8 +3232,7 @@ overflow:
// 71. HasLock // 71. HasLock
func (p *HasLock) NEOEncodedLen() int { func (p *HasLock) NEOEncodedLen() int {
var size int return 16
return size + 16
} }
func (p *HasLock) NEOEncode(data []byte) { func (p *HasLock) NEOEncode(data []byte) {
...@@ -3368,8 +3260,7 @@ overflow: ...@@ -3368,8 +3260,7 @@ overflow:
// 72. AnswerHasLock // 72. AnswerHasLock
func (p *AnswerHasLock) NEOEncodedLen() int { func (p *AnswerHasLock) NEOEncodedLen() int {
var size int return 12
return size + 12
} }
func (p *AnswerHasLock) NEOEncode(data []byte) { func (p *AnswerHasLock) NEOEncode(data []byte) {
...@@ -3397,8 +3288,7 @@ overflow: ...@@ -3397,8 +3288,7 @@ overflow:
// 73. CheckCurrentSerial // 73. CheckCurrentSerial
func (p *CheckCurrentSerial) NEOEncodedLen() int { func (p *CheckCurrentSerial) NEOEncodedLen() int {
var size int return 24
return size + 24
} }
func (p *CheckCurrentSerial) NEOEncode(data []byte) { func (p *CheckCurrentSerial) NEOEncode(data []byte) {
...@@ -3431,8 +3321,7 @@ overflow: ...@@ -3431,8 +3321,7 @@ overflow:
// 74. AnswerCheckCurrentSerial // 74. AnswerCheckCurrentSerial
func (p *AnswerCheckCurrentSerial) NEOEncodedLen() int { func (p *AnswerCheckCurrentSerial) NEOEncodedLen() int {
var size int return 17
return size + 17
} }
func (p *AnswerCheckCurrentSerial) NEOEncode(data []byte) { func (p *AnswerCheckCurrentSerial) NEOEncode(data []byte) {
...@@ -3465,8 +3354,7 @@ overflow: ...@@ -3465,8 +3354,7 @@ overflow:
// 75. Pack // 75. Pack
func (p *Pack) NEOEncodedLen() int { func (p *Pack) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *Pack) NEOEncode(data []byte) { func (p *Pack) NEOEncode(data []byte) {
...@@ -3489,8 +3377,7 @@ overflow: ...@@ -3489,8 +3377,7 @@ overflow:
// 76. AnswerPack // 76. AnswerPack
func (p *AnswerPack) NEOEncodedLen() int { func (p *AnswerPack) NEOEncodedLen() int {
var size int return 1
return size + 1
} }
func (p *AnswerPack) NEOEncode(data []byte) { func (p *AnswerPack) NEOEncode(data []byte) {
...@@ -3513,9 +3400,8 @@ overflow: ...@@ -3513,9 +3400,8 @@ overflow:
// 77. CheckReplicas // 77. CheckReplicas
func (p *CheckReplicas) NEOEncodedLen() int { func (p *CheckReplicas) NEOEncodedLen() int {
var size int
size += 4 + len(p.PartitionDict)*8 size += 4 + len(p.PartitionDict)*8
return size + 16 return 16
} }
func (p *CheckReplicas) NEOEncode(data []byte) { func (p *CheckReplicas) NEOEncode(data []byte) {
...@@ -3580,10 +3466,7 @@ overflow: ...@@ -3580,10 +3466,7 @@ overflow:
// 78. CheckPartition // 78. CheckPartition
func (p *CheckPartition) NEOEncodedLen() int { func (p *CheckPartition) NEOEncodedLen() int {
var size int return 30 + len(p.Source.UpstreamName) + len(p.Source.Address.Host)
size += 8 + len(p.Source.UpstreamName)
size += 4 + len(p.Source.Address.Host)
return size + 18
} }
func (p *CheckPartition) NEOEncode(data []byte) { func (p *CheckPartition) NEOEncode(data []byte) {
...@@ -3661,8 +3544,7 @@ overflow: ...@@ -3661,8 +3544,7 @@ overflow:
// 79. CheckTIDRange // 79. CheckTIDRange
func (p *CheckTIDRange) NEOEncodedLen() int { func (p *CheckTIDRange) NEOEncodedLen() int {
var size int return 24
return size + 24
} }
func (p *CheckTIDRange) NEOEncode(data []byte) { func (p *CheckTIDRange) NEOEncode(data []byte) {
...@@ -3700,8 +3582,7 @@ overflow: ...@@ -3700,8 +3582,7 @@ overflow:
// 80. AnswerCheckTIDRange // 80. AnswerCheckTIDRange
func (p *AnswerCheckTIDRange) NEOEncodedLen() int { func (p *AnswerCheckTIDRange) NEOEncodedLen() int {
var size int return 32
return size + 32
} }
func (p *AnswerCheckTIDRange) NEOEncode(data []byte) { func (p *AnswerCheckTIDRange) NEOEncode(data []byte) {
...@@ -3829,8 +3710,7 @@ overflow: ...@@ -3829,8 +3710,7 @@ overflow:
// 81. CheckSerialRange // 81. CheckSerialRange
func (p *CheckSerialRange) NEOEncodedLen() int { func (p *CheckSerialRange) NEOEncodedLen() int {
var size int return 32
return size + 32
} }
func (p *CheckSerialRange) NEOEncode(data []byte) { func (p *CheckSerialRange) NEOEncode(data []byte) {
...@@ -3873,8 +3753,7 @@ overflow: ...@@ -3873,8 +3753,7 @@ overflow:
// 82. AnswerCheckSerialRange // 82. AnswerCheckSerialRange
func (p *AnswerCheckSerialRange) NEOEncodedLen() int { func (p *AnswerCheckSerialRange) NEOEncodedLen() int {
var size int return 60
return size + 60
} }
func (p *AnswerCheckSerialRange) NEOEncode(data []byte) { func (p *AnswerCheckSerialRange) NEOEncode(data []byte) {
...@@ -4107,9 +3986,7 @@ overflow: ...@@ -4107,9 +3986,7 @@ overflow:
// 83. PartitionCorrupted // 83. PartitionCorrupted
func (p *PartitionCorrupted) NEOEncodedLen() int { func (p *PartitionCorrupted) NEOEncodedLen() int {
var size int return 8 + len(p.CellList)*4
size += 4 + len(p.CellList)*4
return size + 4
} }
func (p *PartitionCorrupted) NEOEncode(data []byte) { func (p *PartitionCorrupted) NEOEncode(data []byte) {
...@@ -4160,8 +4037,7 @@ overflow: ...@@ -4160,8 +4037,7 @@ overflow:
// 84. LastTransaction // 84. LastTransaction
func (p *LastTransaction) NEOEncodedLen() int { func (p *LastTransaction) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *LastTransaction) NEOEncode(data []byte) { func (p *LastTransaction) NEOEncode(data []byte) {
...@@ -4179,8 +4055,7 @@ overflow: ...@@ -4179,8 +4055,7 @@ overflow:
// 85. AnswerLastTransaction // 85. AnswerLastTransaction
func (p *AnswerLastTransaction) NEOEncodedLen() int { func (p *AnswerLastTransaction) NEOEncodedLen() int {
var size int return 8
return size + 8
} }
func (p *AnswerLastTransaction) NEOEncode(data []byte) { func (p *AnswerLastTransaction) NEOEncode(data []byte) {
...@@ -4203,8 +4078,7 @@ overflow: ...@@ -4203,8 +4078,7 @@ overflow:
// 86. NotifyReady // 86. NotifyReady
func (p *NotifyReady) NEOEncodedLen() int { func (p *NotifyReady) NEOEncodedLen() int {
var size int return 0
return size + 0
} }
func (p *NotifyReady) NEOEncode(data []byte) { func (p *NotifyReady) NEOEncode(data []byte) {
......
...@@ -31,13 +31,13 @@ import ( ...@@ -31,13 +31,13 @@ import (
"go/types" "go/types"
"log" "log"
"os" "os"
"strings"
) )
// parsed & typechecked input // parsed & typechecked input
var fset = token.NewFileSet() var fset = token.NewFileSet()
var info = &types.Info{ var info = &types.Info{
Types: make(map[ast.Expr]types.TypeAndValue), Types: make(map[ast.Expr]types.TypeAndValue),
//Uses: make(map[*ast.Ident]types.Object), XXX seems not needed
Defs: make(map[*ast.Ident]types.Object), Defs: make(map[*ast.Ident]types.Object),
} }
...@@ -226,12 +226,12 @@ type CodecCodeGen interface { ...@@ -226,12 +226,12 @@ type CodecCodeGen interface {
generatedCode() string generatedCode() string
} }
// encode/decode codegen // sizer/encode/decode codegen
type sizer struct { type sizer struct {
Buffer // XXX Buffer // XXX
n int n int
symLenv []string // symbolic lengths TODO symLenv []string // symbolic lengths to add to size
sizeVarUsed bool // whether size var was used varSizeUsed bool // whether var size was used
} }
type encoder struct { type encoder struct {
...@@ -262,7 +262,7 @@ func (d *decoder) generatedCode() string { ...@@ -262,7 +262,7 @@ func (d *decoder) generatedCode() string {
func (s *sizer) genPrologue(recvName, typeName string) { func (s *sizer) genPrologue(recvName, typeName string) {
s.emit("func (%s *%s) NEOEncodedLen() int {", recvName, typeName) s.emit("func (%s *%s) NEOEncodedLen() int {", recvName, typeName)
if s.sizeVarUsed { if s.varSizeUsed {
s.emit("var size int") s.emit("var size int")
} }
} }
...@@ -279,10 +279,10 @@ func (d *decoder) genPrologue(recvName, typeName string) { ...@@ -279,10 +279,10 @@ func (d *decoder) genPrologue(recvName, typeName string) {
func (s *sizer) genEpilogue() { func (s *sizer) genEpilogue() {
size := fmt.Sprintf("%v", s.n) size := fmt.Sprintf("%v", s.n)
if len(s.symLenv) > 0 { if len(s.symLenv) > 0 {
size += " + " + strings.Join(s.synLenv, " + ") size += " + " + strings.Join(s.symLenv, " + ")
} }
if s.sizeVarUsed { if s.varSizeUsed {
size += " + size") size += " + size"
} }
s.emit("return %v", size) s.emit("return %v", size)
s.emit("}\n") s.emit("}\n")
...@@ -376,15 +376,19 @@ func (s *sizer) genSlice(path string, typ *types.Slice, obj types.Object) { ...@@ -376,15 +376,19 @@ func (s *sizer) genSlice(path string, typ *types.Slice, obj types.Object) {
// if size(item)==const - size update in one go // if size(item)==const - size update in one go
elemSize, ok := typeSizeFixed(typ.Elem()) elemSize, ok := typeSizeFixed(typ.Elem())
if ok { if ok {
s.emit("size += 4 + len(%v) * %v", path, elemSize) s.n += 4
s.symLenv = append(s.symLenv, fmt.Sprintf("len(%v) * %v", path, elemSize))
return return
} }
s.emit("size += %v + 4", s.n) s.varSizeUsed = true
s.n += 4
s.emit("size += %v", s.n)
s.n = 0 s.n = 0
s.emit("for i := 0; i < len(%v); i++ {", path) s.emit("for i := 0; i < len(%v); i++ {", path)
s.emit("a := &%s[i]", path) s.emit("a := &%s[i]", path)
codegenType("(*a)", typ.Elem(), obj, s) //codegenType("(*a)", typ.Elem(), obj, s)
codegenType("(*a)", typ.Elem(), obj, &sizer{})
s.emit("size += %v", s.n) s.emit("size += %v", s.n)
s.emit("}") s.emit("}")
s.n = 0 s.n = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment