Ejemplo n.º 1
0
// safeDelete is used to delete a value in an immutable ticket treap, returning
// the mutated, immutable treap given as a result.  It first checks to see if
// the key exists in the treap. If it does not, it returns an error.
func safeDelete(t *tickettreap.Immutable, k tickettreap.Key) (*tickettreap.Immutable, error) {
	if !t.Has(k) {
		return nil, stakeRuleError(ErrMissingTicket, fmt.Sprintf("attempted to "+
			"delete non-existing key %v from treap", chainhash.Hash(k)))
	}

	return t.Delete(k), nil
}