Skip to content

Commit

Permalink
Reworked folder structure: PoM is now in Gossip package.
Browse files Browse the repository at this point in the history
  • Loading branch information
tfn18001 committed Apr 19, 2022
1 parent 0b2ab60 commit e93c13f
Show file tree
Hide file tree
Showing 19 changed files with 611 additions and 543 deletions.
170 changes: 0 additions & 170 deletions CTng/HTTP/types.go

This file was deleted.

16 changes: 8 additions & 8 deletions CTng/ctng.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package main

import (
server "CTng/HTTP"
"CTng/POM"
"CTng/config"
"CTng/gossip"
"CTng/monitor"
"CTng/server"
fakeLogger "CTng/testData/fakeLogger"
"fmt"
"os"
Expand All @@ -26,32 +26,32 @@ func main() {
}
storage := new(gossip.Gossip_Storage)
*storage = make(gossip.Gossip_Storage)
accusationdb := new(POM.AccusationDB)
*accusationdb = make(POM.AccusationDB)
accusationdb := new(gossip.AccusationDB)
*accusationdb = make(gossip.AccusationDB)

ctx := server.GossiperContext{
ctx := gossip.GossiperContext{
Config: &conf,
Storage: storage,
Accusations: accusationdb,
StorageFile: "gossiper_data.json", // could be a parameter in the future.
HasPom: make(map[string]bool),
}
ctx.Config = &conf
server.StartGossiper(&ctx)
server.StartGossiperServer(&ctx)
// break // break unneeded in go.
case "monitor":
conf, err := config.LoadMonitorConfig(os.Args[2], os.Args[3], os.Args[4])
if err != nil {
fmt.Println(helpText)
panic(err)
}
ctx := server.MonitorContext{
ctx := monitor.MonitorContext{
Config: &conf,
Storage: new(gossip.Gossip_Storage),
StorageFile: "monitor_data.json",
}
ctx.Config = &conf
server.StartMonitor(&ctx)
server.StartMonitorServer(&ctx)
case "logger":
fakeLogger.RunLogger(os.Args[2])
default:
Expand Down
46 changes: 46 additions & 0 deletions CTng/gossip/PoM_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package gossip

// import (
// "CTng/crypto"
// "testing"
// )

// func TestAccusationUpdates(t *testing.T) {
// println("test start\n")
// var accs AccusationDB
// var cp1 Accusation
// var cp2 Accusation
// var cp3 Accusation
// var cp4 Accusation
// cp1.Accuser = "monitor_01_DNS_place_holder"
// cp1.Entity_URL = "logger_01_DNS_place_holder"
// cp1.Partial_sig = crypto.SigFragment{}
// cp2.Accuser = "monitor_02_DNS_place_holder"
// cp2.Entity_URL = "logger_02_DNS_place_holder"
// cp2.Partial_sig = crypto.SigFragment{}
// cp3.Accuser = "monitor_01_DNS_place_holder"
// cp3.Entity_URL = "logger_02_DNS_place_holder"
// cp3.Partial_sig = crypto.SigFragment{}
// cp4.Accuser = "monitor_02_DNS_place_holder"
// cp4.Entity_URL = "logger_01_DNS_place_holder"
// cp4.Partial_sig = crypto.SigFragment{}
// println("data structures initialized")
// accs = Process_Accusation(cp1, accs)
// accs = Process_Accusation(cp1, accs)
// accs = Process_Accusation(cp2, accs)
// accs = Process_Accusation(cp3, accs)
// println("Accsuation processing went through")
// println("_______________________________________")
// println("start listing accused entities and the number of accusations")
// for i := 0; i < len(accs); i++ {
// println("\nThe accused entity DNS is: ", accs[i].Entity_URL)
// println("The total number of accusations is", accs[i].Num_acc)
// for j := 0; j < len(accs[i].Accusers); j++ {
// print("Accusers No.", j+1, "is ")
// println(accs[i].Accusers[j])
// // print("Partial sigature No.", j+1, "is ")
// // println(accs[i].Partial_sigs[j])
// }
// }

// }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package POM
package gossip

import (
"CTng/crypto"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
package POM
package gossip

import (
"CTng/crypto"
"CTng/gossip"
"errors"
"fmt"
)

type EntityAccusations struct {
Accusers []string
Entity_URL string
Num_acc int
Partial_sigs []crypto.SigFragment
PoM_status bool
}
type AccusationDB map[string]*EntityAccusations

func Process_Accusation(new_acc gossip.Gossip_object, accs *AccusationDB, c *crypto.CryptoConfig) (*gossip.Gossip_object, bool, error) {
func Process_Accusation(new_acc Gossip_object, accs *AccusationDB, c *crypto.CryptoConfig) (*Gossip_object, bool, error) {
// Convert signature string
p_sig, err := crypto.SigFragmentFromString(new_acc.Signature[0])
if err != nil {
Expand Down Expand Up @@ -57,13 +47,13 @@ func Process_Accusation(new_acc gossip.Gossip_object, accs *AccusationDB, c *cry
fmt.Println(converr)
}
val.PoM_status = true
gossip_obj := new(gossip.Gossip_object)
*gossip_obj = gossip.Gossip_object{}
gossip_obj := new(Gossip_object)
*gossip_obj = Gossip_object{}
gossip_obj.Application = "Ctng"
gossip_obj.Type = gossip.GOSSIP_POM
gossip_obj.Type = GOSSIP_POM
// gossip_obj.Signer Signers are contained within the signature.
gossip_obj.Signature[0] = sig_string
gossip_obj.Timestamp = gossip.GetCurrentTimestamp()
gossip_obj.Timestamp = GetCurrentTimestamp()
gossip_obj.Payload[0] = acc_pom.Entity_URL
return gossip_obj, true, nil
}
Expand Down
Loading

0 comments on commit e93c13f

Please sign in to comment.