aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 7a30902c9..346fc43bc 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -112,9 +112,10 @@ type Ethereum struct {
// Channel for shutting down the ethereum
shutdownChan chan bool
- // DB interface
- blockDb ethutil.Database
- stateDb ethutil.Database
+ // DB interfaces
+ blockDb ethutil.Database // Block chain database
+ stateDb ethutil.Database // State changes database
+ extraDb ethutil.Database // Extra database (txs, etc)
//*** SERVICES ***
// State manager for processing new blocks and managing the over all states
@@ -136,6 +137,7 @@ type Ethereum struct {
Mining bool
DataDir string
+ version string
}
func New(config *Config) (*Ethereum, error) {
@@ -154,6 +156,7 @@ func New(config *Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
+ extraDb, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "extra"))
// Perform database sanity checks
d, _ := blockDb.Get([]byte("ProtocolVersion"))
@@ -162,24 +165,24 @@ func New(config *Config) (*Ethereum, error) {
path := path.Join(config.DataDir, "blockchain")
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, path)
}
-
- saveProtocolVersion(blockDb)
- //ethutil.Config.Db = db
+ saveProtocolVersion(extraDb)
eth := &Ethereum{
shutdownChan: make(chan bool),
blockDb: blockDb,
stateDb: stateDb,
+ extraDb: extraDb,
eventMux: &event.TypeMux{},
logger: servlogger,
accountManager: config.AccountManager,
DataDir: config.DataDir,
+ version: config.Name, // TODO should separate from Name
}
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
eth.pow = ethash.New(eth.chainManager)
eth.txPool = core.NewTxPool(eth.EventMux())
- eth.blockProcessor = core.NewBlockProcessor(stateDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
+ eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
eth.chainManager.SetProcessor(eth.blockProcessor)
eth.whisper = whisper.New()
eth.miner = miner.New(eth, eth.pow, config.MinerThreads)
@@ -245,10 +248,12 @@ func (s *Ethereum) Whisper() *whisper.Whisper { return s.whisper }
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
func (s *Ethereum) BlockDb() ethutil.Database { return s.blockDb }
func (s *Ethereum) StateDb() ethutil.Database { return s.stateDb }
+func (s *Ethereum) ExtraDb() ethutil.Database { return s.extraDb }
func (s *Ethereum) IsListening() bool { return true } // Always listening
func (s *Ethereum) PeerCount() int { return s.net.PeerCount() }
func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() }
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
+func (s *Ethereum) Version() string { return s.version }
// Start the ethereum
func (s *Ethereum) Start() error {