Ejemplo n.º 1
0
// Load fetches the entry in the database with the given ID and returns the Pool
// representing it.
func Load(namespace walletdb.Namespace, m *waddrmgr.Manager, poolID []byte) (*Pool, error) {
	err := namespace.View(
		func(tx walletdb.Tx) error {
			if exists := existsPool(tx, poolID); !exists {
				str := fmt.Sprintf("unable to find voting pool %v in db", poolID)
				return newError(ErrPoolNotExists, str, nil)
			}
			return nil
		})
	if err != nil {
		return nil, err
	}
	p := newPool(namespace, m, poolID)
	if err = p.LoadAllSeries(); err != nil {
		return nil, err
	}
	return p, nil
}