mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
fix bug logging, async
This commit is contained in:
parent
b042f3ca81
commit
d8ac726f30
2 changed files with 36 additions and 47 deletions
|
|
@ -862,8 +862,8 @@ func (c *Posv) Finalize(chain consensus.ChainReader, header *types.Header, state
|
||||||
_ = c.cacheData(txs, receipts)
|
_ = c.cacheData(txs, receipts)
|
||||||
|
|
||||||
if c.HookReward != nil && number%rCheckpoint == 0 {
|
if c.HookReward != nil && number%rCheckpoint == 0 {
|
||||||
if !c.EnableCache && uint64(c.BlockSigners.Len()) >= (rCheckpoint*3) {
|
if !c.EnableCache && int(c.BlockSigners.Len()) >= int(rCheckpoint*3) {
|
||||||
log.Debug("EnableCache true c.BlockSigners.Len()", c.BlockSigners.Len())
|
log.Debug("EnableCache true c.BlockSigners.Len() ", "BlockSigners.Len", c.BlockSigners.Len())
|
||||||
c.EnableCache = true
|
c.EnableCache = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1038,12 +1038,7 @@ func (c *Posv) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Hea
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Posv) cacheData(txs []*types.Transaction, receipts []*types.Receipt) error {
|
func (c *Posv) cacheData(txs []*types.Transaction, receipts []*types.Receipt) error {
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
wg.Add(len(txs))
|
|
||||||
|
|
||||||
for _, tx := range txs {
|
for _, tx := range txs {
|
||||||
go func(tx *types.Transaction) error {
|
|
||||||
if tx.IsSigningTransaction() {
|
if tx.IsSigningTransaction() {
|
||||||
blkHash := common.BytesToHash(tx.Data()[len(tx.Data())-32:])
|
blkHash := common.BytesToHash(tx.Data()[len(tx.Data())-32:])
|
||||||
from := *tx.From()
|
from := *tx.From()
|
||||||
|
|
@ -1052,14 +1047,12 @@ func (c *Posv) cacheData(txs []*types.Transaction, receipts []*types.Receipt) er
|
||||||
for _, r := range receipts {
|
for _, r := range receipts {
|
||||||
if r.TxHash == tx.Hash() {
|
if r.TxHash == tx.Hash() {
|
||||||
b = r.Status
|
b = r.Status
|
||||||
wg.Done()
|
break
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if b == types.ReceiptStatusFailed {
|
if b == types.ReceiptStatusFailed {
|
||||||
wg.Done()
|
continue
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var lAddr []common.Address
|
var lAddr []common.Address
|
||||||
|
|
@ -1078,16 +1071,12 @@ func (c *Posv) cacheData(txs []*types.Transaction, receipts []*types.Receipt) er
|
||||||
vote.Masternode = *addr
|
vote.Masternode = *addr
|
||||||
vote.Voter = *tx.From()
|
vote.Voter = *tx.From()
|
||||||
|
|
||||||
log.Debug("Remove from Votes cache", vote.Masternode.String(), vote.Voter.String())
|
log.Debug("Remove from Votes cache ", "Masternode", vote.Masternode.String(), "Voter", vote.Voter.String())
|
||||||
c.Votes.Remove(vote)
|
c.Votes.Remove(vote)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Done()
|
|
||||||
return nil
|
|
||||||
}(tx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -490,7 +490,7 @@ func GetRewardBalancesRate(c *posv.Posv, foudationWalletAddr common.Address, mas
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Fail to get vote capacity", "error", err)
|
log.Crit("Fail to get vote capacity", "error", err)
|
||||||
}
|
}
|
||||||
log.Debug("Add to Votes cache", vote.Masternode.String(), vote.Voter.String(), voterCap.String())
|
log.Debug("Add to Votes cache ", "vote.Masternode", vote.Masternode.String(), "vote.Voter", vote.Voter.String(), "voterCap", voterCap.String())
|
||||||
c.Votes.Add(vote, voterCap)
|
c.Votes.Add(vote, voterCap)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue