less writers
This commit is contained in:
parent
23600524a5
commit
22797a36d1
|
@ -5,7 +5,6 @@ package yanic
|
||||||
*/
|
*/
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
|
||||||
"compress/flate"
|
"compress/flate"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
|
@ -55,8 +54,8 @@ func (conn *Connection) InsertNode(node *runtime.Node) {
|
||||||
Statistics: node.Statistics,
|
Statistics: node.Statistics,
|
||||||
Neighbours: node.Neighbours,
|
Neighbours: node.Neighbours,
|
||||||
}
|
}
|
||||||
var b bytes.Buffer
|
|
||||||
writer := bufio.NewWriter(&b)
|
writer := bufio.NewWriterSize(conn.conn, 8192)
|
||||||
|
|
||||||
flater, err := flate.NewWriter(writer, flate.BestCompression)
|
flater, err := flate.NewWriter(writer, flate.BestCompression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -70,13 +69,17 @@ func (conn *Connection) InsertNode(node *runtime.Node) {
|
||||||
if node.Nodeinfo != nil && node.Nodeinfo.NodeID != "" {
|
if node.Nodeinfo != nil && node.Nodeinfo.NodeID != "" {
|
||||||
nodeid = node.Nodeinfo.NodeID
|
nodeid = node.Nodeinfo.NodeID
|
||||||
}
|
}
|
||||||
log.Printf("[database-yanic] could not send %s node: %s", nodeid, err)
|
log.Printf("[database-yanic] could not encode %s node: %s", nodeid, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
flater.Flush()
|
err = flater.Flush()
|
||||||
writer.Flush()
|
if err != nil {
|
||||||
conn.conn.Write(b.Bytes())
|
log.Printf("[database-yanic] could not compress: %s", err)
|
||||||
|
}
|
||||||
|
err = writer.Flush()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[database-yanic] could not send: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *Connection) InsertLink(link *runtime.Link, time time.Time) {
|
func (conn *Connection) InsertLink(link *runtime.Link, time time.Time) {
|
||||||
|
|
Loading…
Reference in New Issue