OSDN Git Service

add cancel vote (#172)
[bytom/vapor.git] / protocol / bc / tx.go
index fd76ddd..0702e4c 100644 (file)
@@ -82,6 +82,19 @@ func (tx *Tx) Spend(id Hash) (*Spend, error) {
        return sp, nil
 }
 
+// VetoInput try to get the veto entry by given hash
+func (tx *Tx) VetoInput(id Hash) (*VetoInput, error) {
+       e, ok := tx.Entries[id]
+       if !ok || e == nil {
+               return nil, errors.Wrapf(ErrMissingEntry, "id %x", id.Bytes())
+       }
+       sp, ok := e.(*VetoInput)
+       if !ok {
+               return nil, errors.Wrapf(ErrEntryType, "entry %x has unexpected type %T", id.Bytes(), e)
+       }
+       return sp, nil
+}
+
 // VoteOutput try to get the vote output entry by given hash
 func (tx *Tx) VoteOutput(id Hash) (*VoteOutput, error) {
        e, ok := tx.Entries[id]