// safeGet fetches a pointer to the data for the key in the treap, then // copies the value so that the original pointer to the key is never written // to accidentally later. // TODO This function could also check to make sure the states of the ticket // treap value are valid. func safeGet(t *tickettreap.Immutable, k tickettreap.Key) (*tickettreap.Value, error) { v := t.Get(k) if v == nil { h := chainhash.Hash(k) return nil, stakeRuleError(ErrMissingTicket, fmt.Sprintf( "ticket %v was supposed to be in the passed "+ "treap, but could not be found", h)) } return &tickettreap.Value{ Height: v.Height, Missed: v.Missed, Revoked: v.Revoked, Spent: v.Spent, Expired: v.Expired, }, nil }