lotus/chain/types/vmcontext.go

48 lines
1.0 KiB
Go
Raw Normal View History

package types
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
2019-09-12 04:12:35 +00:00
cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
)
type Storage interface {
Put(cbg.CBORMarshaler) (cid.Cid, aerrors.ActorError)
Get(cid.Cid, cbg.CBORUnmarshaler) aerrors.ActorError
GetHead() cid.Cid
// Commit sets the new head of the actors state as long as the current
// state matches 'oldh'
Commit(oldh cid.Cid, newh cid.Cid) aerrors.ActorError
}
type StateTree interface {
SetActor(addr address.Address, act *Actor) error
// GetActor returns the actor from any type of `addr` provided.
GetActor(addr address.Address) (*Actor, error)
}
2019-08-29 00:01:46 +00:00
type storageWrapper struct {
s Storage
}
func (sw *storageWrapper) Put(i cbg.CBORMarshaler) (cid.Cid, error) {
c, err := sw.s.Put(i)
2019-08-29 00:01:46 +00:00
if err != nil {
return cid.Undef, err
}
return c, nil
}
func (sw *storageWrapper) Get(c cid.Cid, out cbg.CBORUnmarshaler) error {
if err := sw.s.Get(c, out); err != nil {
2019-08-29 00:01:46 +00:00
return err
}
return nil
}