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
dbab0779
Commit
dbab0779
authored
2 years ago
by
Xavier Perret
Browse files
Options
Downloads
Patches
Plain Diff
reduced code
parent
949ea52a
No related branches found
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/process-connection/process-connection.go
+6
-22
6 additions, 22 deletions
app/process-connection/process-connection.go
with
6 additions
and
22 deletions
app/process-connection/process-connection.go
+
6
−
22
View file @
dbab0779
...
@@ -36,15 +36,9 @@ func listAllTransactionsToClient(conn net.Conn, objectStorage Blob) {
...
@@ -36,15 +36,9 @@ func listAllTransactionsToClient(conn net.Conn, objectStorage Blob) {
}
}
func
processTransaction
(
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
func
processTransaction
(
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
var
trans
Transaction
var
body
map
[
string
]
interface
{}
=
mess
.
MessageBody
.
(
map
[
string
]
interface
{})
// Convert mess to transaction
// Convert mess to transaction
fmt
.
Println
(
"Processing transaction"
)
fmt
.
Println
(
"Processing transaction"
)
trans
.
Id
=
body
[
"id"
]
.
(
string
)
trans
:=
utilities
.
TranslateMessageToTransaction
(
mess
)
trans
.
Receiver
=
body
[
"receiver"
]
.
(
string
)
trans
.
Sender
=
body
[
"sender"
]
.
(
string
)
trans
.
Amount
=
body
[
"amount"
]
.
(
string
)
utilities
.
PrintTransaction
(
trans
)
utilities
.
PrintTransaction
(
trans
)
database
:=
ObjectStorageAPI
.
ReadDatabaseFromBlobStorage
(
objectStorage
)
database
:=
ObjectStorageAPI
.
ReadDatabaseFromBlobStorage
(
objectStorage
)
...
@@ -98,12 +92,7 @@ func processTransaction(serverListener net.Listener, serverConfig Config, object
...
@@ -98,12 +92,7 @@ func processTransaction(serverListener net.Listener, serverConfig Config, object
fmt
.
Println
(
"***********************************"
)
fmt
.
Println
(
"***********************************"
)
}
}
func
processRate
(
conn
net
.
Conn
,
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
func
processRate
(
conn
net
.
Conn
,
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
var
trans
Transaction
trans
:=
utilities
.
TranslateMessageToTransaction
(
mess
)
var
body
map
[
string
]
interface
{}
=
mess
.
MessageBody
.
(
map
[
string
]
interface
{})
trans
.
Id
=
body
[
"id"
]
.
(
string
)
trans
.
Receiver
=
body
[
"receiver"
]
.
(
string
)
trans
.
Sender
=
body
[
"sender"
]
.
(
string
)
trans
.
Amount
=
body
[
"amount"
]
.
(
string
)
utilities
.
PrintTransaction
(
trans
)
utilities
.
PrintTransaction
(
trans
)
// todo change this for cloud
// todo change this for cloud
...
@@ -171,10 +160,7 @@ func vote(server net.Listener, serverConfig Config, trans Transaction, parentAdd
...
@@ -171,10 +160,7 @@ func vote(server net.Listener, serverConfig Config, trans Transaction, parentAdd
}
}
if
mess
.
MessageType
==
"AckResponse"
{
if
mess
.
MessageType
==
"AckResponse"
{
var
body
map
[
string
]
interface
{}
=
mess
.
MessageBody
.
(
map
[
string
]
interface
{})
newAck
=
utilities
.
TranslateMessageToAckTransaction
(
mess
)
newAck
.
Id
=
body
[
"id"
]
.
(
string
)
newAck
.
AmountOfCorrectNode
=
body
[
"amountOfCorrectNode"
]
.
(
int
)
newAck
.
TotalNodes
=
body
[
"totalNodes"
]
.
(
int
)
if
ack
.
Id
==
newAck
.
Id
{
if
ack
.
Id
==
newAck
.
Id
{
ack
.
TotalNodes
+=
newAck
.
TotalNodes
ack
.
TotalNodes
+=
newAck
.
TotalNodes
ack
.
AmountOfCorrectNode
+=
newAck
.
AmountOfCorrectNode
ack
.
AmountOfCorrectNode
+=
newAck
.
AmountOfCorrectNode
...
@@ -211,16 +197,14 @@ func vote(server net.Listener, serverConfig Config, trans Transaction, parentAdd
...
@@ -211,16 +197,14 @@ func vote(server net.Listener, serverConfig Config, trans Transaction, parentAdd
}
}
func
processFakeRequest
(
conn
net
.
Conn
,
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
func
processFakeRequest
(
conn
net
.
Conn
,
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
var
trans
Transaction
trans
:=
utilities
.
TranslateMessageToTransaction
(
mess
)
var
body
map
[
string
]
interface
{}
=
mess
.
MessageBody
.
(
map
[
string
]
interface
{})
utilities
.
PrintTransaction
(
trans
)
}
}
func
processVoteRequest
(
conn
net
.
Conn
,
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
func
processVoteRequest
(
conn
net
.
Conn
,
serverListener
net
.
Listener
,
serverConfig
Config
,
objectStorage
Blob
,
mess
Message
,
amIRoot
bool
)
{
var
trans
Transaction
trans
:=
utilities
.
TranslateMessageToTransaction
(
mess
)
var
body
map
[
string
]
interface
{}
=
mess
.
MessageBody
.
(
map
[
string
]
interface
{})
fmt
.
Println
(
"Received back a transaction"
)
utilities
.
PrintTransaction
(
trans
)
utilities
.
PrintTransaction
(
trans
)
}
}
...
...
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