Merge pull request #6364 from filecoin-project/asr/resolve-messages
Improve address resolution for messages
This commit is contained in:
@@ -265,7 +265,7 @@ func gasEstimateGasLimit(
|
||||
return -1, xerrors.Errorf("getting key address: %w", err)
|
||||
}
|
||||
|
||||
pending, ts := mpool.PendingFor(fromA)
|
||||
pending, ts := mpool.PendingFor(ctx, fromA)
|
||||
priorMsgs := make([]types.ChainMsg, 0, len(pending))
|
||||
for _, m := range pending {
|
||||
if m.Message.Nonce == msg.Nonce {
|
||||
|
||||
@@ -58,7 +58,7 @@ func (a *MpoolAPI) MpoolSelect(ctx context.Context, tsk types.TipSetKey, ticketQ
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
return a.Mpool.SelectMessages(ts, ticketQuality)
|
||||
return a.Mpool.SelectMessages(ctx, ts, ticketQuality)
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
|
||||
@@ -66,7 +66,7 @@ func (a *MpoolAPI) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*ty
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
pending, mpts := a.Mpool.Pending()
|
||||
pending, mpts := a.Mpool.Pending(ctx)
|
||||
|
||||
haveCids := map[cid.Cid]struct{}{}
|
||||
for _, m := range pending {
|
||||
@@ -120,16 +120,16 @@ func (a *MpoolAPI) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*ty
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolClear(ctx context.Context, local bool) error {
|
||||
a.Mpool.Clear(local)
|
||||
a.Mpool.Clear(ctx, local)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MpoolModule) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) {
|
||||
return m.Mpool.Push(smsg)
|
||||
return m.Mpool.Push(ctx, smsg)
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolPushUntrusted(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) {
|
||||
return a.Mpool.PushUntrusted(smsg)
|
||||
return a.Mpool.PushUntrusted(ctx, smsg)
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) {
|
||||
@@ -190,7 +190,7 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spe
|
||||
func (a *MpoolAPI) MpoolBatchPush(ctx context.Context, smsgs []*types.SignedMessage) ([]cid.Cid, error) {
|
||||
var messageCids []cid.Cid
|
||||
for _, smsg := range smsgs {
|
||||
smsgCid, err := a.Mpool.Push(smsg)
|
||||
smsgCid, err := a.Mpool.Push(ctx, smsg)
|
||||
if err != nil {
|
||||
return messageCids, err
|
||||
}
|
||||
@@ -202,7 +202,7 @@ func (a *MpoolAPI) MpoolBatchPush(ctx context.Context, smsgs []*types.SignedMess
|
||||
func (a *MpoolAPI) MpoolBatchPushUntrusted(ctx context.Context, smsgs []*types.SignedMessage) ([]cid.Cid, error) {
|
||||
var messageCids []cid.Cid
|
||||
for _, smsg := range smsgs {
|
||||
smsgCid, err := a.Mpool.PushUntrusted(smsg)
|
||||
smsgCid, err := a.Mpool.PushUntrusted(ctx, smsg)
|
||||
if err != nil {
|
||||
return messageCids, err
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (a *MpoolAPI) MpoolBatchPushMessage(ctx context.Context, msgs []*types.Mess
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
||||
return a.Mpool.GetNonce(addr)
|
||||
return a.Mpool.GetNonce(ctx, addr)
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolSub(ctx context.Context) (<-chan api.MpoolUpdate, error) {
|
||||
|
||||
@@ -23,18 +23,18 @@ type MpoolNonceAPI struct {
|
||||
}
|
||||
|
||||
// GetNonce gets the nonce from current chain head.
|
||||
func (a *MpoolNonceAPI) GetNonce(addr address.Address) (uint64, error) {
|
||||
func (a *MpoolNonceAPI) GetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
||||
ts := a.StateAPI.Chain.GetHeaviestTipSet()
|
||||
|
||||
// make sure we have a key address so we can compare with messages
|
||||
keyAddr, err := a.StateAPI.StateManager.ResolveToKeyAddress(context.TODO(), addr, ts)
|
||||
keyAddr, err := a.StateAPI.StateManager.ResolveToKeyAddress(ctx, addr, ts)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Load the last nonce from the state, if it exists.
|
||||
highestNonce := uint64(0)
|
||||
if baseActor, err := a.StateAPI.StateManager.LoadActorRaw(context.TODO(), addr, ts.ParentState()); err != nil {
|
||||
if baseActor, err := a.StateAPI.StateManager.LoadActorRaw(ctx, addr, ts.ParentState()); err != nil {
|
||||
if !xerrors.Is(err, types.ErrActorNotFound) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user