|
@@ -97,7 +97,7 @@ func GetTweets(pirQuery []byte, dataLength int, whereFrom int, pubKey [32]byte)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return tweetsToByteArray(tweetsToReturn, whereFrom, wantedTopics)
|
|
|
+ return tweetsToByteArray(tweetsToReturn, whereFrom, wantedTopics, dataLength)
|
|
|
}
|
|
|
|
|
|
func getNamesForTopics(wantedIndices []byte, whereFrom int) []string {
|
|
@@ -118,9 +118,10 @@ func getNamesForTopics(wantedIndices []byte, whereFrom int) []string {
|
|
|
}
|
|
|
|
|
|
//transform struct to byte array for sending
|
|
|
-func tweetsToByteArray(tweetsToReturn [][]Tweet, whereFrom int, wantedTopics []string) []byte {
|
|
|
- //50 is an estimated nr that works, there probably is a smarter way to do this
|
|
|
- minimumBlockSize := 50 * maxTweetAmount(whereFrom)
|
|
|
+func tweetsToByteArray(tweetsToReturn [][]Tweet, whereFrom int, wantedTopics []string, dataLength int) []byte {
|
|
|
+ //factor is an estimated nr that works, there probably is a smarter way to do this
|
|
|
+ factor := 0.4
|
|
|
+ minimumBlockSize := int(factor * float64(dataLength*maxLength(whereFrom)))
|
|
|
|
|
|
tweetsAsBytes := make([]byte, minimumBlockSize)
|
|
|
for _, block := range tweetsToReturn {
|
|
@@ -172,7 +173,7 @@ func tweetsToByteArray(tweetsToReturn [][]Tweet, whereFrom int, wantedTopics []s
|
|
|
return tweetsAsBytes
|
|
|
}
|
|
|
|
|
|
-func maxTweetAmount(whereFrom int) int {
|
|
|
+func maxLength(whereFrom int) int {
|
|
|
tmpdb := dbR
|
|
|
if whereFrom == 1 {
|
|
|
tmpdb = archive
|