Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
6b6391c2
Commit
6b6391c2
authored
Jul 04, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
bd109559
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
20 deletions
+21
-20
go/neo/proto/proto-misc.go
go/neo/proto/proto-misc.go
+12
-9
go/neo/proto/proto.go
go/neo/proto/proto.go
+1
-1
go/neo/proto/proto_test.go
go/neo/proto/proto_test.go
+1
-1
go/neo/proto/proto_vs_py_test.go
go/neo/proto/proto_vs_py_test.go
+1
-1
go/neo/proto/protogen.go
go/neo/proto/protogen.go
+0
-2
go/neo/proto/zproto-str.go
go/neo/proto/zproto-str.go
+6
-6
No files found.
go/neo/proto/proto-misc.go
View file @
6b6391c2
// Copyright (C) 2017 Nexedi SA and Contributors.
// Copyright (C) 2017
-2018
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -40,9 +40,9 @@ func MsgType(msgCode uint16) reflect.Type {
...
@@ -40,9 +40,9 @@ func MsgType(msgCode uint16) reflect.Type {
}
}
// XXX or better translate to some other errors ?
// XXX here - not in proto.go - because else stringer will be confused
func
(
e
*
Error
)
Error
()
string
{
func
(
e
*
Error
)
Error
()
string
{
// NOTE here, not in proto.go - because else stringer will be confused.
// XXX better translate to some other errors?
s
:=
e
.
Code
.
String
()
s
:=
e
.
Code
.
String
()
if
e
.
Message
!=
""
{
if
e
.
Message
!=
""
{
s
+=
": "
+
e
.
Message
s
+=
": "
+
e
.
Message
...
@@ -52,6 +52,7 @@ func (e *Error) Error() string {
...
@@ -52,6 +52,7 @@ func (e *Error) Error() string {
// Set sets cluster state value to v.
// Set sets cluster state value to v.
//
// Use Set instead of direct assignment for ClusterState tracing to work.
// Use Set instead of direct assignment for ClusterState tracing to work.
//
//
// XXX move this to neo.clusterState wrapping proto.ClusterState?
// XXX move this to neo.clusterState wrapping proto.ClusterState?
...
@@ -60,10 +61,11 @@ func (cs *ClusterState) Set(v ClusterState) {
...
@@ -60,10 +61,11 @@ func (cs *ClusterState) Set(v ClusterState) {
traceClusterStateChanged
(
cs
)
traceClusterStateChanged
(
cs
)
}
}
//
const nodeTypeChar = "MSCA????" // keep in sync with NodeType constants
//
node type -> character representing it.
const
nodeTypeChar
=
"SMCA"
// XXX neo/py does this out of sync with NodeType constants
const
nodeTypeChar
=
"SMCA"
// NOTE neo/py does this out of sync with NodeType constants.
// String returns string representation of a node uuid.
// String returns string representation of a node uuid.
//
// It returns ex 'S1', 'M2', ...
// It returns ex 'S1', 'M2', ...
func
(
nodeUUID
NodeUUID
)
String
()
string
{
func
(
nodeUUID
NodeUUID
)
String
()
string
{
if
nodeUUID
==
0
{
if
nodeUUID
==
0
{
...
@@ -133,6 +135,7 @@ func UUID(typ NodeType, num int32) NodeUUID {
...
@@ -133,6 +135,7 @@ func UUID(typ NodeType, num int32) NodeUUID {
// ----------------------------------------
// ----------------------------------------
// IdTimeNone represents None passed as identification time.
var
IdTimeNone
=
IdTime
(
math
.
Inf
(
-
1
))
var
IdTimeNone
=
IdTime
(
math
.
Inf
(
-
1
))
func
(
t
IdTime
)
String
()
string
{
func
(
t
IdTime
)
String
()
string
{
...
@@ -147,7 +150,7 @@ func (t IdTime) String() string {
...
@@ -147,7 +150,7 @@ func (t IdTime) String() string {
// ----------------------------------------
// ----------------------------------------
// Addr
converts network address string into NEO Address
// Addr
String converts network address string into NEO Address.
//
//
// TODO make neo.Address just string without host:port split
// TODO make neo.Address just string without host:port split
func
AddrString
(
network
,
addr
string
)
(
Address
,
error
)
{
func
AddrString
(
network
,
addr
string
)
(
Address
,
error
)
{
...
@@ -181,12 +184,12 @@ func AddrString(network, addr string) (Address, error) {
...
@@ -181,12 +184,12 @@ func AddrString(network, addr string) (Address, error) {
return
Address
{
Host
:
host
,
Port
:
uint16
(
port
)},
nil
return
Address
{
Host
:
host
,
Port
:
uint16
(
port
)},
nil
}
}
// Addr converts net.Addr into NEO Address
// Addr converts net.Addr into NEO Address
.
func
Addr
(
addr
net
.
Addr
)
(
Address
,
error
)
{
func
Addr
(
addr
net
.
Addr
)
(
Address
,
error
)
{
return
AddrString
(
addr
.
Network
(),
addr
.
String
())
return
AddrString
(
addr
.
Network
(),
addr
.
String
())
}
}
// String formats Address to networked address string
// String formats Address to networked address string
.
func
(
addr
Address
)
String
()
string
{
func
(
addr
Address
)
String
()
string
{
// XXX in py if .Host == "" -> whole Address is assumed to be empty
// XXX in py if .Host == "" -> whole Address is assumed to be empty
...
...
go/neo/proto/proto.go
View file @
6b6391c2
go/neo/proto/proto_test.go
View file @
6b6391c2
...
@@ -275,7 +275,7 @@ func TestMsgMarshal(t *testing.T) {
...
@@ -275,7 +275,7 @@ func TestMsgMarshal(t *testing.T) {
}
}
}
}
// For all message types: same as testMsgMarshal but zero-values only
// For all message types: same as testMsgMarshal but zero-values only
.
// this way we additionally lightly check encode / decode overflow behaviour for all types.
// this way we additionally lightly check encode / decode overflow behaviour for all types.
func
TestMsgMarshalAllOverflowLightly
(
t
*
testing
.
T
)
{
func
TestMsgMarshalAllOverflowLightly
(
t
*
testing
.
T
)
{
for
_
,
typ
:=
range
msgTypeRegistry
{
for
_
,
typ
:=
range
msgTypeRegistry
{
...
...
go/neo/proto/proto_vs_py_test.go
View file @
6b6391c2
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"github.com/kylelemons/godebug/pretty"
"github.com/kylelemons/godebug/pretty"
)
)
// verify that message codes are the same in between py and go
// verify that message codes are the same in between py and go
.
func
TestMsgCodeVsPy
(
t
*
testing
.
T
)
{
func
TestMsgCodeVsPy
(
t
*
testing
.
T
)
{
goMsgRegistry
:=
map
[
uint16
]
string
{}
// code -> packet name
goMsgRegistry
:=
map
[
uint16
]
string
{}
// code -> packet name
for
code
,
pktType
:=
range
msgTypeRegistry
{
for
code
,
pktType
:=
range
msgTypeRegistry
{
...
...
go/neo/proto/protogen.go
View file @
6b6391c2
...
@@ -135,8 +135,6 @@ type localImporter struct {
...
@@ -135,8 +135,6 @@ type localImporter struct {
}
}
func
(
li
*
localImporter
)
Import
(
path
string
)
(
*
types
.
Package
,
error
)
{
func
(
li
*
localImporter
)
Import
(
path
string
)
(
*
types
.
Package
,
error
)
{
// xpath := strings.TrimPrefix(path, "../") // ../zodb -> zodb
// pkg := pkgMap[xpath]
pkg
:=
pkgMap
[
path
]
pkg
:=
pkgMap
[
path
]
if
pkg
!=
nil
{
if
pkg
!=
nil
{
return
pkg
,
nil
return
pkg
,
nil
...
...
go/neo/proto/zproto-str.go
View file @
6b6391c2
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
package
proto
package
proto
import
"
fmt
"
import
"
strconv
"
const
_ErrorCode_name
=
"ACKNOT_READYOID_NOT_FOUNDTID_NOT_FOUNDOID_DOES_NOT_EXISTPROTOCOL_ERRORREPLICATION_ERRORCHECKING_ERRORBACKEND_NOT_IMPLEMENTEDNON_READABLE_CELLREAD_ONLY_ACCESSINCOMPLETE_TRANSACTION"
const
_ErrorCode_name
=
"ACKNOT_READYOID_NOT_FOUNDTID_NOT_FOUNDOID_DOES_NOT_EXISTPROTOCOL_ERRORREPLICATION_ERRORCHECKING_ERRORBACKEND_NOT_IMPLEMENTEDNON_READABLE_CELLREAD_ONLY_ACCESSINCOMPLETE_TRANSACTION"
...
@@ -10,7 +10,7 @@ var _ErrorCode_index = [...]uint8{0, 3, 12, 25, 38, 56, 70, 87, 101, 124, 141, 1
...
@@ -10,7 +10,7 @@ var _ErrorCode_index = [...]uint8{0, 3, 12, 25, 38, 56, 70, 87, 101, 124, 141, 1
func
(
i
ErrorCode
)
String
()
string
{
func
(
i
ErrorCode
)
String
()
string
{
if
i
>=
ErrorCode
(
len
(
_ErrorCode_index
)
-
1
)
{
if
i
>=
ErrorCode
(
len
(
_ErrorCode_index
)
-
1
)
{
return
fmt
.
Sprintf
(
"ErrorCode(%d)"
,
i
)
return
"ErrorCode("
+
strconv
.
FormatInt
(
int64
(
i
),
10
)
+
")"
}
}
return
_ErrorCode_name
[
_ErrorCode_index
[
i
]
:
_ErrorCode_index
[
i
+
1
]]
return
_ErrorCode_name
[
_ErrorCode_index
[
i
]
:
_ErrorCode_index
[
i
+
1
]]
}
}
...
@@ -21,7 +21,7 @@ var _ClusterState_index = [...]uint8{0, 17, 33, 47, 62, 77, 86, 101}
...
@@ -21,7 +21,7 @@ var _ClusterState_index = [...]uint8{0, 17, 33, 47, 62, 77, 86, 101}
func
(
i
ClusterState
)
String
()
string
{
func
(
i
ClusterState
)
String
()
string
{
if
i
<
0
||
i
>=
ClusterState
(
len
(
_ClusterState_index
)
-
1
)
{
if
i
<
0
||
i
>=
ClusterState
(
len
(
_ClusterState_index
)
-
1
)
{
return
fmt
.
Sprintf
(
"ClusterState(%d)"
,
i
)
return
"ClusterState("
+
strconv
.
FormatInt
(
int64
(
i
),
10
)
+
")"
}
}
return
_ClusterState_name
[
_ClusterState_index
[
i
]
:
_ClusterState_index
[
i
+
1
]]
return
_ClusterState_name
[
_ClusterState_index
[
i
]
:
_ClusterState_index
[
i
+
1
]]
}
}
...
@@ -32,7 +32,7 @@ var _NodeType_index = [...]uint8{0, 6, 13, 19, 24}
...
@@ -32,7 +32,7 @@ var _NodeType_index = [...]uint8{0, 6, 13, 19, 24}
func
(
i
NodeType
)
String
()
string
{
func
(
i
NodeType
)
String
()
string
{
if
i
<
0
||
i
>=
NodeType
(
len
(
_NodeType_index
)
-
1
)
{
if
i
<
0
||
i
>=
NodeType
(
len
(
_NodeType_index
)
-
1
)
{
return
fmt
.
Sprintf
(
"NodeType(%d)"
,
i
)
return
"NodeType("
+
strconv
.
FormatInt
(
int64
(
i
),
10
)
+
")"
}
}
return
_NodeType_name
[
_NodeType_index
[
i
]
:
_NodeType_index
[
i
+
1
]]
return
_NodeType_name
[
_NodeType_index
[
i
]
:
_NodeType_index
[
i
+
1
]]
}
}
...
@@ -43,7 +43,7 @@ var _NodeState_index = [...]uint8{0, 7, 11, 18, 25}
...
@@ -43,7 +43,7 @@ var _NodeState_index = [...]uint8{0, 7, 11, 18, 25}
func
(
i
NodeState
)
String
()
string
{
func
(
i
NodeState
)
String
()
string
{
if
i
<
0
||
i
>=
NodeState
(
len
(
_NodeState_index
)
-
1
)
{
if
i
<
0
||
i
>=
NodeState
(
len
(
_NodeState_index
)
-
1
)
{
return
fmt
.
Sprintf
(
"NodeState(%d)"
,
i
)
return
"NodeState("
+
strconv
.
FormatInt
(
int64
(
i
),
10
)
+
")"
}
}
return
_NodeState_name
[
_NodeState_index
[
i
]
:
_NodeState_index
[
i
+
1
]]
return
_NodeState_name
[
_NodeState_index
[
i
]
:
_NodeState_index
[
i
+
1
]]
}
}
...
@@ -54,7 +54,7 @@ var _CellState_index = [...]uint8{0, 10, 21, 28, 37, 46}
...
@@ -54,7 +54,7 @@ var _CellState_index = [...]uint8{0, 10, 21, 28, 37, 46}
func
(
i
CellState
)
String
()
string
{
func
(
i
CellState
)
String
()
string
{
if
i
<
0
||
i
>=
CellState
(
len
(
_CellState_index
)
-
1
)
{
if
i
<
0
||
i
>=
CellState
(
len
(
_CellState_index
)
-
1
)
{
return
fmt
.
Sprintf
(
"CellState(%d)"
,
i
)
return
"CellState("
+
strconv
.
FormatInt
(
int64
(
i
),
10
)
+
")"
}
}
return
_CellState_name
[
_CellState_index
[
i
]
:
_CellState_index
[
i
+
1
]]
return
_CellState_name
[
_CellState_index
[
i
]
:
_CellState_index
[
i
+
1
]]
}
}
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