Skip to content

Commit

Permalink
simplify the type
Browse files Browse the repository at this point in the history
  • Loading branch information
jie committed Nov 10, 2023
1 parent 62940d8 commit 7dc91b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 15 additions & 5 deletions gossiper/gossiper_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ func Gossip_notification_handler(c *GossiperContext, w http.ResponseWriter, r *h
c.Counter1_lock.Lock()
c.Total_traffic_received += int(bytecount)
c.Counter1_lock.Unlock()
var newID definition.Gossip_ID
newID.Period = notification.Period
newID.Type = notification.Type
newID.Entity_URL = notification.Entity_URL
//fmt.Println(util.BLUE+"Received notification from "+notification.Sender+".", util.RESET)
if c.SearchPayload(notification.GossipID) == false {
if c.SearchPayload(newID) == false {
notification.Sender = c.Gossiper_crypto_config.SelfID.String()
msg, _ := json.Marshal(notification)
c.Counter2_lock.Lock()
Expand Down Expand Up @@ -100,10 +104,13 @@ func Gossip_request_handler(c *GossiperContext, w http.ResponseWriter, r *http.R
c.Counter1_lock.Lock()
c.Total_traffic_received += int(bytecount)
c.Counter1_lock.Unlock()
gid := notification.GossipID
obj := c.GetObject(gid, definition.REV_INIT)
var newID definition.Gossip_ID
newID.Period = notification.Period
newID.Type = notification.Type
newID.Entity_URL = notification.Entity_URL
obj := c.GetObject(newID, definition.REV_INIT)
fmt.Println(notification)
fmt.Println(gid)
fmt.Println(newID)
fmt.Println(obj.Payload)
if obj.Payload[0] != "" {
dstendpoint := "/gossip/rev_init"
Expand Down Expand Up @@ -444,8 +451,11 @@ func Send_obj_to_Gossipers(c *GossiperContext, gossip_obj definition.Gossip_obje
if bytecount > c.Optimization_threshold && (gossip_obj.Type == definition.REV_INIT) {
//fmt.Println("Optimization threshold reached")
var notification Gossip_Notification
notification.GossipID = gossip_obj.GetID()
GID := gossip_obj.GetID()
notification.Sender = c.Gossiper_crypto_config.SelfID.String()
notification.Period = GID.Period
notification.Type = GID.Type
notification.Entity_URL = GID.Entity_URL
fmt.Println(notification)
msg, _ := json.Marshal(notification)
bytecount = len(msg)
Expand Down
6 changes: 4 additions & 2 deletions gossiper/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ type Gossiper_log_entry struct {
}

type Gossip_Notification struct {
Sender string
GossipID definition.Gossip_ID
Sender string
Period string
Type string
Entity_URL string
}

type Gossiper_log map[int]Gossiper_log_entry
Expand Down

0 comments on commit 7dc91b7

Please sign in to comment.