Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
perso-distributed-systems
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xavier.perret
perso-distributed-systems
Commits
46c7531b
Commit
46c7531b
authored
2 years ago
by
Xavier Perret
Browse files
Options
Downloads
Patches
Plain Diff
starting to refactored the application
parent
0e13df10
No related branches found
No related tags found
1 merge request
!2
added file to separate client function from the server
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/server.go
+59
-0
59 additions, 0 deletions
app/server.go
with
59 additions
and
0 deletions
app/server.go
0 → 100644
+
59
−
0
View file @
46c7531b
package
main
import
(
"fmt"
"gopkg.in/yaml.v3"
.
"node/types"
"node/utilities"
"os"
)
/**
* @file Server.go - Server for the blockchain
* @brief Distributed Systems - Blockchain, each instance of this program is a node in the blockchain
* @author Xavier Perret
* @date 28/10/2022
* @version 1.3
*/
func
main
()
{
argsLen
:=
len
(
os
.
Args
)
isThereEnoughArgs
:=
argsLen
<=
1
if
isThereEnoughArgs
{
fmt
.
Println
(
"First argument should be the path of the config file '--path=<config.yaml>'"
)
os
.
Exit
(
1
)
}
// init configuration
args
:=
os
.
Args
[
1
:
]
fmt
.
Println
(
"Program started with arguments"
,
args
)
fmt
.
Println
(
"config file path is "
,
args
[
0
][
7
:
])
buf
,
err
:=
os
.
ReadFile
(
args
[
0
][
7
:
])
if
err
!=
nil
{
fmt
.
Println
(
"Error while reading the config file"
,
err
)
fmt
.
Println
(
"Exiting..."
)
os
.
Exit
(
1
)
}
var
c
Config
err
=
yaml
.
Unmarshal
(
buf
,
&
c
)
if
err
!=
nil
{
os
.
Exit
(
1
)
}
utilities
.
PrintConfig
(
c
)
amIRoot
:=
argsLen
==
3
if
amIRoot
{
if
os
.
Args
[
3
]
==
"--root"
{
amIRoot
=
true
}
}
if
!
amIRoot
{
fmt
.
Println
(
"Third argument is not --root meaning this node is not meant to be directly stimulated by the client"
)
}
fmt
.
Println
(
"Launching server loop"
)
fmt
.
Println
(
"Launching user input command line"
)
}
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