Exemplo n.º 1
0
func randomBalance(balances bitrie.Bitrie, c comp.C) int {
	key := core.RandomKey(bitrie.Bits{}, balances, c)

	trackc := verified.NewTrackC(c)
	info, found := balances.Get(key, trackc)
	if !found {
		panic(key)
	}

	oi := info.(*core.OutpointInfo)
	trackc.Use(oi)

	return computeSize(balances, trackc)
}
Exemplo n.º 2
0
func main() {
	core.RegisterTypes()
	transactions.RegisterTypes()

	flag.Parse()

	db := core.ContinueDB(filepath.Join(*BaseDbPath, "transactions"), *treapToken)

	logtreap := new(verified.LogTreap)
	logtreap.MakeOpaque()
	ads.GetInfo(logtreap).Token = *treapToken

	pagingC := core.NewPagingC(db)
	pagingC.Load(ads.GetInfo(logtreap))

	c := pagingC

	c.Use(logtreap)
	length := logtreap.Count(c)
	hash := logtreap.Slice(0, length, c)

	// this hash is what we commit to....
	c.Use(hash)
	tree := hash.Finish(c).(verified.LogTree)

	c.Use(tree)
	lastReturn := tree.Index(length-1, c)

	c.Use(lastReturn)
	transactions := lastReturn.ArgsOrResults[0].(bitrie.Bitrie)

	c.Use(transactions)
	fmt.Println(BitrieSize(transactions, c))

	for i := 0; i < 100; i++ {
		fmt.Println(core.RandomKey(bitrie.Bits{}, transactions, c))
	}
}