summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlQueries.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/sqlQueries.go b/sqlQueries.go
index f9003a4..efaffba 100644
--- a/sqlQueries.go
+++ b/sqlQueries.go
@@ -187,7 +187,10 @@ func removeASNIP(db *sql.DB, asn int, ipBlock string) error {
// database that is older than t and haven't had
// differential privacy added to them yet.
func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
- query, err := db.Prepare("SELECT ipb_src,ipb_dst,as_src,as_dst,port_src,port_dst,volume,time,occurences FROM clean_data WHERE time_added < ? FOR UPDATE")
+ if conf.Epsilon <= 0 {
+ return
+ }
+ query, err := db.Prepare("SELECT ipb_src,ipb_dst,as_src,as_dst,port_src,port_dst,volume,time_added,occurences FROM clean_data WHERE time_added < ?")
if err != nil {
log.Println("Failed to prepare query")
return
@@ -198,6 +201,7 @@ func privatizeCleaned(db *sql.DB, t time.Time, conf Config) (err error) {
log.Println("Failed to query for unprivitized rows")
return
}
+ defer rows.Close()
update, err := db.Prepare("UPDATE clean_data SET occurences = ? , time_privatized = ? WHERE ipb_src = ? AND ipb_dst = ? AND as_src = ? AND as_dst = ? AND port_src = ? AND port_dst = ? AND volume = ? AND time_added = ? ")
if err != nil {