diff --git a/light/lightchain.go b/light/lightchain.go index 9d0a4e4f73..6bbcba12bd 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -104,7 +104,8 @@ func NewLightChain(odr OdrBackend, config *params.ChainConfig, engine consensus. if err := bc.loadLastState(); err != nil { 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 { if header := bc.GetHeaderByHash(hash); header != nil { log.Error("Found bad hash, rewinding chain", "number", header.Number, "hash", header.ParentHash) diff --git a/light/odr_util.go b/light/odr_util.go index 620af63835..221a76f3dc 100644 --- a/light/odr_util.go +++ b/light/odr_util.go @@ -49,7 +49,8 @@ func GetHeaderByNumber(ctx context.Context, odr OdrBackend, number uint64) (*typ if odr.ChtIndexer() != nil { chtCount, sectionHeadNum, sectionHead = odr.ChtIndexer().Sections() 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{}) { chtCount-- 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 -// hash. +// GetBody retrieves the block body (transactons, uncles) corresponding to the hash. func GetBody(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (*types.Body, error) { data, err := GetBodyRLP(ctx, odr, hash, number) if err != nil { @@ -173,7 +173,8 @@ func GetBlockLogs(ctx context.Context, odr OdrBackend, hash common.Hash, number 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) { db := odr.Database() result := make([][]byte, len(sectionIdxList)) @@ -189,7 +190,8 @@ func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxLi if odr.BloomTrieIndexer() != nil { bloomTrieCount, sectionHeadNum, sectionHead = odr.BloomTrieIndexer().Sections() 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{}) { bloomTrieCount-- if bloomTrieCount > 0 { @@ -220,7 +222,12 @@ func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxLi 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 { return nil, err } else { diff --git a/light/postprocess.go b/light/postprocess.go index c06c18027e..3b6df2606b 100644 --- a/light/postprocess.go +++ b/light/postprocess.go @@ -126,7 +126,7 @@ type ChtIndexerBackend struct { trie *trie.Trie } -// NewBloomTrieIndexer creates a BloomTrie chain indexer +// NewChtIndexer creates a cht chain indexer func NewChtIndexer(db ethdb.Database, clientMode bool) *core.ChainIndexer { var sectionSize, confirmReq uint64 if clientMode { @@ -240,7 +240,8 @@ func NewBloomTrieIndexer(db ethdb.Database, clientMode bool) *core.ChainIndexer } backend.bloomTrieRatio = BloomTrieFrequency / backend.parentSectionSize 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 @@ -300,7 +301,8 @@ func (b *BloomTrieIndexerBackend) Commit() error { b.triedb.Commit(root, false) 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) return nil diff --git a/light/txpool.go b/light/txpool.go index 1fabc3dc5a..89528a0418 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -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 - 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 }