Exemple #1
0
func (c *PagingC) Load(info *ads.Info) {
	begin := time.Now()

	data := c.DB.Read(info.Token)

	c.LoadDiskTime += time.Now().Sub(begin)

	begin = time.Now()
	decoder := ads.Decoder{
		Reader: bytes.NewBuffer(data),
	}

	decoder.Decode(&info.Value)
	info.Value.MakeTransparent()

	for _, root := range ads.CollectChildren(info.Value) {
		var buffer [8]byte
		if n, err := decoder.Read(buffer[:]); n != 8 || err != nil {
			log.Panic(err)
		}

		info := root.GetInfo()
		info.Token = int64(binary.LittleEndian.Uint64(buffer[:]))
	}

	c.LoadTime += time.Now().Sub(begin)
}
Exemple #2
0
func (n *BitrieLeaf) Decode(d *ads.Decoder) {
	var buffer [40]byte
	d.Read(buffer[:])
	n.Bits.Bits = buffer[0:32]
	n.Bits.Start = int32(binary.LittleEndian.Uint16(buffer[32:36]))
	n.Bits.Length = int32(binary.LittleEndian.Uint16(buffer[36:40]))
	d.Decode(&n.Value)
}
Exemple #3
0
func (b *Block) Decode(d *ads.Decoder) {
	msgBlock := btcwire.MsgBlock{
		Header: b.Header,
	}
	msgBlock.BtcDecode(d, btcwire.ProtocolVersion)

	d.Decode(&b.Previous)
	d.Decode(&b.Transactions)

	// check that msgBlock has zero transactions and that the transaction merkle tree hash is correct
}