github.com/simpleiot/simpleiot@v0.18.3/store/hash.go (about) 1 package store 2 3 /* old implementation 4 5 // updateHash updates the hash in all the upstream edges 6 func updateHash(node *data.Node, upEdges []*data.Edge, downEdges []*data.Edge) { 7 // downstream edge hashes are used in the hash calculation, so sort them first 8 sort.Sort(data.ByHash(downEdges)) 9 10 for _, up := range upEdges { 11 h := md5.New() 12 13 for _, p := range up.Points { 14 d := make([]byte, 8) 15 binary.LittleEndian.PutUint64(d, uint64(p.Time.UnixNano())) 16 h.Write(d) 17 } 18 19 for _, p := range node.Points { 20 d := make([]byte, 8) 21 binary.LittleEndian.PutUint64(d, uint64(p.Time.UnixNano())) 22 h.Write(d) 23 } 24 25 for _, downEdge := range downEdges { 26 h.Write(downEdge.Hash) 27 } 28 29 up.Hash = h.Sum(nil) 30 } 31 } 32 33 */