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 (n *BitrieLeaf) Encode(e *ads.Encoder) { var buffer [40]byte copy(buffer[0:32], n.Bits.Bits[0:32]) binary.LittleEndian.PutUint32(buffer[32:36], uint32(n.Bits.Start)) binary.LittleEndian.PutUint32(buffer[36:40], uint32(n.Bits.Length)) e.Write(buffer[0:40]) e.Encode(&n.Value) }
func (b *Block) Encode(e *ads.Encoder) { msgBlock := btcwire.MsgBlock{ Header: b.Header, } msgBlock.BtcEncode(e, btcwire.ProtocolVersion) e.Encode(&b.Previous) e.Encode(&b.Transactions) }