Browse Source

various bugfixes

Simon 2 years ago
parent
commit
d0b0cd0182
4 changed files with 136 additions and 80 deletions
  1. 64 50
      client/client.go
  2. 18 6
      follower/follower.go
  3. 37 8
      leader/leader.go
  4. 17 16
      lib/databaseRead.go

+ 64 - 50
client/client.go

@@ -40,15 +40,15 @@ type tweet struct {
 const leader string = "127.0.0.1:4441"
 
 //needs to be changed at leader/follower/client at the same time
-const neededSubscriptions = 1
-const numClients = 1
+const numClients = 50
 const dataLength int = 128
 const numThreads int = 12
 
-var dbWriteSize int = 100
+var dbWriteSize int
 var round int
 var topicList []string
 var archiveTopicList []string
+var neededSubscriptions int
 
 //todo! expand this for multiple clients
 var archiveInterests = make([]int, 1)
@@ -58,8 +58,8 @@ var wantsArchive = make([]byte, 1)
 
 var leaderPublicKey *[32]byte
 var followerPublicKey *[32]byte
-var clientPrivateKey *[32]byte
-var clientPublicKey *[32]byte
+var clientPrivateKey [numClients]*[32]byte
+var clientPublicKey [numClients]*[32]byte
 
 func main() {
 	wg := &sync.WaitGroup{}
@@ -77,8 +77,8 @@ func client(clientNumber int) {
 	if err != nil {
 		panic(err)
 	}
-	clientPrivateKey = generatedPrivateKey
-	clientPublicKey = generatedPublicKey
+	clientPrivateKey[clientNumber] = generatedPrivateKey
+	clientPublicKey[clientNumber] = generatedPublicKey
 
 	C.initializeCipher()
 
@@ -112,7 +112,10 @@ func client(clientNumber int) {
 	followerPublicKey = &tmpFollowerPubKey
 
 	//sends own public key
-	writeTo(leaderConn, clientPublicKey[:])
+	writeTo(leaderConn, clientPublicKey[clientNumber][:])
+
+	neededSubscriptionsBytes := readFrom(leaderConn, 4)
+	neededSubscriptions = byteToInt(neededSubscriptionsBytes)
 
 	//setup ends above
 	//while client is active he is always connected and has to participate
@@ -121,7 +124,7 @@ func client(clientNumber int) {
 		//gets current phase
 		phase := readFrom(leaderConn, 1)
 
-		fmt.Println("Phase ", phase[0])
+		//fmt.Println("Phase ", phase[0])
 
 		if phase[0] == 1 {
 
@@ -168,7 +171,7 @@ func client(clientNumber int) {
 			if err != nil {
 				panic("couldn't get randomness for nonce!")
 			}
-			dpfQueryAEncrypted := box.Seal(nonce[:], queryAPlaintext, &nonce, leaderPublicKey, clientPrivateKey)
+			dpfQueryAEncrypted := box.Seal(nonce[:], queryAPlaintext, &nonce, leaderPublicKey, clientPrivateKey[clientNumber])
 
 			//encrypts queryB and appends it to message
 			queryBPlaintext := C.GoBytes(unsafe.Pointer(dpfQueryB), C.int(intQuerySize))
@@ -178,7 +181,7 @@ func client(clientNumber int) {
 			if err != nil {
 				panic("couldn't get randomness for nonce!")
 			}
-			dpfQueryBEncrypted := box.Seal(nonce[:], queryBPlaintext, &nonce, followerPublicKey, clientPrivateKey)
+			dpfQueryBEncrypted := box.Seal(nonce[:], queryBPlaintext, &nonce, followerPublicKey, clientPrivateKey[clientNumber])
 
 			//writes the dpfQuery to the leader
 			dpfLengthBytes := intToByte(len(dpfQueryAEncrypted))
@@ -250,19 +253,21 @@ func client(clientNumber int) {
 //creates and sends the pirQuerys for each server
 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] = 1
-
+	topicsOFInterest := make([]int, 10)
+	topicsOFInterest[0] = 1
+	topicsOFInterest[1] = 1
+	topicsOFInterest[9] = 1
 	archiveInterests[0] = 1
 
-	tmptopicsOfInterest := make([]int, len(topicsOfInterest))
-	copy(tmptopicsOfInterest, topicsOfInterest)
-
+	//todo! repeat for archive
 	tmpNeededSubscriptions := neededSubscriptions
 	if tmpNeededSubscriptions > len(topicList) {
 		tmpNeededSubscriptions = len(topicList)
 	}
 
+	tmptopicsOfInterest := make([]int, len(topicList))
+	copy(tmptopicsOfInterest, topicsOFInterest)
+
 	tmpTopicList := make([]string, len(topicList))
 	copy(tmpTopicList, topicList)
 	if wantsArchive[0] == 1 && subPhase == -1 {
@@ -274,26 +279,15 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
 		copy(tmpTopicList, archiveTopicList)
 	}
 
-	topicsOfInterestAsBytes := make([][]byte, tmpNeededSubscriptions)
-	for i := range topicsOfInterestAsBytes {
-		topicsOfInterestAsBytes[i] = make([]byte, len(tmpTopicList))
-	}
-
 	//creates fake topicsOfInterest if client is boooring
 	if len(tmptopicsOfInterest) < tmpNeededSubscriptions && subPhase != -1 {
 		tmptopicsOfInterest = addFakeInterests(len(tmpTopicList), tmptopicsOfInterest, false)
 	}
 
-	for topic, position := range tmptopicsOfInterest {
-		if position > 0 {
-			topicsOfInterestAsBytes[topic][position-1] = 1
-		}
-	}
-
-	//pirQuery [serverAmount][topicsofinterest][topicAmount]byte
-	pirQuerys := make([][][]byte, 2)
+	//pirQuery [topicsofinterest][serverAmount][topicAmount]byte
+	pirQuerys := make([][][]byte, len(tmptopicsOfInterest))
 	for i := range pirQuerys {
-		pirQuerys[i] = make([][]byte, len(tmptopicsOfInterest))
+		pirQuerys[i] = make([][]byte, 2)
 		for j := range pirQuerys[i] {
 			pirQuerys[i][j] = make([]byte, len(tmpTopicList))
 		}
@@ -307,19 +301,33 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
 			if err != nil {
 				panic(err)
 			}
-			pirQuerys[0][topic][index] = byte(bit.Int64())
+			pirQuerys[topic][0][index] = byte(bit.Int64())
+		}
+	}
+
+	tmptopicsOfInterestBytes := make([]byte, tmpNeededSubscriptions)
+	for index := range tmptopicsOfInterestBytes {
+		if tmptopicsOfInterest[index] == 1 {
+			tmptopicsOfInterestBytes[index] = 1
 		}
 	}
 
-	//creating last manually with result and wanted
-	//if position random result correct -> 0, not correct -> 1
 	for topic := range tmptopicsOfInterest {
 		for index := range tmpTopicList {
-			if pirQuerys[0][topic][index] == topicsOfInterestAsBytes[topic][index] {
-				pirQuerys[1][topic][index] = 0
+			if topic == index {
+				if pirQuerys[topic][0][index] == 1 {
+					pirQuerys[topic][1][index] = 0
+				} else {
+					pirQuerys[topic][1][index] = 1
+				}
 			} else {
-				pirQuerys[1][topic][index] = 1
+				if pirQuerys[topic][0][index] == 0 {
+					pirQuerys[topic][1][index] = 0
+				} else {
+					pirQuerys[topic][1][index] = 1
+				}
 			}
+
 		}
 	}
 
@@ -332,9 +340,9 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
 		}
 	}
 
-	for server := 0; server < 2; server++ {
-		for topic := range pirQuerys[server] {
-			messagesFlattened[server] = append(messagesFlattened[server], pirQuerys[server][topic][:]...)
+	for server := range messagesFlattened {
+		for topic := range pirQuerys {
+			messagesFlattened[server] = append(messagesFlattened[server], pirQuerys[topic][server]...)
 		}
 	}
 
@@ -343,13 +351,13 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
 	if err != nil {
 		panic("couldn't get randomness for nonce!")
 	}
-	encryptedQueryLeader := box.Seal(nonce[:], messagesFlattened[0], &nonce, leaderPublicKey, clientPrivateKey)
+	encryptedQueryLeader := box.Seal(nonce[:], messagesFlattened[0], &nonce, leaderPublicKey, clientPrivateKey[clientNumber])
 
 	_, err = rand.Read(nonce[:])
 	if err != nil {
 		panic("couldn't get randomness for nonce!")
 	}
-	encryptedQueryFollower := box.Seal(nonce[:], messagesFlattened[1], &nonce, followerPublicKey, clientPrivateKey)
+	encryptedQueryFollower := box.Seal(nonce[:], messagesFlattened[1], &nonce, followerPublicKey, clientPrivateKey[clientNumber])
 
 	return encryptedQueryLeader, encryptedQueryFollower
 }
@@ -402,6 +410,8 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
 
 		tweets := readFrom(leaderConn, tweetsLength)
 
+		//fmt.Println(tweets[:10])
+
 		//expand sharedSecret so it is of right length
 		expandBy := len(tweets) / 32
 		expandedSharedSecrets := make([][]byte, 2)
@@ -420,9 +430,11 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
 		index := strings.Index(string(tweets), ";;;")
 		if index != -1 {
 			text := string(tweets)[:index]
-			fmt.Println("received in round", round, "Text", text)
+			fmt.Println("received in round", round, "Text", text, len(tweets))
 		} else {
-			fmt.Println("received text not of correct format", round, "Text:", string(tweets))
+			fmt.Println("Round", round, "Text:", string(tweets))
+			fmt.Println("länge", byteToInt(tweetsLengthBytes))
+			panic("received text not of correct format")
 		}
 	}
 }
@@ -478,13 +490,13 @@ func createAuditPIRQuery(clientNumber int) ([]byte, []byte) {
 	if err != nil {
 		panic("couldn't get randomness for nonce!")
 	}
-	encryptedQueryLeader := box.Seal(nonce[:], messagesFlattened[0], &nonce, leaderPublicKey, clientPrivateKey)
+	encryptedQueryLeader := box.Seal(nonce[:], messagesFlattened[0], &nonce, leaderPublicKey, clientPrivateKey[clientNumber])
 
 	_, err = rand.Read(nonce[:])
 	if err != nil {
 		panic("couldn't get randomness for nonce!")
 	}
-	encryptedQueryFollower := box.Seal(nonce[:], messagesFlattened[1], &nonce, followerPublicKey, clientPrivateKey)
+	encryptedQueryFollower := box.Seal(nonce[:], messagesFlattened[1], &nonce, followerPublicKey, clientPrivateKey[clientNumber])
 
 	return encryptedQueryLeader, encryptedQueryFollower
 }
@@ -562,7 +574,7 @@ func getTweet(clientNumber int) []byte {
 
 	r := mr.New(mr.NewSource(time.Now().UnixNano()))
 
-	maxTopics := r.Intn(4)
+	maxTopics := r.Intn(6)
 	if maxTopics == 0 {
 		maxTopics = 1
 	}
@@ -581,8 +593,7 @@ func getTweet(clientNumber int) []byte {
 	}
 
 	sort.Ints(topicNumbers)
-	fmt.Println("Writing to", topicNumbers)
-
+	//fmt.Println("topicNumbers", topicNumbers)
 	var topics []byte
 
 	topicIndex := 0
@@ -597,11 +608,13 @@ func getTweet(clientNumber int) []byte {
 
 	topics = append(topics, []byte(";")[0])
 
-	text := []byte("I am a house in a mouse " + strconv.Itoa(r.Intn(10000)) + ";")
+	text := []byte(strconv.Itoa(r.Intn(10000)) + ";")
 	tweet = append(tweet, topics...)
 	tweet = append(tweet, text...)
 	tweet = append(tweet, []byte(";")[0])
 
+	//fmt.Println("writing", string(text))
+
 	//adds padding
 	length := dataLength - len(tweet)
 	padding := make([]byte, length)
@@ -626,6 +639,7 @@ func readFrom(connection net.Conn, size int) []byte {
 	if err != nil {
 		panic(err)
 	}
+
 	return array
 }
 

+ 18 - 6
follower/follower.go

@@ -47,12 +47,13 @@ var followerPublicKey *[32]byte
 var leaderPublicKey *[32]byte
 
 //needs to be changed at leader/follower/client at the same time
-const neededSubscriptions = 1
 const dataLength = 128
 const numThreads = 12
 
-var dbWriteSize int = 100
-var maxTimePerRound time.Duration = 5 * time.Second
+var dbWriteSize int = 10
+var neededSubscriptions int
+
+var maxTimePerRound time.Duration = 1000 * time.Millisecond
 
 var round int = 0
 var startTime time.Time
@@ -136,6 +137,9 @@ func main() {
 		panic(err)
 	}
 
+	neededSubscriptionsBytes := readFrom(leaderConnection, 4)
+	neededSubscriptions = byteToInt(neededSubscriptionsBytes)
+
 	leaderPublicKey = &tmpLeaderPubKey
 
 	//setup ends here
@@ -173,7 +177,7 @@ func main() {
 		}
 		wg.Wait()
 
-		fmt.Println("Phase 2")
+		//Phase 2
 		leaderConnection, err := lnLeader.Accept()
 		if err != nil {
 			panic(err)
@@ -182,7 +186,7 @@ func main() {
 
 		phase2(leaderConnection)
 
-		fmt.Println("Phase 3")
+		//Phase 3
 
 		if round == 1 {
 			//addTestTweets()
@@ -394,7 +398,7 @@ func phase2(leaderWorkerConnection net.Conn) {
 	var tweets []lib.Tweet
 	for i := 0; i < dbSize; i++ {
 		//discard cover message
-		if tmpdb[i][0] == 0 {
+		if tmpdb[i][1] == 0 {
 			continue
 		} else if -1 == strings.Index(string(tmpdb[i]), ";;") {
 			continue
@@ -525,7 +529,11 @@ func phase3(leaderWorkerConnection net.Conn, wg *sync.WaitGroup, m *sync.RWMutex
 
 //gets tweet from db and sends them to leader
 func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, leaderWorkerConnection net.Conn) {
+	//todo! repeat for archive
 	tmpNeededSubscriptions := neededSubscriptions
+	if tmpNeededSubscriptions > topicAmount {
+		tmpNeededSubscriptions = topicAmount
+	}
 	if archiveQuerys != nil {
 		tmpNeededSubscriptions = len(archiveQuerys)
 	}
@@ -617,7 +625,11 @@ func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subP
 	//follower expects pirQuery
 
 	//transforms byteArray to ints of wanted topics
+	//todo! repeat for archive
 	tmpNeededSubscriptions := neededSubscriptions
+	if tmpNeededSubscriptions > topicAmount {
+		tmpNeededSubscriptions = topicAmount
+	}
 	tmpTopicAmount := topicAmount
 	if subPhase == -1 {
 		tmpNeededSubscriptions = byteToInt(archiveNeededSubscriptions)

+ 37 - 8
leader/leader.go

@@ -59,12 +59,15 @@ var archiveTopicAmount int
 
 // every roundsBeforeUpdate the client updates his pirQuery
 const roundsBeforeUpdate = 1
-const neededSubscriptions = 1
+const neededSubscriptions = 10
 const numThreads = 12
 const dataLength = 128
 
-var dbWriteSize int = 100
-var maxTimePerRound time.Duration = 5 * time.Second
+var dbWriteSize int = 10
+
+const minDBWriteSize int = 10
+
+var maxTimePerRound time.Duration = 1000 * time.Millisecond
 
 //counts the number of rounds
 var round int = 0
@@ -118,6 +121,8 @@ func main() {
 	//send publicKey to follower
 	writeTo(followerConnection, leaderPublicKey[:])
 
+	writeTo(followerConnection, intToByte(neededSubscriptions))
+
 	//goroutine for accepting new clients
 	go func() {
 		leaderConnectionPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
@@ -206,6 +211,13 @@ func main() {
 				break
 			}
 
+			_, err = clientConnection.Write(intToByte(neededSubscriptions))
+			if err != nil {
+				fmt.Println("error", err)
+				clientConnection.Close()
+				break
+			}
+
 			clientPublicKey = &tmpClientPublicKey
 
 			//this is the key for map(client data)
@@ -264,7 +276,7 @@ func main() {
 
 		wg.Wait()
 
-		fmt.Println("Phase 2")
+		//Phase 2
 
 		followerConnection, err := tls.Dial("tcp", follower, conf)
 		if err != nil {
@@ -274,7 +286,7 @@ func main() {
 
 		phase2(followerConnection)
 
-		fmt.Println("Phase 3")
+		//Phase 3
 
 		//no tweets -> continue to phase 1 and mb get tweets
 		topicList, topicAmount = lib.GetTopicList(0)
@@ -588,7 +600,7 @@ func phase2(followerConnection net.Conn) {
 	var currentPublisherAmount int = 0
 	for i := 0; i < dbSize; i++ {
 		//discard cover message
-		if tmpdb[i][0] == 0 {
+		if tmpdb[i][1] == 0 {
 			continue
 		} else if -1 == strings.Index(string(tmpdb[i]), ";;") {
 			continue
@@ -653,8 +665,8 @@ func phase2(followerConnection net.Conn) {
 	//calculates the dbWriteSize for this round
 	dbWriteSize = int(math.Ceil(19.5 * float64(publisherAverage)))
 
-	if dbWriteSize < 100 {
-		dbWriteSize = 100
+	if dbWriteSize < minDBWriteSize {
+		dbWriteSize = minDBWriteSize
 	}
 
 	//writes dbWriteSize of current round to follower
@@ -957,10 +969,16 @@ func getSendVirtualAddress(pirQuery []byte, virtualAddresses []int, sharedSecret
 }
 
 func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, clientConnection, followerConnection net.Conn) bool {
+	//todo! repeat for archive
 	tmpNeededSubscriptions := neededSubscriptions
+	if tmpNeededSubscriptions > topicAmount {
+		tmpNeededSubscriptions = topicAmount
+	}
 	if archiveQuerys != nil {
 		tmpNeededSubscriptions = len(archiveQuerys)
 	}
+	//fmt.Println("tmpNeededSubscriptions", tmpNeededSubscriptions)
+
 	tweets := make([][]byte, tmpNeededSubscriptions)
 	for i := 0; i < tmpNeededSubscriptions; i++ {
 		//gets all requested tweets
@@ -980,6 +998,8 @@ func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, clientConnecti
 		//Xor's sharedSecret with all tweets
 		lib.Xor(expandedSharedSecret[:], tweets[i])
 
+		//fmt.Println(tweets[0])
+
 		//receives tweets from follower and Xor's them in
 		tweetsLengthBytes, _ := readFrom(followerConnection, 4, nil, 0)
 
@@ -990,6 +1010,8 @@ func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, clientConnecti
 		lib.Xor(receivedTweets, tweets[i])
 	}
 
+	//fmt.Println("Bytes", tweets[0][:10])
+
 	//sends tweets to client
 	for i := 0; i < tmpNeededSubscriptions; i++ {
 		tweetsLengthBytes := intToByte(len(tweets[i]))
@@ -998,6 +1020,7 @@ func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, clientConnecti
 			return true
 		}
 		errorBool = writeToWError(clientConnection, tweets[i], followerConnection, 2)
+
 		if errorBool {
 			return true
 		}
@@ -1028,7 +1051,12 @@ func handlePirQuery(clientKeys clientKeys, clientConnection net.Conn, followerCo
 		return clientKeys, nil, true
 	}
 
+	//todo! repeat for archive
 	tmpNeededSubscriptions := neededSubscriptions
+	if tmpNeededSubscriptions > topicAmount {
+		tmpNeededSubscriptions = topicAmount
+	}
+
 	tmpTopicAmount := topicAmount
 	if subPhase == -1 {
 		archiveNeededSubscriptions, errorBool := readFrom(clientConnection, 4, followerConnection, 5)
@@ -1040,6 +1068,7 @@ func handlePirQuery(clientKeys clientKeys, clientConnection net.Conn, followerCo
 		tmpNeededSubscriptions = byteToInt(archiveNeededSubscriptions)
 		tmpTopicAmount = archiveTopicAmount
 	}
+
 	if doAuditing {
 		tmpNeededSubscriptions = 1
 		tmpTopicAmount = dbWriteSize

+ 17 - 16
lib/databaseRead.go

@@ -2,9 +2,7 @@ package lib
 
 import (
 	"bytes"
-	"crypto/rand"
 	"encoding/json"
-	"fmt"
 )
 
 //topicPointer and textPointer should not be exported
@@ -24,7 +22,7 @@ var archive = make(map[string][]Tweet)
 //has to be dividable by 32
 var minimumBlockSize int
 
-const roundsBeforeArchiving = 300
+var roundsBeforeArchiving = 3
 
 var topicList []string
 
@@ -38,6 +36,7 @@ func NewEntries(inputTweets []Tweet, whereTo int) {
 	var position int = 0
 	for _, tweet := range inputTweets {
 		for index := range tweet.Topics {
+			//fmt.Println("topic to put in", tweet.Topics[index])
 			//new topic
 			if _, ok := tmpdb[tweet.Topics[index]]; !ok {
 				if whereTo == 0 {
@@ -72,15 +71,12 @@ func NewEntries(inputTweets []Tweet, whereTo int) {
 
 //todo! add round to pirquery only get tweets that have been posted from that round onward
 func GetTweets(pirQuery []byte, dataLength int, whereFrom int) []byte {
-	fmt.Println("pirQuery", pirQuery)
-	fmt.Println(dbR)
 	tmpdb := dbR
 	if whereFrom == 1 {
 		tmpdb = archive
 	}
 	minimumBlockSize = dataLength * maxTweetAmount(whereFrom)
 	var wantedTopics = getNamesForTopics(pirQuery, whereFrom)
-	fmt.Println("topicNames", wantedTopics)
 	tweetsToReturn := make([][]Tweet, len(wantedTopics))
 	for index, wantedTopic := range wantedTopics {
 		for _, tweet := range tmpdb[wantedTopic] {
@@ -91,6 +87,7 @@ func GetTweets(pirQuery []byte, dataLength int, whereFrom int) []byte {
 			} else {
 				//"copied" tweet
 				//find tweet with pointers
+				//fmt.Println(tweet)
 				tweet = tmpdb[tweet.TopicPointer][tweet.TextPointer]
 				tweet.RoundPosted = 0
 				tweetsToReturn[index] = append(tweetsToReturn[index], tweet)
@@ -98,12 +95,6 @@ func GetTweets(pirQuery []byte, dataLength int, whereFrom int) []byte {
 		}
 	}
 
-	for _, row := range tweetsToReturn {
-		for _, tweet := range row {
-			fmt.Print(tweet.Text)
-		}
-		fmt.Println("")
-	}
 	return tweetsToByteArray(tweetsToReturn)
 }
 
@@ -155,10 +146,17 @@ func tweetsToByteArray(tweetsToReturn [][]Tweet) []byte {
 		//adds padding
 		tweetToAppend = append(tweetToAppend, []byte(";;")[:]...)
 		length := minimumBlockSize - len(tweetToAppend)
-		padding := make([]byte, length)
-		rand.Read(padding)
+		//todo! replace with grouping
+		padding := bytes.Repeat([]byte(";"), length)
 		tweetToAppend = append(tweetToAppend, padding...)
-		Xor(tweetToAppend, tweetsAsBytes)
+		//Xor(tweetToAppend, tweetsAsBytes)
+
+		for index := range tweetToAppend {
+			tweetsAsBytes[index] = tweetsAsBytes[index] ^ tweetToAppend[index]
+		}
+
+		//fmt.Println(tweetsAsBytes)
+
 	}
 
 	return tweetsAsBytes
@@ -180,8 +178,11 @@ func GetTopicList(whereFrom int) ([]byte, int) {
 
 //iterates through full dbR and moves old tweets to archive
 func CleanUpdbR(round int) {
+	//is broken
+	return
 
-	if roundsBeforeArchiving%round == 0 {
+	if roundsBeforeArchiving-round == 0 {
+		roundsBeforeArchiving = roundsBeforeArchiving + roundsBeforeArchiving
 		var tweetsToArchive []Tweet
 		for j := range dbR {
 			tweets := dbR[j]