Skip to content

Commit

Permalink
Merge pull request #14 from sadoci/metadium
Browse files Browse the repository at this point in the history
metadium: fixes for sync issues, pending block issue & chaindata directory name issue
  • Loading branch information
MetadiumRelease committed Apr 14, 2022
2 parents 993beaf + aff46db commit 98df44a
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 203 deletions.
17 changes: 12 additions & 5 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,20 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
func(addr common.Address, amt *big.Int) {
state.AddBalance(addr, amt)
})
if err != nil {
if err == nil {
header.Rewards = rewards
if coinbase != nil {
header.Coinbase = *coinbase
}
} else {
if err == metaminer.ErrNotInitialized {
reward := new(big.Int)
reward.Add(blockReward, header.Fees)
state.AddBalance(header.Coinbase, reward)
return nil
}
return err
}
header.Rewards = rewards
if coinbase != nil {
header.Coinbase = *coinbase
}
}
return nil
}
4 changes: 2 additions & 2 deletions core/metadium_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12333,7 +12333,7 @@ var (
},
"coinbase": "0x378360d4f25E6377f3da53F8cF09e9a258118528",
"config": {
"berlinBlock": 25570000,
"berlinBlock": 80000000,
"chainId": 12,
"homesteadBlock": 0,
"eip150Block": 5623000,
Expand All @@ -12342,7 +12342,7 @@ var (
"byzantiumBlock": 0,
"constantinopleBlock": 5623000,
"istanbulBlock": 5623000,
"londonBlock": 25570000,
"londonBlock": 80000000,
"muirGlacierBlock": 5623000
},
"difficulty": "0x1",
Expand Down
26 changes: 26 additions & 0 deletions core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
package rawdb

import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"path"
"strings"
"sync/atomic"
"time"

Expand Down Expand Up @@ -293,7 +296,24 @@ func NewRocksDBDatabaseWithFreezer(file string, cache int, handles int, freezer
return frdb, nil
}

func detectDb(file string) int {
if f, err := os.Open(path.Join(file, "LOG")); err != nil {
return 0
} else if s, err := bufio.NewReader(f).ReadString('\n'); err != nil {
return 0
} else if strings.Contains(s, "RocksDB version") {
return 2
}
return 1
}

func NewDB(file string, cache int, handles int, namespace string, readonly bool) (ethdb.Database, error) {
switch detectDb(file) {
case 1:
return NewLevelDBDatabase(file, cache, handles, namespace, readonly)
case 2:
return NewRocksDBDatabase(file, cache, handles, namespace, readonly)
}
if params.UseRocksDb != 0 {
return NewRocksDBDatabase(file, cache, handles, namespace, readonly)
} else {
Expand All @@ -302,6 +322,12 @@ func NewDB(file string, cache int, handles int, namespace string, readonly bool)
}

func NewDBWithFreezer(file string, cache int, handles int, freezer string, namespace string, readonly bool) (ethdb.Database, error) {
switch detectDb(file) {
case 1:
return NewLevelDBDatabaseWithFreezer(file, cache, handles, freezer, namespace, readonly)
case 2:
return NewRocksDBDatabaseWithFreezer(file, cache, handles, freezer, namespace, readonly)
}
if params.UseRocksDb != 0 {
return NewRocksDBDatabaseWithFreezer(file, cache, handles, freezer, namespace, readonly)
} else {
Expand Down
Loading

0 comments on commit 98df44a

Please sign in to comment.