|
@@ -14,7 +14,7 @@ import (
|
|
|
"sync/atomic"
|
|
"sync/atomic"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
- "github.com/ethereum/go-ethereum/chain"
|
|
|
|
|
|
|
+ "github.com/ethereum/go-ethereum/core"
|
|
|
"github.com/ethereum/go-ethereum/crypto"
|
|
"github.com/ethereum/go-ethereum/crypto"
|
|
|
"github.com/ethereum/go-ethereum/ethutil"
|
|
"github.com/ethereum/go-ethereum/ethutil"
|
|
|
"github.com/ethereum/go-ethereum/event"
|
|
"github.com/ethereum/go-ethereum/event"
|
|
@@ -50,12 +50,12 @@ type Ethereum struct {
|
|
|
// DB interface
|
|
// DB interface
|
|
|
db ethutil.Database
|
|
db ethutil.Database
|
|
|
// State manager for processing new blocks and managing the over all states
|
|
// State manager for processing new blocks and managing the over all states
|
|
|
- blockManager *chain.BlockManager
|
|
|
|
|
|
|
+ blockManager *core.BlockManager
|
|
|
// The transaction pool. Transaction can be pushed on this pool
|
|
// The transaction pool. Transaction can be pushed on this pool
|
|
|
// for later including in the blocks
|
|
// for later including in the blocks
|
|
|
- txPool *chain.TxPool
|
|
|
|
|
|
|
+ txPool *core.TxPool
|
|
|
// The canonical chain
|
|
// The canonical chain
|
|
|
- blockChain *chain.ChainManager
|
|
|
|
|
|
|
+ blockChain *core.ChainManager
|
|
|
// The block pool
|
|
// The block pool
|
|
|
blockPool *BlockPool
|
|
blockPool *BlockPool
|
|
|
// Eventer
|
|
// Eventer
|
|
@@ -94,7 +94,7 @@ type Ethereum struct {
|
|
|
|
|
|
|
|
filterMu sync.RWMutex
|
|
filterMu sync.RWMutex
|
|
|
filterId int
|
|
filterId int
|
|
|
- filters map[int]*chain.Filter
|
|
|
|
|
|
|
+ filters map[int]*core.Filter
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *crypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) {
|
|
func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *crypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) {
|
|
@@ -124,13 +124,13 @@ func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *cr
|
|
|
keyManager: keyManager,
|
|
keyManager: keyManager,
|
|
|
clientIdentity: clientIdentity,
|
|
clientIdentity: clientIdentity,
|
|
|
isUpToDate: true,
|
|
isUpToDate: true,
|
|
|
- filters: make(map[int]*chain.Filter),
|
|
|
|
|
|
|
+ filters: make(map[int]*core.Filter),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ethereum.blockPool = NewBlockPool(ethereum)
|
|
ethereum.blockPool = NewBlockPool(ethereum)
|
|
|
- ethereum.txPool = chain.NewTxPool(ethereum)
|
|
|
|
|
- ethereum.blockChain = chain.NewChainManager(ethereum.EventMux())
|
|
|
|
|
- ethereum.blockManager = chain.NewBlockManager(ethereum)
|
|
|
|
|
|
|
+ ethereum.txPool = core.NewTxPool(ethereum)
|
|
|
|
|
+ ethereum.blockChain = core.NewChainManager(ethereum.EventMux())
|
|
|
|
|
+ ethereum.blockManager = core.NewBlockManager(ethereum)
|
|
|
ethereum.blockChain.SetProcessor(ethereum.blockManager)
|
|
ethereum.blockChain.SetProcessor(ethereum.blockManager)
|
|
|
|
|
|
|
|
// Start the tx pool
|
|
// Start the tx pool
|
|
@@ -147,15 +147,15 @@ func (s *Ethereum) ClientIdentity() wire.ClientIdentity {
|
|
|
return s.clientIdentity
|
|
return s.clientIdentity
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (s *Ethereum) ChainManager() *chain.ChainManager {
|
|
|
|
|
|
|
+func (s *Ethereum) ChainManager() *core.ChainManager {
|
|
|
return s.blockChain
|
|
return s.blockChain
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (s *Ethereum) BlockManager() *chain.BlockManager {
|
|
|
|
|
|
|
+func (s *Ethereum) BlockManager() *core.BlockManager {
|
|
|
return s.blockManager
|
|
return s.blockManager
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (s *Ethereum) TxPool() *chain.TxPool {
|
|
|
|
|
|
|
+func (s *Ethereum) TxPool() *core.TxPool {
|
|
|
return s.txPool
|
|
return s.txPool
|
|
|
}
|
|
}
|
|
|
func (s *Ethereum) BlockPool() *BlockPool {
|
|
func (s *Ethereum) BlockPool() *BlockPool {
|
|
@@ -591,7 +591,7 @@ out:
|
|
|
// InstallFilter adds filter for blockchain events.
|
|
// InstallFilter adds filter for blockchain events.
|
|
|
// The filter's callbacks will run for matching blocks and messages.
|
|
// The filter's callbacks will run for matching blocks and messages.
|
|
|
// The filter should not be modified after it has been installed.
|
|
// The filter should not be modified after it has been installed.
|
|
|
-func (self *Ethereum) InstallFilter(filter *chain.Filter) (id int) {
|
|
|
|
|
|
|
+func (self *Ethereum) InstallFilter(filter *core.Filter) (id int) {
|
|
|
self.filterMu.Lock()
|
|
self.filterMu.Lock()
|
|
|
id = self.filterId
|
|
id = self.filterId
|
|
|
self.filters[id] = filter
|
|
self.filters[id] = filter
|
|
@@ -608,7 +608,7 @@ func (self *Ethereum) UninstallFilter(id int) {
|
|
|
|
|
|
|
|
// GetFilter retrieves a filter installed using InstallFilter.
|
|
// GetFilter retrieves a filter installed using InstallFilter.
|
|
|
// The filter may not be modified.
|
|
// The filter may not be modified.
|
|
|
-func (self *Ethereum) GetFilter(id int) *chain.Filter {
|
|
|
|
|
|
|
+func (self *Ethereum) GetFilter(id int) *core.Filter {
|
|
|
self.filterMu.RLock()
|
|
self.filterMu.RLock()
|
|
|
defer self.filterMu.RUnlock()
|
|
defer self.filterMu.RUnlock()
|
|
|
return self.filters[id]
|
|
return self.filters[id]
|
|
@@ -616,10 +616,10 @@ func (self *Ethereum) GetFilter(id int) *chain.Filter {
|
|
|
|
|
|
|
|
func (self *Ethereum) filterLoop() {
|
|
func (self *Ethereum) filterLoop() {
|
|
|
// Subscribe to events
|
|
// Subscribe to events
|
|
|
- events := self.eventMux.Subscribe(chain.NewBlockEvent{}, state.Messages(nil))
|
|
|
|
|
|
|
+ events := self.eventMux.Subscribe(core.NewBlockEvent{}, state.Messages(nil))
|
|
|
for event := range events.Chan() {
|
|
for event := range events.Chan() {
|
|
|
switch event := event.(type) {
|
|
switch event := event.(type) {
|
|
|
- case chain.NewBlockEvent:
|
|
|
|
|
|
|
+ case core.NewBlockEvent:
|
|
|
self.filterMu.RLock()
|
|
self.filterMu.RLock()
|
|
|
for _, filter := range self.filters {
|
|
for _, filter := range self.filters {
|
|
|
if filter.BlockCallback != nil {
|
|
if filter.BlockCallback != nil {
|