mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
light: long line to multi lines
This commit is contained in:
parent
8a9dea26d3
commit
b34c0669d3
4 changed files with 23 additions and 11 deletions
|
|
@ -104,7 +104,8 @@ func NewLightChain(odr OdrBackend, config *params.ChainConfig, engine consensus.
|
||||||
if err := bc.loadLastState(); err != nil {
|
if err := bc.loadLastState(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
|
// Check the current state of the block hashes and
|
||||||
|
// make sure that we do not have any of the bad blocks in our chain
|
||||||
for hash := range core.BadHashes {
|
for hash := range core.BadHashes {
|
||||||
if header := bc.GetHeaderByHash(hash); header != nil {
|
if header := bc.GetHeaderByHash(hash); header != nil {
|
||||||
log.Error("Found bad hash, rewinding chain", "number", header.Number, "hash", header.ParentHash)
|
log.Error("Found bad hash, rewinding chain", "number", header.Number, "hash", header.ParentHash)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ func GetHeaderByNumber(ctx context.Context, odr OdrBackend, number uint64) (*typ
|
||||||
if odr.ChtIndexer() != nil {
|
if odr.ChtIndexer() != nil {
|
||||||
chtCount, sectionHeadNum, sectionHead = odr.ChtIndexer().Sections()
|
chtCount, sectionHeadNum, sectionHead = odr.ChtIndexer().Sections()
|
||||||
canonicalHash := rawdb.ReadCanonicalHash(db, sectionHeadNum)
|
canonicalHash := rawdb.ReadCanonicalHash(db, sectionHeadNum)
|
||||||
// if the CHT was injected as a trusted checkpoint, we have no canonical hash yet so we accept zero hash too
|
// if the CHT was injected as a trusted checkpoint,
|
||||||
|
// we have no canonical hash yet so we accept zero hash too
|
||||||
for chtCount > 0 && canonicalHash != sectionHead && canonicalHash != (common.Hash{}) {
|
for chtCount > 0 && canonicalHash != sectionHead && canonicalHash != (common.Hash{}) {
|
||||||
chtCount--
|
chtCount--
|
||||||
if chtCount > 0 {
|
if chtCount > 0 {
|
||||||
|
|
@ -94,8 +95,7 @@ func GetBodyRLP(ctx context.Context, odr OdrBackend, hash common.Hash, number ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBody retrieves the block body (transactons, uncles) corresponding to the
|
// GetBody retrieves the block body (transactons, uncles) corresponding to the hash.
|
||||||
// hash.
|
|
||||||
func GetBody(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (*types.Body, error) {
|
func GetBody(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (*types.Body, error) {
|
||||||
data, err := GetBodyRLP(ctx, odr, hash, number)
|
data, err := GetBodyRLP(ctx, odr, hash, number)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -173,7 +173,8 @@ func GetBlockLogs(ctx context.Context, odr OdrBackend, hash common.Hash, number
|
||||||
return logs, nil
|
return logs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBloomBits retrieves a batch of compressed bloomBits vectors belonging to the given bit index and section indexes
|
// GetBloomBits retrieves a batch of compressed bloomBits vectors
|
||||||
|
// belonging to the given bit index and section indexes
|
||||||
func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxList []uint64) ([][]byte, error) {
|
func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxList []uint64) ([][]byte, error) {
|
||||||
db := odr.Database()
|
db := odr.Database()
|
||||||
result := make([][]byte, len(sectionIdxList))
|
result := make([][]byte, len(sectionIdxList))
|
||||||
|
|
@ -189,7 +190,8 @@ func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxLi
|
||||||
if odr.BloomTrieIndexer() != nil {
|
if odr.BloomTrieIndexer() != nil {
|
||||||
bloomTrieCount, sectionHeadNum, sectionHead = odr.BloomTrieIndexer().Sections()
|
bloomTrieCount, sectionHeadNum, sectionHead = odr.BloomTrieIndexer().Sections()
|
||||||
canonicalHash := rawdb.ReadCanonicalHash(db, sectionHeadNum)
|
canonicalHash := rawdb.ReadCanonicalHash(db, sectionHeadNum)
|
||||||
// if the BloomTrie was injected as a trusted checkpoint, we have no canonical hash yet so we accept zero hash too
|
// if the BloomTrie was injected as a trusted checkpoint,
|
||||||
|
// we have no canonical hash yet so we accept zero hash too
|
||||||
for bloomTrieCount > 0 && canonicalHash != sectionHead && canonicalHash != (common.Hash{}) {
|
for bloomTrieCount > 0 && canonicalHash != sectionHead && canonicalHash != (common.Hash{}) {
|
||||||
bloomTrieCount--
|
bloomTrieCount--
|
||||||
if bloomTrieCount > 0 {
|
if bloomTrieCount > 0 {
|
||||||
|
|
@ -220,7 +222,12 @@ func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxLi
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
r := &BloomRequest{BloomTrieRoot: GetBloomTrieRoot(db, bloomTrieCount-1, sectionHead), BloomTrieNum: bloomTrieCount - 1, BitIdx: bitIdx, SectionIdxList: reqList}
|
r := &BloomRequest{
|
||||||
|
BloomTrieRoot: GetBloomTrieRoot(db, bloomTrieCount-1, sectionHead),
|
||||||
|
BloomTrieNum: bloomTrieCount - 1,
|
||||||
|
BitIdx: bitIdx,
|
||||||
|
SectionIdxList: reqList,
|
||||||
|
}
|
||||||
if err := odr.Retrieve(ctx, r); err != nil {
|
if err := odr.Retrieve(ctx, r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ type ChtIndexerBackend struct {
|
||||||
trie *trie.Trie
|
trie *trie.Trie
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBloomTrieIndexer creates a BloomTrie chain indexer
|
// NewChtIndexer creates a cht chain indexer
|
||||||
func NewChtIndexer(db ethdb.Database, clientMode bool) *core.ChainIndexer {
|
func NewChtIndexer(db ethdb.Database, clientMode bool) *core.ChainIndexer {
|
||||||
var sectionSize, confirmReq uint64
|
var sectionSize, confirmReq uint64
|
||||||
if clientMode {
|
if clientMode {
|
||||||
|
|
@ -240,7 +240,8 @@ func NewBloomTrieIndexer(db ethdb.Database, clientMode bool) *core.ChainIndexer
|
||||||
}
|
}
|
||||||
backend.bloomTrieRatio = BloomTrieFrequency / backend.parentSectionSize
|
backend.bloomTrieRatio = BloomTrieFrequency / backend.parentSectionSize
|
||||||
backend.sectionHeads = make([]common.Hash, backend.bloomTrieRatio)
|
backend.sectionHeads = make([]common.Hash, backend.bloomTrieRatio)
|
||||||
return core.NewChainIndexer(db, idb, backend, BloomTrieFrequency, confirmReq-ethBloomBitsConfirmations, time.Millisecond*100, "bloomtrie")
|
return core.NewChainIndexer(db, idb, backend, BloomTrieFrequency,
|
||||||
|
confirmReq-ethBloomBitsConfirmations, time.Millisecond*100, "bloomtrie")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset implements core.ChainIndexerBackend
|
// Reset implements core.ChainIndexerBackend
|
||||||
|
|
@ -300,7 +301,8 @@ func (b *BloomTrieIndexerBackend) Commit() error {
|
||||||
b.triedb.Commit(root, false)
|
b.triedb.Commit(root, false)
|
||||||
|
|
||||||
sectionHead := b.sectionHeads[b.bloomTrieRatio-1]
|
sectionHead := b.sectionHeads[b.bloomTrieRatio-1]
|
||||||
log.Info("Storing bloom trie", "section", b.section, "head", sectionHead, "root", root, "compression", float64(compSize)/float64(decompSize))
|
log.Info("Storing bloom trie", "section", b.section, "head", sectionHead,
|
||||||
|
"root", root, "compression", float64(compSize)/float64(decompSize))
|
||||||
StoreBloomTrieRoot(b.diskdb, b.section, sectionHead, root)
|
StoreBloomTrieRoot(b.diskdb, b.section, sectionHead, root)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -416,7 +416,9 @@ func (self *TxPool) add(ctx context.Context, tx *types.Transaction) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a log message if low enough level is set
|
// Print a log message if low enough level is set
|
||||||
log.Debug("Pooled new transaction", "hash", hash, "from", log.Lazy{Fn: func() common.Address { from, _ := types.Sender(self.signer, tx); return from }}, "to", tx.To())
|
log.Debug("Pooled new transaction", "hash", hash,
|
||||||
|
"from", log.Lazy{Fn: func() common.Address { from, _ := types.Sender(self.signer, tx); return from }},
|
||||||
|
"to", tx.To())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue