Merge pull request #1931 from filecoin-project/feat/compute-state-sub-links
compute-state html: Allow linking to internal executions
This commit is contained in:
commit
e7af464033
16
cli/state.go
16
cli/state.go
@ -1042,7 +1042,7 @@ func computeStateHtml(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(
|
|||||||
|
|
||||||
if len(ir.InternalExecutions) > 0 {
|
if len(ir.InternalExecutions) > 0 {
|
||||||
fmt.Println("<div>Internal executions:</div>")
|
fmt.Println("<div>Internal executions:</div>")
|
||||||
if err := printInternalExecutionsHtml(ir.InternalExecutions, getCode); err != nil {
|
if err := printInternalExecutionsHtml(cid.String(), ir.InternalExecutions, getCode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1054,8 +1054,10 @@ func computeStateHtml(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printInternalExecutionsHtml(trace []*types.ExecutionResult, getCode func(addr address.Address) (cid.Cid, error)) error {
|
func printInternalExecutionsHtml(hashName string, trace []*types.ExecutionResult, getCode func(addr address.Address) (cid.Cid, error)) error {
|
||||||
for _, im := range trace {
|
for i, im := range trace {
|
||||||
|
hashName := fmt.Sprintf("%s-r%d", hashName, i)
|
||||||
|
|
||||||
toCode, err := getCode(im.Msg.To)
|
toCode, err := getCode(im.Msg.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting code for %s: %w", toCode, err)
|
return xerrors.Errorf("getting code for %s: %w", toCode, err)
|
||||||
@ -1086,18 +1088,18 @@ func printInternalExecutionsHtml(trace []*types.ExecutionResult, getCode func(ad
|
|||||||
slow := im.Duration > 10*time.Millisecond
|
slow := im.Duration > 10*time.Millisecond
|
||||||
veryslow := im.Duration > 50*time.Millisecond
|
veryslow := im.Duration > 50*time.Millisecond
|
||||||
|
|
||||||
fmt.Printf(`<div class="exec">
|
fmt.Printf(`<div class="exec" id="%s">
|
||||||
<div><h4 class="call">%s:%s</h4></div>
|
<div><a href="#%s"><h4 class="call">%s:%s</h4></a></div>
|
||||||
<div><b>%s</b> -> <b>%s</b> (%s FIL), M%d</div>
|
<div><b>%s</b> -> <b>%s</b> (%s FIL), M%d</div>
|
||||||
%s
|
%s
|
||||||
<div><span class="slow-%t-%t">Took %s</span>, <span class="exit%d">Exit: <b>%d</b></span>%s
|
<div><span class="slow-%t-%t">Took %s</span>, <span class="exit%d">Exit: <b>%d</b></span>%s
|
||||||
`, codeStr(toCode), methods[toCode][im.Msg.Method].name, im.Msg.From, im.Msg.To, types.FIL(im.Msg.Value), im.Msg.Method, params, slow, veryslow, im.Duration, im.MsgRct.ExitCode, im.MsgRct.ExitCode, ret)
|
`, hashName, hashName, codeStr(toCode), methods[toCode][im.Msg.Method].name, im.Msg.From, im.Msg.To, types.FIL(im.Msg.Value), im.Msg.Method, params, slow, veryslow, im.Duration, im.MsgRct.ExitCode, im.MsgRct.ExitCode, ret)
|
||||||
if im.MsgRct.ExitCode != 0 {
|
if im.MsgRct.ExitCode != 0 {
|
||||||
fmt.Printf(`<div class="error">Error: <pre>%s</pre></div>`, im.Error)
|
fmt.Printf(`<div class="error">Error: <pre>%s</pre></div>`, im.Error)
|
||||||
}
|
}
|
||||||
if len(im.Subcalls) > 0 {
|
if len(im.Subcalls) > 0 {
|
||||||
fmt.Println("<div>Subcalls:</div>")
|
fmt.Println("<div>Subcalls:</div>")
|
||||||
if err := printInternalExecutionsHtml(im.Subcalls, getCode); err != nil {
|
if err := printInternalExecutionsHtml(hashName, im.Subcalls, getCode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user