func (c *PagingC) Store(info *ads.Info) int64 { if info.Token != 0 { return info.Token } buffer := ads.GetFromPool() defer ads.ReturnToPool(buffer) ads.Hash(info.Value) buffer.Reset() e := ads.Encoder{ Writer: buffer, Transparent: map[ads.ADS]bool{info.Value: true}, } e.Encode(&info.Value) for _, root := range ads.CollectChildren(info.Value) { info := ads.GetInfo(root) c.Store(info) var buffer [8]byte binary.LittleEndian.PutUint64(buffer[:], uint64(info.Token)) if n, err := e.Write(buffer[:]); n != 8 || err != nil { log.Panic(err) } } info.Token = c.DB.Write(buffer.Bytes()) return info.Token }
func computeSize(value ads.ADS, trackc *verified.TrackC) int { buffer := ads.GetFromPool() defer ads.ReturnToPool(buffer) buffer.Reset() encoder := &ads.Encoder{ Writer: buffer, Transparent: trackc.Used, } encoder.Encode(&value) return buffer.Len() }