2019-07-17 14:30:55 +00:00
|
|
|
package actors
|
|
|
|
|
|
|
|
import (
|
2019-09-10 19:58:45 +00:00
|
|
|
"bytes"
|
|
|
|
|
2020-11-17 05:28:27 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/exitcode"
|
|
|
|
|
2019-10-18 04:47:41 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
2019-09-10 19:58:45 +00:00
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
2019-07-17 14:30:55 +00:00
|
|
|
)
|
|
|
|
|
2019-09-10 19:58:45 +00:00
|
|
|
func SerializeParams(i cbg.CBORMarshaler) ([]byte, aerrors.ActorError) {
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
if err := i.MarshalCBOR(buf); err != nil {
|
2019-08-07 06:35:57 +00:00
|
|
|
// TODO: shouldnt this be a fatal error?
|
2020-11-17 05:28:27 +00:00
|
|
|
return nil, aerrors.Absorb(err, exitcode.ErrSerialization, "failed to encode parameter")
|
2019-07-22 16:08:54 +00:00
|
|
|
}
|
2019-09-10 19:58:45 +00:00
|
|
|
return buf.Bytes(), nil
|
2019-07-17 14:30:55 +00:00
|
|
|
}
|