2019-07-17 14:30:55 +00:00
|
|
|
package actors
|
|
|
|
|
|
|
|
import (
|
2019-09-10 19:58:45 +00:00
|
|
|
"bytes"
|
|
|
|
|
2019-07-22 16:08:54 +00:00
|
|
|
"github.com/filecoin-project/go-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-07-17 16:00:59 +00:00
|
|
|
var (
|
|
|
|
EmptyStructCBOR = []byte{0xa0}
|
|
|
|
)
|
|
|
|
|
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?
|
2019-07-22 16:08:54 +00:00
|
|
|
return nil, aerrors.Absorb(err, 1, "failed to encode parameter")
|
|
|
|
}
|
2019-09-10 19:58:45 +00:00
|
|
|
return buf.Bytes(), nil
|
2019-07-17 14:30:55 +00:00
|
|
|
}
|