refactor: renames
This commit is contained in:
parent
f3cae55bd4
commit
b755ce9528
@ -77,7 +77,7 @@ func (a Actor) Exports() []interface{} {
|
|||||||
MethodDeleteActor: a.DeleteActor,
|
MethodDeleteActor: a.DeleteActor,
|
||||||
MethodSend: a.Send,
|
MethodSend: a.Send,
|
||||||
MethodMutateState: a.MutateState,
|
MethodMutateState: a.MutateState,
|
||||||
MethodAbort: a.Abort,
|
MethodAbort: a.AbortWith,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,17 +235,17 @@ func (a Actor) MutateState(rt runtime.Runtime, args *MutateStateArgs) *adt.Empty
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbortArgs are the arguments to the abort method, specifying the exit code to
|
// AbortWithArgs are the arguments to the Actor.AbortWith method, specifying the
|
||||||
// (optionally) abort with and the message.
|
// exit code to (optionally) abort with and the message.
|
||||||
type AbortArgs struct {
|
type AbortWithArgs struct {
|
||||||
Code exitcode.ExitCode
|
Code exitcode.ExitCode
|
||||||
NoCode bool
|
Message string
|
||||||
Message string
|
Uncontrolled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abort simply causes a panic or abort with the passed exit code.
|
// AbortWith simply causes a panic with the passed exit code.
|
||||||
func (a Actor) Abort(rt runtime.Runtime, args *AbortArgs) *adt.EmptyValue {
|
func (a Actor) AbortWith(rt runtime.Runtime, args *AbortWithArgs) *adt.EmptyValue {
|
||||||
if args.NoCode { // no code, just plain old panic
|
if args.Uncontrolled { // uncontrolled abort: directly panic
|
||||||
panic(args.Message)
|
panic(args.Message)
|
||||||
} else {
|
} else {
|
||||||
rt.Abortf(args.Code, args.Message)
|
rt.Abortf(args.Code, args.Message)
|
||||||
|
@ -615,14 +615,14 @@ func (t *MutateStateArgs) UnmarshalCBOR(r io.Reader) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var lengthBufAbortArgs = []byte{131}
|
var lengthBufAbortWithArgs = []byte{131}
|
||||||
|
|
||||||
func (t *AbortArgs) MarshalCBOR(w io.Writer) error {
|
func (t *AbortWithArgs) MarshalCBOR(w io.Writer) error {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
_, err := w.Write(cbg.CborNull)
|
_, err := w.Write(cbg.CborNull)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := w.Write(lengthBufAbortArgs); err != nil {
|
if _, err := w.Write(lengthBufAbortWithArgs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,11 +639,6 @@ func (t *AbortArgs) MarshalCBOR(w io.Writer) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.NoCode (bool) (bool)
|
|
||||||
if err := cbg.WriteBool(w, t.NoCode); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.Message (string) (string)
|
// t.Message (string) (string)
|
||||||
if len(t.Message) > cbg.MaxLength {
|
if len(t.Message) > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Value in field t.Message was too long")
|
return xerrors.Errorf("Value in field t.Message was too long")
|
||||||
@ -655,11 +650,16 @@ func (t *AbortArgs) MarshalCBOR(w io.Writer) error {
|
|||||||
if _, err := io.WriteString(w, string(t.Message)); err != nil {
|
if _, err := io.WriteString(w, string(t.Message)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// t.Uncontrolled (bool) (bool)
|
||||||
|
if err := cbg.WriteBool(w, t.Uncontrolled); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *AbortArgs) UnmarshalCBOR(r io.Reader) error {
|
func (t *AbortWithArgs) UnmarshalCBOR(r io.Reader) error {
|
||||||
*t = AbortArgs{}
|
*t = AbortWithArgs{}
|
||||||
|
|
||||||
br := cbg.GetPeeker(r)
|
br := cbg.GetPeeker(r)
|
||||||
scratch := make([]byte, 8)
|
scratch := make([]byte, 8)
|
||||||
@ -701,23 +701,6 @@ func (t *AbortArgs) UnmarshalCBOR(r io.Reader) error {
|
|||||||
|
|
||||||
t.Code = exitcode.ExitCode(extraI)
|
t.Code = exitcode.ExitCode(extraI)
|
||||||
}
|
}
|
||||||
// t.NoCode (bool) (bool)
|
|
||||||
|
|
||||||
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if maj != cbg.MajOther {
|
|
||||||
return fmt.Errorf("booleans must be major type 7")
|
|
||||||
}
|
|
||||||
switch extra {
|
|
||||||
case 20:
|
|
||||||
t.NoCode = false
|
|
||||||
case 21:
|
|
||||||
t.NoCode = true
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
|
||||||
}
|
|
||||||
// t.Message (string) (string)
|
// t.Message (string) (string)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -728,5 +711,22 @@ func (t *AbortArgs) UnmarshalCBOR(r io.Reader) error {
|
|||||||
|
|
||||||
t.Message = string(sval)
|
t.Message = string(sval)
|
||||||
}
|
}
|
||||||
|
// t.Uncontrolled (bool) (bool)
|
||||||
|
|
||||||
|
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if maj != cbg.MajOther {
|
||||||
|
return fmt.Errorf("booleans must be major type 7")
|
||||||
|
}
|
||||||
|
switch extra {
|
||||||
|
case 20:
|
||||||
|
t.Uncontrolled = false
|
||||||
|
case 21:
|
||||||
|
t.Uncontrolled = true
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ func main() {
|
|||||||
chaos.SendArgs{},
|
chaos.SendArgs{},
|
||||||
chaos.SendReturn{},
|
chaos.SendReturn{},
|
||||||
chaos.MutateStateArgs{},
|
chaos.MutateStateArgs{},
|
||||||
chaos.AbortArgs{},
|
chaos.AbortWithArgs{},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user