add state replay api and command

This commit is contained in:
whyrusleeping
2019-09-19 13:25:18 -07:00
parent 374759edeb
commit f7e3762cfc
6 changed files with 137 additions and 17 deletions
+19
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"strconv"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/libp2p/go-libp2p-core/peer"
@@ -194,6 +195,24 @@ func (a *StateAPI) StateCall(ctx context.Context, msg *types.Message, ts *types.
return a.StateManager.Call(ctx, msg, ts)
}
func (a *StateAPI) StateReplay(ctx context.Context, ts *types.TipSet, mc cid.Cid) (*api.ReplayResults, error) {
m, r, err := a.StateManager.Replay(ctx, ts, mc)
if err != nil {
return nil, err
}
var errstr string
if r.ActorErr != nil {
errstr = r.ActorErr.Error()
}
return &api.ReplayResults{
Msg: m,
Receipt: &r.MessageReceipt,
Error: errstr,
}, nil
}
func (a *StateAPI) stateForTs(ts *types.TipSet) (*state.StateTree, error) {
if ts == nil {
ts = a.Chain.GetHeaviestTipSet()