mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
ethstats: chain event fixes
This commit is contained in:
parent
084129ad47
commit
b335c19ccd
1 changed files with 12 additions and 12 deletions
|
|
@ -253,6 +253,7 @@ func (s *Service) loop(chainHeadCh chan core.ChainHeadEvent, chain2HeadCh chan c
|
||||||
quitCh = make(chan struct{})
|
quitCh = make(chan struct{})
|
||||||
headCh = make(chan *types.Header, 1)
|
headCh = make(chan *types.Header, 1)
|
||||||
txCh = make(chan struct{}, 1)
|
txCh = make(chan struct{}, 1)
|
||||||
|
head2Ch = make(chan core.Chain2HeadEvent, 100)
|
||||||
)
|
)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -710,7 +711,6 @@ func (s *Service) assembleBlockStats(header *types.Header) *blockStats {
|
||||||
td *big.Int
|
td *big.Int
|
||||||
txs []txStats
|
txs []txStats
|
||||||
uncles []*types.Header
|
uncles []*types.Header
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// check if backend is a full node
|
// check if backend is a full node
|
||||||
|
|
@ -847,11 +847,11 @@ type blockStub struct {
|
||||||
ParentHash string `json:"parent_hash"`
|
ParentHash string `json:"parent_hash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func createStub(b *types.Block) *blockStub {
|
func createStub(h *types.Header) *blockStub {
|
||||||
s := &blockStub{
|
s := &blockStub{
|
||||||
Hash: b.Hash().String(),
|
Hash: h.Hash().String(),
|
||||||
ParentHash: b.ParentHash().String(),
|
ParentHash: h.ParentHash.String(),
|
||||||
Number: b.NumberU64(),
|
Number: h.Number.Uint64(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
@ -868,12 +868,12 @@ func (s *Service) reportChain2Head(conn *connWrapper, chain2HeadData *core.Chain
|
||||||
chainHeadEvent := ChainHeadEvent{
|
chainHeadEvent := ChainHeadEvent{
|
||||||
Type: chain2HeadData.Type,
|
Type: chain2HeadData.Type,
|
||||||
}
|
}
|
||||||
for _, block := range chain2HeadData.NewChain {
|
for _, header := range chain2HeadData.NewChain {
|
||||||
chainHeadEvent.NewChain = append(chainHeadEvent.NewChain, createStub(block))
|
chainHeadEvent.NewChain = append(chainHeadEvent.NewChain, createStub(header))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, block := range chain2HeadData.OldChain {
|
for _, header := range chain2HeadData.OldChain {
|
||||||
chainHeadEvent.OldChain = append(chainHeadEvent.OldChain, createStub(block))
|
chainHeadEvent.OldChain = append(chainHeadEvent.OldChain, createStub(header))
|
||||||
}
|
}
|
||||||
|
|
||||||
stats := map[string]interface{}{
|
stats := map[string]interface{}{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue