mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 07:53:47 +00:00
Updated when FIRE INIT is actually printed
The tracer will now keep the state of wheter the init has been sent or not and will emit it prior sending the very first block out.
This commit is contained in:
parent
b6c53b7ada
commit
213e30cebe
1 changed files with 7 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -56,6 +57,7 @@ func newFirehoseTracer() (core.BlockchainLogger, error) {
|
||||||
type Firehose struct {
|
type Firehose struct {
|
||||||
// Global state
|
// Global state
|
||||||
outputBuffer *bytes.Buffer
|
outputBuffer *bytes.Buffer
|
||||||
|
initSent *atomic.Bool
|
||||||
|
|
||||||
// Block state
|
// Block state
|
||||||
block *pbeth.Block
|
block *pbeth.Block
|
||||||
|
|
@ -78,12 +80,10 @@ type Firehose struct {
|
||||||
const FirehoseProtocolVersion = "3.0"
|
const FirehoseProtocolVersion = "3.0"
|
||||||
|
|
||||||
func NewFirehoseLogger() *Firehose {
|
func NewFirehoseLogger() *Firehose {
|
||||||
// FIXME: Where should we put our actual INIT line?
|
|
||||||
printToFirehose("INIT", FirehoseProtocolVersion, "geth", params.Version)
|
|
||||||
|
|
||||||
return &Firehose{
|
return &Firehose{
|
||||||
// Global state
|
// Global state
|
||||||
outputBuffer: bytes.NewBuffer(make([]byte, 0, 100*1024*1024)),
|
outputBuffer: bytes.NewBuffer(make([]byte, 0, 100*1024*1024)),
|
||||||
|
initSent: new(atomic.Bool),
|
||||||
|
|
||||||
// Block state
|
// Block state
|
||||||
blockOrdinal: &Ordinal{},
|
blockOrdinal: &Ordinal{},
|
||||||
|
|
@ -978,6 +978,10 @@ func (f *Firehose) panicNotInState(msg string) string {
|
||||||
//
|
//
|
||||||
// It flushes this through [flushToFirehose] to the `os.Stdout` writer.
|
// It flushes this through [flushToFirehose] to the `os.Stdout` writer.
|
||||||
func (f *Firehose) printBlockToFirehose(block *pbeth.Block, finalityStatus *FinalityStatus) {
|
func (f *Firehose) printBlockToFirehose(block *pbeth.Block, finalityStatus *FinalityStatus) {
|
||||||
|
if wasNeverSent := f.initSent.CompareAndSwap(false, true); wasNeverSent {
|
||||||
|
printToFirehose("INIT", FirehoseProtocolVersion, "geth", params.Version)
|
||||||
|
}
|
||||||
|
|
||||||
marshalled, err := proto.Marshal(block)
|
marshalled, err := proto.Marshal(block)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to marshal block: %w", err))
|
panic(fmt.Errorf("failed to marshal block: %w", err))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue