Skip to content
Snippets Groups Projects
Commit 6873ed4e authored by Xavier Perret's avatar Xavier Perret
Browse files

added utilities function for cleaner code

parent cfa22be3
No related branches found
No related tags found
1 merge request!2added file to separate client function from the server
package utilities
import (
"fmt"
. "node/types"
)
func PrintTransaction(trans Transaction) {
fmt.Println("--------------------")
fmt.Println("Printing transaction")
fmt.Println("The id is ", trans.Id)
fmt.Println("The sender is ", trans.Sender)
fmt.Println("The receiver is ", trans.Receiver)
fmt.Println("The amount is ", trans.Amount)
fmt.Println("--------------------")
}
func ListAllTransactions(db Database) {
for i, transaction := range db {
fmt.Println("***********INDEX N=,", i, "****************")
PrintTransaction(transaction)
fmt.Println("***********************************")
}
}
func PrintNeighbors(neighbors []Neighbors) {
fmt.Println("Printing neighbors")
for i, neighbor := range neighbors {
fmt.Println("***********INDEX N=,", i, "****************")
fmt.Println("The id is ", neighbor.ID)
fmt.Println("The address is ", neighbor.Address)
fmt.Println("The port is ", neighbor.Port)
fmt.Println("***********************************")
}
}
func PrintConfig(config Config) {
fmt.Println("Printing config")
fmt.Println("The id is ", config.ID)
fmt.Println("The address is ", config.Address)
fmt.Println("The port is ", config.Port)
PrintNeighbors(config.Neighbours)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment