X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=protocol%2Fbc%2Ftx.go;h=0702e4ced421f714a65339ff5aada17b8f5ffad5;hp=fd76dddaf0ba1e65ca29222a7744201ffbd5ca99;hb=ce85135aab7643cff4426cab11f1b822ad3ef264;hpb=571174f9f9a4e942512505e21dcfa7af06dc3613 diff --git a/protocol/bc/tx.go b/protocol/bc/tx.go index fd76ddda..0702e4ce 100644 --- a/protocol/bc/tx.go +++ b/protocol/bc/tx.go @@ -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]