Пример #1
0
// NOTE: accs must be stored in deterministic order.
func storeAccounts(eyesCli *eyes.MerkleEyesClient, accs []types.PubAccount) {
	fmt.Println("STORE ACCOUNTS", accs)
	for _, acc := range accs {
		accBytes := wire.BinaryBytes(acc.Account)
		err := eyesCli.SetSync([]byte(acc.PubKey.KeyString()), accBytes)
		if err != nil {
			panic("Error storing account: " + err.Error())
		}
	}
}
Пример #2
0
func loadAccounts(eyesCli *eyes.MerkleEyesClient, pubKeys []crypto.PubKey) (accMap map[string]types.PubAccount) {
	accMap = make(map[string]types.PubAccount, len(pubKeys))
	for _, pubKey := range pubKeys {
		keyString := pubKey.KeyString()
		accBytes, err := eyesCli.GetSync([]byte(keyString))
		if err != nil {
			panic("Error loading account: " + err.Error())
		}
		if len(accBytes) == 0 {
			continue
		}
		var acc types.Account
		err = wire.ReadBinaryBytes(accBytes, &acc)
		if err != nil {
			panic("Error reading account: " + err.Error())
		}
		accMap[keyString] = types.PubAccount{
			Account: acc,
			PubKey:  pubKey,
		}
	}
	return
}