add tipset message was executed in back to waitmsg call
This commit is contained in:
parent
b8bc54fd5b
commit
84985ef96f
@ -195,6 +195,7 @@ type DealInfo struct {
|
|||||||
|
|
||||||
type MsgWait struct {
|
type MsgWait struct {
|
||||||
Receipt types.MessageReceipt
|
Receipt types.MessageReceipt
|
||||||
|
TipSet *types.TipSet
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockMessages struct {
|
type BlockMessages struct {
|
||||||
|
@ -642,25 +642,25 @@ func (cs *ChainStore) LoadSignedMessagesFromCids(cids []cid.Cid) ([]*types.Signe
|
|||||||
return msgs, nil
|
return msgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ChainStore) WaitForMessage(ctx context.Context, mcid cid.Cid) (*types.MessageReceipt, error) {
|
func (cs *ChainStore) WaitForMessage(ctx context.Context, mcid cid.Cid) (*types.TipSet, *types.MessageReceipt, error) {
|
||||||
tsub := cs.SubHeadChanges(ctx)
|
tsub := cs.SubHeadChanges(ctx)
|
||||||
|
|
||||||
head := cs.GetHeaviestTipSet()
|
head := cs.GetHeaviestTipSet()
|
||||||
|
|
||||||
r, err := cs.tipsetExecutedMessage(head, mcid)
|
r, err := cs.tipsetExecutedMessage(head, mcid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if r != nil {
|
if r != nil {
|
||||||
return r, nil
|
return head, r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case notif, ok := <-tsub:
|
case notif, ok := <-tsub:
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ctx.Err()
|
return nil, nil, ctx.Err()
|
||||||
}
|
}
|
||||||
for _, val := range notif {
|
for _, val := range notif {
|
||||||
switch val.Type {
|
switch val.Type {
|
||||||
@ -669,15 +669,15 @@ func (cs *ChainStore) WaitForMessage(ctx context.Context, mcid cid.Cid) (*types.
|
|||||||
case HCApply:
|
case HCApply:
|
||||||
r, err := cs.tipsetExecutedMessage(val.Val, mcid)
|
r, err := cs.tipsetExecutedMessage(val.Val, mcid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if r != nil {
|
if r != nil {
|
||||||
return r, nil
|
return val.Val, r, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ctx.Err()
|
return nil, nil, ctx.Err()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ func tipsetSortFunc(blks []*BlockHeader) func(i, j int) bool {
|
|||||||
tj := blks[j].LastTicket()
|
tj := blks[j].LastTicket()
|
||||||
|
|
||||||
if ti.Equals(tj) {
|
if ti.Equals(tj) {
|
||||||
//log.Warn("blocks have same ticket")
|
log.Warnf("blocks have same ticket (%s %s)", blks[i].Miner, blks[j].Miner)
|
||||||
return blks[i].Cid().KeyString() < blks[j].Cid().KeyString()
|
return blks[i].Cid().KeyString() < blks[j].Cid().KeyString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,13 +49,14 @@ func (a *ChainAPI) ChainGetRandomness(ctx context.Context, pts *types.TipSet, ti
|
|||||||
func (a *ChainAPI) ChainWaitMsg(ctx context.Context, msg cid.Cid) (*api.MsgWait, error) {
|
func (a *ChainAPI) ChainWaitMsg(ctx context.Context, msg cid.Cid) (*api.MsgWait, error) {
|
||||||
// TODO: consider using event system for this, expose confidence
|
// TODO: consider using event system for this, expose confidence
|
||||||
|
|
||||||
recpt, err := a.Chain.WaitForMessage(ctx, msg)
|
ts, recpt, err := a.Chain.WaitForMessage(ctx, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &api.MsgWait{
|
return &api.MsgWait{
|
||||||
Receipt: *recpt,
|
Receipt: *recpt,
|
||||||
|
TipSet: ts,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user