Optional tipset param for ChainCall
This commit is contained in:
parent
eb854467c8
commit
d8bd222cb1
@ -73,7 +73,9 @@ type FullNode interface {
|
|||||||
ChainWaitMsg(context.Context, cid.Cid) (*MsgWait, error)
|
ChainWaitMsg(context.Context, cid.Cid) (*MsgWait, error)
|
||||||
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error)
|
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error)
|
||||||
ChainGetBlockMessages(context.Context, cid.Cid) ([]*types.SignedMessage, error)
|
ChainGetBlockMessages(context.Context, cid.Cid) ([]*types.SignedMessage, error)
|
||||||
ChainCall(context.Context, *types.Message) (*types.MessageReceipt, error)
|
|
||||||
|
// if tipset is nil, we'll use heaviest
|
||||||
|
ChainCall(context.Context, *types.Message, *types.TipSet) (*types.MessageReceipt, error)
|
||||||
|
|
||||||
// messages
|
// messages
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ type FullNodeStruct struct {
|
|||||||
ChainWaitMsg func(context.Context, cid.Cid) (*MsgWait, error) `perm:"read"`
|
ChainWaitMsg func(context.Context, cid.Cid) (*MsgWait, error) `perm:"read"`
|
||||||
ChainGetBlock func(context.Context, cid.Cid) (*types.BlockHeader, error) `perm:"read"`
|
ChainGetBlock func(context.Context, cid.Cid) (*types.BlockHeader, error) `perm:"read"`
|
||||||
ChainGetBlockMessages func(context.Context, cid.Cid) ([]*types.SignedMessage, error) `perm:"read"`
|
ChainGetBlockMessages func(context.Context, cid.Cid) ([]*types.SignedMessage, error) `perm:"read"`
|
||||||
ChainCall func(context.Context, *types.Message) (*types.MessageReceipt, error) `perm:"read"`
|
ChainCall func(context.Context, *types.Message, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"`
|
||||||
|
|
||||||
MpoolPending func(context.Context, *types.TipSet) ([]*types.SignedMessage, error) `perm:"read"`
|
MpoolPending func(context.Context, *types.TipSet) ([]*types.SignedMessage, error) `perm:"read"`
|
||||||
MpoolPush func(context.Context, *types.SignedMessage) error `perm:"write"`
|
MpoolPush func(context.Context, *types.SignedMessage) error `perm:"write"`
|
||||||
@ -156,8 +156,8 @@ func (c *FullNodeStruct) ChainWaitMsg(ctx context.Context, msgc cid.Cid) (*MsgWa
|
|||||||
return c.Internal.ChainWaitMsg(ctx, msgc)
|
return c.Internal.ChainWaitMsg(ctx, msgc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) ChainCall(ctx context.Context, msg *types.Message) (*types.MessageReceipt, error) {
|
func (c *FullNodeStruct) ChainCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error) {
|
||||||
return c.Internal.ChainCall(ctx, msg)
|
return c.Internal.ChainCall(ctx, msg, ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) WalletNew(ctx context.Context, typ string) (address.Address, error) {
|
func (c *FullNodeStruct) WalletNew(ctx context.Context, typ string) (address.Address, error) {
|
||||||
|
@ -86,14 +86,16 @@ func (a *FullNodeAPI) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) ([
|
|||||||
return a.Chain.MessagesForBlock(b)
|
return a.Chain.MessagesForBlock(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *FullNodeAPI) ChainCall(ctx context.Context, msg *types.Message) (*types.MessageReceipt, error) {
|
func (a *FullNodeAPI) ChainCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error) {
|
||||||
hts := a.Chain.GetHeaviestTipSet()
|
if ts == nil {
|
||||||
state, err := a.Chain.TipSetState(hts.Cids())
|
ts = a.Chain.GetHeaviestTipSet()
|
||||||
|
}
|
||||||
|
state, err := a.Chain.TipSetState(ts.Cids())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
vmi, err := vm.NewVM(state, hts.Height(), hts.Blocks()[0].Miner, a.Chain)
|
vmi, err := vm.NewVM(state, ts.Height(), ts.Blocks()[0].Miner, a.Chain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to set up vm: %w", err)
|
return nil, xerrors.Errorf("failed to set up vm: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ type storageMinerApi interface {
|
|||||||
//ReadState(ctx context.Context, addr address.Address) (????, error)
|
//ReadState(ctx context.Context, addr address.Address) (????, error)
|
||||||
|
|
||||||
// Call a read only method on actors (no interaction with the chain required)
|
// Call a read only method on actors (no interaction with the chain required)
|
||||||
ChainCall(ctx context.Context, msg *types.Message) (*types.MessageReceipt, error)
|
ChainCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error)
|
||||||
|
|
||||||
MpoolPush(context.Context, *types.SignedMessage) error
|
MpoolPush(context.Context, *types.SignedMessage) error
|
||||||
MpoolGetNonce(context.Context, address.Address) (uint64, error)
|
MpoolGetNonce(context.Context, address.Address) (uint64, error)
|
||||||
@ -187,7 +187,7 @@ func (m *Miner) getWorkerAddr(ctx context.Context) (address.Address, error) {
|
|||||||
Params: actors.EmptyStructCBOR,
|
Params: actors.EmptyStructCBOR,
|
||||||
}
|
}
|
||||||
|
|
||||||
recpt, err := m.api.ChainCall(ctx, msg)
|
recpt, err := m.api.ChainCall(ctx, msg, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, errors.Wrapf(err, "calling getWorker(%s)", m.maddr)
|
return address.Undef, errors.Wrapf(err, "calling getWorker(%s)", m.maddr)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user