github.com/koko1123/flow-go-1@v0.29.6/module/mempool/consensus/exec_fork_actor.go (about)

     1  package consensus
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  
     7  	"github.com/rs/zerolog"
     8  
     9  	"github.com/koko1123/flow-go-1/model/flow"
    10  )
    11  
    12  type ExecForkActor func([]*flow.IncorporatedResultSeal)
    13  
    14  func LogForkAndCrash(log zerolog.Logger) ExecForkActor {
    15  	return func(conflictingSeals []*flow.IncorporatedResultSeal) {
    16  		l := log.Fatal().Int("number conflicting seals", len(conflictingSeals))
    17  		for i, s := range conflictingSeals {
    18  			sealAsJson, err := json.Marshal(s)
    19  			if err != nil {
    20  				err = fmt.Errorf("failed to marshal candidate seal to json: %w", err)
    21  				l.Str(fmt.Sprintf("seal_%d", i), err.Error())
    22  				continue
    23  			}
    24  			l = l.Str(fmt.Sprintf("seal_%d", i), string(sealAsJson))
    25  		}
    26  		l.Msg("inconsistent seals for the same block")
    27  	}
    28  }