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
0d1abff4
Commit
0d1abff4
authored
Jun 06, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0ee8d550
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
go/neo/storage.go
go/neo/storage.go
+29
-6
No files found.
go/neo/storage.go
View file @
0d1abff4
...
@@ -39,7 +39,7 @@ type Storage struct {
...
@@ -39,7 +39,7 @@ type Storage struct {
my
NodeInfo
// XXX -> only Address + NodeUUID ?
my
NodeInfo
// XXX -> only Address + NodeUUID ?
net
Network
// network we are working on
net
Network
// network we are working on
masterAddr
Address
// address of master
masterAddr
string
// address of master XXX -> Address ?
zstor
zodb
.
IStorage
// underlying ZODB storage XXX temp ?
zstor
zodb
.
IStorage
// underlying ZODB storage XXX temp ?
}
}
...
@@ -48,7 +48,7 @@ type Storage struct {
...
@@ -48,7 +48,7 @@ type Storage struct {
// The storage uses zstor as underlying backend for storing data.
// The storage uses zstor as underlying backend for storing data.
// To actually start running the node - call Run. XXX text
// To actually start running the node - call Run. XXX text
func
NewStorage
(
net
Network
,
masterAddr
string
,
serveAddr
string
,
zstor
zodb
.
IStorage
)
*
Storage
{
func
NewStorage
(
net
Network
,
masterAddr
string
,
serveAddr
string
,
zstor
zodb
.
IStorage
)
*
Storage
{
stor
:=
&
Storage
{
net
:
net
,
zstor
:
zstor
}
stor
:=
&
Storage
{
net
:
net
,
masterAddr
:
masterAddr
,
zstor
:
zstor
}
return
stor
return
stor
}
}
...
@@ -77,17 +77,40 @@ func (stor *Storage) Run(ctx context.Context) error {
...
@@ -77,17 +77,40 @@ func (stor *Storage) Run(ctx context.Context) error {
my
.
Address
=
addr
my
.
Address
=
addr
go
stor
.
talkMaster
(
ctx
)
// TODO
go
stor
.
talkMaster
(
ctx
)
err
=
Serve
(
ctx
,
l
,
stor
)
// XXX -> go
err
=
Serve
(
ctx
,
l
,
stor
)
// XXX -> go
?
return
err
// XXX err ctx
return
err
// XXX err ctx
// XXX oversee both master and server and wait ?
// XXX oversee both master and server and wait ?
}
}
// talkMaster connects to master announces self and receives notifications and commands
// talkMaster connects to master, announces self and receives notifications and commands
// it tries to persist master link reconnecting as needed
func
(
stor
*
Storage
)
talkMaster
(
ctx
context
.
Context
)
{
func
(
stor
*
Storage
)
talkMaster
(
ctx
context
.
Context
)
{
// TODO
for
{
stor
.
talkMaster1
(
ctx
)
// XXX err -> log ?
// throttle reconnecting / exit on cancel
select
{
case
<-
ctx
.
Done
()
:
return
// XXX 1s hardcoded -> move out of here
case
<-
time
.
After
(
1
*
time
.
Second
)
:
// ok
}
}
}
func
(
stor
*
Storage
)
talkMaster1
(
ctx
context
.
Context
)
{
fmt
.
Printf
(
"stor: connecting to master %v
\n
"
,
stor
.
masterAddr
)
// XXX info
Mlink
,
err
:=
Dial
(
ctx
,
stor
.
net
,
stor
.
masterAddr
)
if
err
!=
nil
{
// XXX
}
}
}
// ServeLink serves incoming node-node link connection
// ServeLink serves incoming node-node link connection
...
...
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