mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
Merge branch 'juga1980/appendBetter'
This commit is contained in:
commit
f24e6a0730
8 changed files with 19 additions and 16 deletions
|
|
@ -1352,7 +1352,7 @@ const (
|
|||
// will be directly stored in the ancient, getting rid of the chain migration.
|
||||
func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []rlp.RawValue, ancientLimit uint64) (int, error) {
|
||||
// Verify the supplied headers before insertion without lock
|
||||
var headers []*types.Header
|
||||
headers := make([]*types.Header, 0, len(blockChain))
|
||||
for _, block := range blockChain {
|
||||
headers = append(headers, block.Header())
|
||||
// Here we also validate that blob transactions in the block do not
|
||||
|
|
@ -2210,7 +2210,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator, ma
|
|||
}
|
||||
// Import all the pruned blocks to make the state available
|
||||
var (
|
||||
blocks []*types.Block
|
||||
blocks = make([]*types.Block, 0, len(hashes))
|
||||
memory uint64
|
||||
)
|
||||
for i := len(hashes) - 1; i >= 0; i-- {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ func (info *freezerInfo) size() common.StorageSize {
|
|||
|
||||
func inspect(name string, order map[string]freezerTableConfig, reader ethdb.AncientReader) (freezerInfo, error) {
|
||||
info := freezerInfo{name: name}
|
||||
info.sizes = make([]tableSize, 0, len(order))
|
||||
for t := range order {
|
||||
size, err := reader.AncientSize(t)
|
||||
if err != nil {
|
||||
|
|
@ -78,7 +79,7 @@ func inspect(name string, order map[string]freezerTableConfig, reader ethdb.Anci
|
|||
|
||||
// inspectFreezers inspects all freezers registered in the system.
|
||||
func inspectFreezers(db ethdb.Database) ([]freezerInfo, error) {
|
||||
var infos []freezerInfo
|
||||
var infos []freezerInfo = make([]freezerInfo, 0, len(freezers))
|
||||
for _, freezer := range freezers {
|
||||
switch freezer {
|
||||
case ChainFreezerName:
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ func iterateTransactions(db ethdb.Database, from uint64, to uint64, reverse bool
|
|||
log.Warn("Failed to decode block body", "block", data.number, "error", err)
|
||||
return
|
||||
}
|
||||
var hashes []common.Hash
|
||||
var hashes []common.Hash = make([]common.Hash, 0, len(body.Transactions))
|
||||
for _, tx := range body.Transactions {
|
||||
hashes = append(hashes, tx.Hash())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -936,7 +936,7 @@ func (t *freezerTable) getIndices(from, count uint64) ([]*indexEntry, error) {
|
|||
return nil, err
|
||||
}
|
||||
var (
|
||||
indices []*indexEntry
|
||||
indices = make([]*indexEntry, 0, count+1)
|
||||
offset int
|
||||
)
|
||||
for i := from; i <= from+count; i++ {
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ func (p *BlobPool) parseTransaction(id uint64, size uint32, blob []byte) error {
|
|||
}
|
||||
|
||||
// recheck verifies the pool's content for a specific account and drops anything
|
||||
// that does not fit anymore (dangling or filled nonce, overdraft).
|
||||
// that does not fit anymore (dangling or filled nonce, overdraft). // TODO split long method in smaller parts
|
||||
func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint64) {
|
||||
// Sort the transactions belonging to the account so reinjects can be simpler
|
||||
txs := p.index[addr]
|
||||
|
|
@ -541,8 +541,8 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
|
|||
)
|
||||
if gapped || filled {
|
||||
var (
|
||||
ids []uint64
|
||||
nonces []uint64
|
||||
ids []uint64 = make([]uint64, 0, len(txs))
|
||||
nonces []uint64 = make([]uint64, 0, len(txs))
|
||||
)
|
||||
for i := 0; i < len(txs); i++ {
|
||||
ids = append(ids, txs[i].id)
|
||||
|
|
@ -659,8 +659,8 @@ func (p *BlobPool) recheck(addr common.Address, inclusions map[common.Hash]uint6
|
|||
}
|
||||
// Otherwise if there's a nonce gap evict all later transactions
|
||||
var (
|
||||
ids []uint64
|
||||
nonces []uint64
|
||||
ids []uint64 = make([]uint64, 0, len(txs))
|
||||
nonces []uint64 = make([]uint64, 0, len(txs))
|
||||
)
|
||||
for j := i; j < len(txs); j++ {
|
||||
ids = append(ids, txs[j].id)
|
||||
|
|
|
|||
|
|
@ -645,9 +645,10 @@ func runBn256Pairing(input []byte) ([]byte, error) {
|
|||
return nil, errBadPairingInput
|
||||
}
|
||||
// Convert the input into a set of coordinates
|
||||
howMuch := len(input) / 192
|
||||
var (
|
||||
cs []*bn256.G1
|
||||
ts []*bn256.G2
|
||||
cs []*bn256.G1 = make([]*bn256.G1, 0, howMuch)
|
||||
ts []*bn256.G2 = make([]*bn256.G2, 0, howMuch)
|
||||
)
|
||||
for i := 0; i < len(input); i += 192 {
|
||||
c, err := newCurvePoint(input[i : i+64])
|
||||
|
|
@ -976,8 +977,8 @@ func (c *bls12381Pairing) Run(input []byte) ([]byte, error) {
|
|||
}
|
||||
|
||||
var (
|
||||
p []bls12381.G1Affine
|
||||
q []bls12381.G2Affine
|
||||
p []bls12381.G1Affine = make([]bls12381.G1Affine, 0, k)
|
||||
q []bls12381.G2Affine = make([]bls12381.G2Affine, 0, k)
|
||||
)
|
||||
|
||||
// Decode pairs
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func ValidEip(eipNum int) bool {
|
|||
return ok
|
||||
}
|
||||
func ActivateableEips() []string {
|
||||
var nums []string
|
||||
nums := make([]string, 0, len(activators))
|
||||
for k := range activators {
|
||||
nums = append(nums, fmt.Sprintf("%d", k))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,11 +136,12 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
|||
default:
|
||||
table = &frontierInstructionSet
|
||||
}
|
||||
var extraEips []int
|
||||
extraEips := make([]int, 0, len(evm.Config.ExtraEips))
|
||||
if len(evm.Config.ExtraEips) > 0 {
|
||||
// Deep-copy jumptable to prevent modification of opcodes in other tables
|
||||
table = copyJumpTable(table)
|
||||
}
|
||||
|
||||
for _, eip := range evm.Config.ExtraEips {
|
||||
if err := EnableEIP(eip, table); err != nil {
|
||||
// Disable it, so caller can check if it's activated or not
|
||||
|
|
|
|||
Loading…
Reference in a new issue