|
@@ -61,12 +61,16 @@ var publisherAmount int
|
|
|
var goodPadding int
|
|
|
var blocksReceived int
|
|
|
var timeBounds []float64
|
|
|
+
|
|
|
+//gui variables
|
|
|
var guiTweet string
|
|
|
+var mainTweets string
|
|
|
+var archiveTweets string
|
|
|
|
|
|
//this translates to a simulated round length of ~2h
|
|
|
var speedUp float64 = 7200 / ((maxTimePerRound.Seconds()) * 3)
|
|
|
|
|
|
-var maxTimePerRound time.Duration = 5 * time.Second
|
|
|
+var maxTimePerRound time.Duration = 2 * time.Second
|
|
|
var startTime int
|
|
|
|
|
|
var archiveInterests = make([]int, 1)
|
|
@@ -274,7 +278,7 @@ func Client(clientNumber int, f *os.File) {
|
|
|
receiveTweets(sharedSecret[clientNumber], leaderConn, false, clientNumber)
|
|
|
|
|
|
if len(archiveTopicList) > 0 {
|
|
|
- wantsArchive[0] = 0
|
|
|
+ wantsArchive[0] = 1
|
|
|
} else {
|
|
|
wantsArchive[0] = 0
|
|
|
}
|
|
@@ -298,8 +302,8 @@ func Client(clientNumber int, f *os.File) {
|
|
|
func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
|
//later this will be taken from gui, this is only for testing
|
|
|
topicsOfInterest := make([]int, 1)
|
|
|
- topicsOfInterest[0] = mr.Intn(10)
|
|
|
- archiveInterests[0] = mr.Intn(10)
|
|
|
+ topicsOfInterest[0] = 0 //mr.Intn(10)
|
|
|
+ archiveInterests[0] = 0 //mr.Intn(10)
|
|
|
|
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
|
if tmpNeededSubscriptions > len(topicList) {
|
|
@@ -471,6 +475,8 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
|
|
|
|
index := strings.Index(string(tweets), ";;")
|
|
|
|
|
|
+ fmt.Println("received", string(tweets))
|
|
|
+
|
|
|
if index != -1 {
|
|
|
|
|
|
textArr := strings.Split(string(tweets), ";;;")
|
|
@@ -485,6 +491,16 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
|
goodPadding++
|
|
|
}
|
|
|
|
|
|
+ if getArchive {
|
|
|
+ if !strings.Contains(archiveTweets, text[0]) {
|
|
|
+ archiveTweets += text[0] + ";"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if !strings.Contains(mainTweets, text[0]) {
|
|
|
+ mainTweets += text[0] + ";"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else if index == -1 && tweets[0] != 0 {
|
|
|
fmt.Println("error")
|
|
|
fmt.Println("round", round, string(tweets), "length", len(tweets))
|
|
@@ -493,6 +509,33 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func GetTweets(whereFrom int) string {
|
|
|
+
|
|
|
+ var tweets string
|
|
|
+
|
|
|
+ var recTweets string
|
|
|
+
|
|
|
+ if whereFrom == 0 {
|
|
|
+ recTweets = mainTweets
|
|
|
+ mainTweets = ""
|
|
|
+ } else {
|
|
|
+ recTweets = archiveTweets
|
|
|
+ archiveTweets = ""
|
|
|
+ fmt.Println("archive", recTweets)
|
|
|
+ }
|
|
|
+
|
|
|
+ tweetArr := strings.Split(recTweets, ";;")
|
|
|
+
|
|
|
+ for _, str := range tweetArr {
|
|
|
+ strArr := strings.Split(str, ";")
|
|
|
+ tweets += "<li>" + strArr[0] + "<br>" + strArr[1] + "</li>"
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("tweetsToPost", tweets)
|
|
|
+
|
|
|
+ return tweets
|
|
|
+}
|
|
|
+
|
|
|
//creates a shared secret for each server
|
|
|
func createSharedSecret() [numClients][2][32]byte {
|
|
|
var tmpSharedSecret [numClients][2][32]byte
|