mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
remove blocks compression (#1453)
This commit is contained in:
parent
c35b07df3d
commit
6faec7e834
@ -6,11 +6,6 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
compressBlocks bool
|
|
||||||
getCompressBlocks sync.Once
|
|
||||||
)
|
|
||||||
|
|
||||||
// atomic: bit 0 is the value, bit 1 is the initialized flag
|
// atomic: bit 0 is the value, bit 1 is the initialized flag
|
||||||
var getNodeData uint32
|
var getNodeData uint32
|
||||||
|
|
||||||
@ -47,13 +42,6 @@ func OverrideGetNodeData(val bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsBlockCompressionEnabled() bool {
|
|
||||||
getCompressBlocks.Do(func() {
|
|
||||||
_, compressBlocks = os.LookupEnv("COMPRESS_BLOCKS")
|
|
||||||
})
|
|
||||||
return compressBlocks
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testDB string
|
testDB string
|
||||||
getTestDB sync.Once
|
getTestDB sync.Once
|
||||||
|
@ -24,17 +24,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
||||||
"github.com/ledgerwatch/turbo-geth/ethdb/cbor"
|
|
||||||
|
|
||||||
"github.com/ledgerwatch/turbo-geth/common"
|
"github.com/ledgerwatch/turbo-geth/common"
|
||||||
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
||||||
"github.com/ledgerwatch/turbo-geth/common/debug"
|
|
||||||
"github.com/ledgerwatch/turbo-geth/core/types"
|
"github.com/ledgerwatch/turbo-geth/core/types"
|
||||||
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||||||
|
"github.com/ledgerwatch/turbo-geth/ethdb/cbor"
|
||||||
"github.com/ledgerwatch/turbo-geth/log"
|
"github.com/ledgerwatch/turbo-geth/log"
|
||||||
"github.com/ledgerwatch/turbo-geth/rlp"
|
"github.com/ledgerwatch/turbo-geth/rlp"
|
||||||
|
|
||||||
"github.com/golang/snappy"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadCanonicalHash retrieves the hash assigned to a canonical block number.
|
// ReadCanonicalHash retrieves the hash assigned to a canonical block number.
|
||||||
@ -334,9 +330,6 @@ func WriteTransactions(db ethdb.Database, txs []*types.Transaction, baseTxId uin
|
|||||||
|
|
||||||
// WriteBodyRLP stores an RLP encoded block body into the database.
|
// WriteBodyRLP stores an RLP encoded block body into the database.
|
||||||
func WriteBodyRLP(db DatabaseWriter, hash common.Hash, number uint64, rlp rlp.RawValue) {
|
func WriteBodyRLP(db DatabaseWriter, hash common.Hash, number uint64, rlp rlp.RawValue) {
|
||||||
if debug.IsBlockCompressionEnabled() {
|
|
||||||
rlp = snappy.Encode(nil, rlp)
|
|
||||||
}
|
|
||||||
if err := db.Put(dbutils.BlockBodyPrefix, dbutils.BlockBodyKey(number, hash), rlp); err != nil {
|
if err := db.Put(dbutils.BlockBodyPrefix, dbutils.BlockBodyKey(number, hash), rlp); err != nil {
|
||||||
log.Crit("Failed to store block body", "err", err)
|
log.Crit("Failed to store block body", "err", err)
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/snappy"
|
|
||||||
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
||||||
"github.com/ledgerwatch/turbo-geth/common/debug"
|
|
||||||
"github.com/ledgerwatch/turbo-geth/common/etl"
|
"github.com/ledgerwatch/turbo-geth/common/etl"
|
||||||
"github.com/ledgerwatch/turbo-geth/core/types"
|
"github.com/ledgerwatch/turbo-geth/core/types"
|
||||||
"github.com/ledgerwatch/turbo-geth/ethdb"
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||||||
@ -23,18 +21,6 @@ var transactionsTable = Migration{
|
|||||||
defer logEvery.Stop()
|
defer logEvery.Stop()
|
||||||
logPrefix := "tx_table"
|
logPrefix := "tx_table"
|
||||||
|
|
||||||
decompressBlockBody := func(compressed []byte) ([]byte, error) {
|
|
||||||
if !debug.IsBlockCompressionEnabled() || len(compressed) == 0 {
|
|
||||||
return compressed, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var bodyRlp []byte
|
|
||||||
bodyRlp, err = snappy.Decode(nil, compressed)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("err on decode block: %w", err)
|
|
||||||
}
|
|
||||||
return bodyRlp, nil
|
|
||||||
}
|
|
||||||
const loadStep = "load"
|
const loadStep = "load"
|
||||||
reader := bytes.NewReader(nil)
|
reader := bytes.NewReader(nil)
|
||||||
buf := bytes.NewBuffer(make([]byte, 4096))
|
buf := bytes.NewBuffer(make([]byte, 4096))
|
||||||
@ -102,13 +88,7 @@ var transactionsTable = Migration{
|
|||||||
}
|
}
|
||||||
// don't need canonical check
|
// don't need canonical check
|
||||||
|
|
||||||
var bodyRlp []byte
|
reader.Reset(v)
|
||||||
bodyRlp, err = decompressBlockBody(v)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.Reset(bodyRlp)
|
|
||||||
if err = rlp.Decode(reader, body); err != nil {
|
if err = rlp.Decode(reader, body); err != nil {
|
||||||
return false, fmt.Errorf("[%s]: invalid block body RLP: %w", logPrefix, err)
|
return false, fmt.Errorf("[%s]: invalid block body RLP: %w", logPrefix, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user