Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
teaching
dunixir
Commits
11b270a9
Commit
11b270a9
authored
4 years ago
by
x18zhan2
Browse files
Options
Downloads
Patches
Plain Diff
some cleaning after merged ws2pheads
parent
0034a9b7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#1351
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/ws2p_heads/server_conf.ex
+0
-44
0 additions, 44 deletions
lib/ws2p_heads/server_conf.ex
lib/ws2p_heads/ws2p_headscache.ex
+0
-23
0 additions, 23 deletions
lib/ws2p_heads/ws2p_headscache.ex
with
0 additions
and
67 deletions
lib/ws2p_heads/server_conf.ex
deleted
100644 → 0
+
0
−
44
View file @
0034a9b7
defmodule
Server
.
Conf
.
Keypair
do
use
GenServer
def
init
(
_init
)
do
#TODO: read keypair from .yml file
seckey
=
"2DLT4zDuuQSsEehijzkwCwdvH4vrsp6joBf4rum9Zb8jDTBKhDfZawSYsGeWy56cPDUGbWf5ybJgADNnVcnJ3sek"
pubkey
=
"BhQf2fkGAe1EszyZRJqasMr23YLSf1P3mhuYzEoKpgVA"
{
:ok
,
{
pubkey
,
seckey
}}
end
def
start_link
()
do
GenServer
.
start_link
(
__MODULE__
,
[],
name:
{
:via
,
Registry
,
{
WS2P
.
HeadCache
.
Registry
,
:keypair
}})
end
def
handle_call
({
:get_pubkey
},
_from
,
state
)
do
{
pubkey
,
_
}
=
state
{
:reply
,
pubkey
,
state
}
end
def
handle_call
({
:get_seckey
},
_from
,
state
)
do
{
pubkey
,
_
}
=
state
{
:reply
,
pubkey
,
state
}
end
end
defmodule
Server
.
Conf
.
WS2PID
do
use
GenServer
#TODO: generate ws2pid when we synchronize a node, then put ws2p id into db
def
init
(
_init
)
do
#TODO: read ws2pid from db
ws2pid
=
UUID
.
uuid4
()
|>
String
.
split
(
"-"
)
|>
List
.
first
()
{
:ok
,
ws2pid
}
end
def
start_link
()
do
GenServer
.
start_link
(
__MODULE__
,
[],
name:
{
:via
,
Registry
,
{
WS2P
.
HeadCache
.
Registry
,
:ws2pid
}})
end
def
handle_call
({
:get_ws2pid
},
_from
,
ws2pid
)
do
{
:reply
,
ws2pid
,
ws2pid
}
end
end
This diff is collapsed.
Click to expand it.
lib/ws2p_heads/ws2p_headscache.ex
deleted
100644 → 0
+
0
−
23
View file @
0034a9b7
defmodule
WS2P
.
HeadsCache
do
use
GenServer
require
Logger
def
init
(
_args
)
do
{
:ok
,
%{}}
end
@spec
start_link
(
any
)
::
:ignore
|
{
:error
,
any
}
|
{
:ok
,
pid
}
def
start_link
(
_args
)
do
GenServer
.
start_link
(
__MODULE__
,
[],
name:
{
:via
,
Registry
,
{
WS2P
.
HeadCache
.
Registry
,
:headcache
}}
)
end
def
handle_call
(
:get_headcache
,
_from
,
state
)
do
{
:reply
,
state
,
state
}
end
def
handle_cast
({
:update_headcache
,
new_heads_cache
},
_old_heads_cache
)
do
{
:noreply
,
new_heads_cache
}
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment