Skip to content

Commit

Permalink
refactor the get actor function
Browse files Browse the repository at this point in the history
  • Loading branch information
Terryhung committed Aug 18, 2023
1 parent eb586f3 commit 63632d0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tasks/fevm/trace/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func getEthAddress(addr address.Address) string {
return to.String()
}

func (t *Task) getActorAddress(ctx context.Context, address address.Address, tsk types.TipSetKey) address.Address {
actor, _ := t.node.Actor(ctx, address, tsk)
if actor.Address != nil {
return *actor.Address
}
return address
}

func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, executed *types.TipSet) (model.Persistable, *visormodel.ProcessingReport, error) {
ctx, span := otel.Tracer("").Start(ctx, "ProcessTipSets")
if span.IsRecording() {
Expand Down Expand Up @@ -139,17 +147,8 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
}

// Get Address
toActor, _ := t.node.Actor(ctx, child.Message.To, current.Key())
toAddress := child.Message.To
if toActor.Address != nil {
toAddress = *toActor.Address
}

fromActor, _ := t.node.Actor(ctx, child.Message.From, current.Key())
fromAddress := child.Message.From
if fromActor.Address != nil {
fromAddress = *fromActor.Address
}
toAddress := t.getActorAddress(ctx, child.Message.To, current.Key())
fromAddress := t.getActorAddress(ctx, child.Message.From, current.Key())

traceObj := &fevm.FEVMTrace{
Height: int64(parentMsg.Height),
Expand Down

0 comments on commit 63632d0

Please sign in to comment.