Re: #1412: Add a non-blocking version of StateWaitMsg

- This commit adds a new method called StateSearchMsg
- We can probably overhaul StateWaitMsg onto this new method at a later point in time
This commit is contained in:
Aayush Rajasekaran
2020-03-24 06:43:15 -04:00
parent d74ede5a79
commit d350a9d415
7 changed files with 102 additions and 8 deletions
+18 -2
View File
@@ -281,7 +281,7 @@ func (a *StateAPI) MinerCreateBlock(ctx context.Context, addr address.Address, p
return &out, nil
}
func (a *StateAPI) StateWaitMsg(ctx context.Context, msg cid.Cid) (*api.MsgWait, error) {
func (a *StateAPI) StateWaitMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
// TODO: consider using event system for this, expose confidence
ts, recpt, err := a.StateManager.WaitForMessage(ctx, msg)
@@ -289,12 +289,28 @@ func (a *StateAPI) StateWaitMsg(ctx context.Context, msg cid.Cid) (*api.MsgWait,
return nil, err
}
return &api.MsgWait{
return &api.MsgLookup{
Receipt: *recpt,
TipSet: ts,
}, nil
}
func (a *StateAPI) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
ts, recpt, err := a.StateManager.SearchForMessage(ctx, msg)
if err != nil {
return nil, err
}
if ts != nil {
return &api.MsgLookup{
Receipt: *recpt,
TipSet: ts,
}, nil
} else {
return nil, nil
}
}
func (a *StateAPI) StateGetReceipt(ctx context.Context, msg cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error) {
ts, err := a.Chain.GetTipSetFromKey(tsk)
if err != nil {