aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
Diffstat (limited to 'eth')
-rw-r--r--eth/api_backend.go30
-rw-r--r--eth/backend.go62
-rw-r--r--eth/bad_block.go2
-rw-r--r--eth/bind.go10
-rw-r--r--eth/db_upgrade.go2
-rw-r--r--eth/downloader/downloader.go27
-rw-r--r--eth/downloader/downloader_test.go2
-rw-r--r--eth/filters/api.go30
-rw-r--r--eth/filters/filter.go91
-rw-r--r--eth/filters/filter_system.go82
-rw-r--r--eth/filters/filter_system_test.go40
-rw-r--r--eth/filters/filter_test.go36
-rw-r--r--eth/gasprice/lightprice.go160
-rw-r--r--eth/handler.go10
-rw-r--r--eth/handler_test.go2
-rw-r--r--eth/helper_test.go2
16 files changed, 470 insertions, 118 deletions
diff --git a/eth/api_backend.go b/eth/api_backend.go
index 42b84bf9b..efe9a7a01 100644
--- a/eth/api_backend.go
+++ b/eth/api_backend.go
@@ -1,18 +1,18 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of the go-ethereum library.
//
-// go-ethereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
+// GNU Lesser General Public License for more details.
//
-// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package eth
@@ -44,17 +44,17 @@ func (b *EthApiBackend) SetHead(number uint64) {
b.eth.blockchain.SetHead(number)
}
-func (b *EthApiBackend) HeaderByNumber(blockNr rpc.BlockNumber) *types.Header {
+func (b *EthApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) {
// Pending block is only known by the miner
if blockNr == rpc.PendingBlockNumber {
block, _ := b.eth.miner.Pending()
- return block.Header()
+ return block.Header(), nil
}
// Otherwise resolve and return the block
if blockNr == rpc.LatestBlockNumber {
- return b.eth.blockchain.CurrentBlock().Header()
+ return b.eth.blockchain.CurrentBlock().Header(), nil
}
- return b.eth.blockchain.GetHeaderByNumber(uint64(blockNr))
+ return b.eth.blockchain.GetHeaderByNumber(uint64(blockNr)), nil
}
func (b *EthApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error) {
@@ -70,16 +70,16 @@ func (b *EthApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumb
return b.eth.blockchain.GetBlockByNumber(uint64(blockNr)), nil
}
-func (b *EthApiBackend) StateAndHeaderByNumber(blockNr rpc.BlockNumber) (ethapi.State, *types.Header, error) {
+func (b *EthApiBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (ethapi.State, *types.Header, error) {
// Pending state is only known by the miner
if blockNr == rpc.PendingBlockNumber {
block, state := b.eth.miner.Pending()
return EthApiState{state}, block.Header(), nil
}
// Otherwise resolve the block number and return its state
- header := b.HeaderByNumber(blockNr)
- if header == nil {
- return nil, nil, nil
+ header, err := b.HeaderByNumber(ctx, blockNr)
+ if header == nil || err != nil {
+ return nil, nil, err
}
stateDb, err := b.eth.BlockChain().StateAt(header.Root)
return EthApiState{stateDb}, header, err
diff --git a/eth/backend.go b/eth/backend.go
index 24419d6d8..ec501043a 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -66,9 +66,13 @@ var (
type Config struct {
ChainConfig *core.ChainConfig // chain configuration
- NetworkId int // Network ID to use for selecting peers to connect to
- Genesis string // Genesis JSON to seed the chain database with
- FastSync bool // Enables the state download based fast synchronisation algorithm
+ NetworkId int // Network ID to use for selecting peers to connect to
+ Genesis string // Genesis JSON to seed the chain database with
+ FastSync bool // Enables the state download based fast synchronisation algorithm
+ LightMode bool // Running in light client mode
+ LightServ int // Maximum percentage of time allowed for serving LES requests
+ LightPeers int // Maximum number of LES client peers
+ MaxPeers int // Maximum number of global peers
SkipBcVersionCheck bool // e.g. blockchain export
DatabaseCache int
@@ -100,6 +104,12 @@ type Config struct {
TestGenesisState ethdb.Database // Genesis state to seed the database with (testing only!)
}
+type LesServer interface {
+ Start(srvr *p2p.Server)
+ Stop()
+ Protocols() []p2p.Protocol
+}
+
// Ethereum implements the Ethereum full node service.
type Ethereum struct {
chainConfig *core.ChainConfig
@@ -111,6 +121,7 @@ type Ethereum struct {
txMu sync.Mutex
blockchain *core.BlockChain
protocolManager *ProtocolManager
+ lesServer LesServer
// DB interfaces
chainDb ethdb.Database // Block chain database
@@ -119,7 +130,7 @@ type Ethereum struct {
httpclient *httpclient.HTTPClient
accountManager *accounts.Manager
- apiBackend *EthApiBackend
+ ApiBackend *EthApiBackend
miner *miner.Miner
Mining bool
@@ -135,10 +146,14 @@ type Ethereum struct {
netRPCService *ethapi.PublicNetAPI
}
+func (s *Ethereum) AddLesServer(ls LesServer) {
+ s.lesServer = ls
+}
+
// New creates a new Ethereum object (including the
// initialisation of the common Ethereum object)
func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
- chainDb, err := createDB(ctx, config)
+ chainDb, err := CreateDB(ctx, config, "chaindata")
if err != nil {
return nil, err
}
@@ -217,7 +232,18 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
newPool := core.NewTxPool(eth.chainConfig, eth.EventMux(), eth.blockchain.State, eth.blockchain.GasLimit)
eth.txPool = newPool
- if eth.protocolManager, err = NewProtocolManager(eth.chainConfig, config.FastSync, config.NetworkId, eth.eventMux, eth.txPool, eth.pow, eth.blockchain, chainDb); err != nil {
+ maxPeers := config.MaxPeers
+ if config.LightServ > 0 {
+ // if we are running a light server, limit the number of ETH peers so that we reserve some space for incoming LES connections
+ // temporary solution until the new peer connectivity API is finished
+ halfPeers := maxPeers / 2
+ maxPeers -= config.LightPeers
+ if maxPeers < halfPeers {
+ maxPeers = halfPeers
+ }
+ }
+
+ if eth.protocolManager, err = NewProtocolManager(eth.chainConfig, config.FastSync, config.NetworkId, maxPeers, eth.eventMux, eth.txPool, eth.pow, eth.blockchain, chainDb); err != nil {
return nil, err
}
eth.miner = miner.New(eth, eth.chainConfig, eth.EventMux(), eth.pow)
@@ -233,14 +259,14 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
GpobaseCorrectionFactor: config.GpobaseCorrectionFactor,
}
gpo := gasprice.NewGasPriceOracle(eth.blockchain, chainDb, eth.eventMux, gpoParams)
- eth.apiBackend = &EthApiBackend{eth, gpo}
+ eth.ApiBackend = &EthApiBackend{eth, gpo}
return eth, nil
}
-// createDB creates the chain database.
-func createDB(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) {
- db, err := ctx.OpenDatabase("chaindata", config.DatabaseCache, config.DatabaseHandles)
+// CreateDB creates the chain database.
+func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) {
+ db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles)
if db, ok := db.(*ethdb.LDBDatabase); ok {
db.Meter("eth/db/chaindata/")
}
@@ -288,7 +314,7 @@ func CreatePoW(config *Config) (*ethash.Ethash, error) {
// APIs returns the collection of RPC services the ethereum package offers.
// NOTE, some of these services probably need to be moved to somewhere else.
func (s *Ethereum) APIs() []rpc.API {
- return append(ethapi.GetAPIs(s.apiBackend, s.solcPath), []rpc.API{
+ return append(ethapi.GetAPIs(s.ApiBackend, s.solcPath), []rpc.API{
{
Namespace: "eth",
Version: "1.0",
@@ -312,7 +338,7 @@ func (s *Ethereum) APIs() []rpc.API {
}, {
Namespace: "eth",
Version: "1.0",
- Service: filters.NewPublicFilterAPI(s.chainDb, s.eventMux),
+ Service: filters.NewPublicFilterAPI(s.ApiBackend, false),
Public: true,
}, {
Namespace: "admin",
@@ -391,7 +417,11 @@ func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManage
// Protocols implements node.Service, returning all the currently configured
// network protocols to start.
func (s *Ethereum) Protocols() []p2p.Protocol {
- return s.protocolManager.SubProtocols
+ if s.lesServer == nil {
+ return s.protocolManager.SubProtocols
+ } else {
+ return append(s.protocolManager.SubProtocols, s.lesServer.Protocols()...)
+ }
}
// Start implements node.Service, starting all internal goroutines needed by the
@@ -402,6 +432,9 @@ func (s *Ethereum) Start(srvr *p2p.Server) error {
s.StartAutoDAG()
}
s.protocolManager.Start()
+ if s.lesServer != nil {
+ s.lesServer.Start(srvr)
+ }
return nil
}
@@ -413,6 +446,9 @@ func (s *Ethereum) Stop() error {
}
s.blockchain.Stop()
s.protocolManager.Stop()
+ if s.lesServer != nil {
+ s.lesServer.Stop()
+ }
s.txPool.Stop()
s.miner.Stop()
s.eventMux.Stop()
diff --git a/eth/bad_block.go b/eth/bad_block.go
index 3a6c3d85c..e0f05f540 100644
--- a/eth/bad_block.go
+++ b/eth/bad_block.go
@@ -1,4 +1,4 @@
-// Copyright 2015 The go-ethereum Authors
+// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
diff --git a/eth/bind.go b/eth/bind.go
index 532e94460..747965d37 100644
--- a/eth/bind.go
+++ b/eth/bind.go
@@ -1,4 +1,4 @@
-// Copyright 2016 The go-ethereum Authors
+// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
@@ -43,11 +43,11 @@ type ContractBackend struct {
// NewContractBackend creates a new native contract backend using an existing
// Etheruem object.
-func NewContractBackend(eth *Ethereum) *ContractBackend {
+func NewContractBackend(apiBackend ethapi.Backend) *ContractBackend {
return &ContractBackend{
- eapi: ethapi.NewPublicEthereumAPI(eth.apiBackend),
- bcapi: ethapi.NewPublicBlockChainAPI(eth.apiBackend),
- txapi: ethapi.NewPublicTransactionPoolAPI(eth.apiBackend),
+ eapi: ethapi.NewPublicEthereumAPI(apiBackend),
+ bcapi: ethapi.NewPublicBlockChainAPI(apiBackend),
+ txapi: ethapi.NewPublicTransactionPoolAPI(apiBackend),
}
}
diff --git a/eth/db_upgrade.go b/eth/db_upgrade.go
index 172bb0954..5fd73a586 100644
--- a/eth/db_upgrade.go
+++ b/eth/db_upgrade.go
@@ -1,4 +1,4 @@
-// Copyright 2014 The go-ethereum Authors
+// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index da20e48a2..b1f4b8169 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -164,13 +164,13 @@ type Downloader struct {
}
// New creates a new downloader to fetch hashes and blocks from remote peers.
-func New(stateDb ethdb.Database, mux *event.TypeMux, hasHeader headerCheckFn, hasBlockAndState blockAndStateCheckFn,
+func New(mode SyncMode, stateDb ethdb.Database, mux *event.TypeMux, hasHeader headerCheckFn, hasBlockAndState blockAndStateCheckFn,
getHeader headerRetrievalFn, getBlock blockRetrievalFn, headHeader headHeaderRetrievalFn, headBlock headBlockRetrievalFn,
headFastBlock headFastBlockRetrievalFn, commitHeadBlock headBlockCommitterFn, getTd tdRetrievalFn, insertHeaders headerChainInsertFn,
insertBlocks blockChainInsertFn, insertReceipts receiptChainInsertFn, rollback chainRollbackFn, dropPeer peerDropFn) *Downloader {
dl := &Downloader{
- mode: FullSync,
+ mode: mode,
mux: mux,
queue: newQueue(stateDb),
peers: newPeerSet(),
@@ -1179,10 +1179,23 @@ func (d *Downloader) processHeaders(origin uint64, td *big.Int) error {
for i, header := range rollback {
hashes[i] = header.Hash()
}
- lastHeader, lastFastBlock, lastBlock := d.headHeader().Number, d.headFastBlock().Number(), d.headBlock().Number()
+ lastHeader, lastFastBlock, lastBlock := d.headHeader().Number, common.Big0, common.Big0
+ if d.headFastBlock != nil {
+ lastFastBlock = d.headFastBlock().Number()
+ }
+ if d.headBlock != nil {
+ lastBlock = d.headBlock().Number()
+ }
d.rollback(hashes)
+ curFastBlock, curBlock := common.Big0, common.Big0
+ if d.headFastBlock != nil {
+ curFastBlock = d.headFastBlock().Number()
+ }
+ if d.headBlock != nil {
+ curBlock = d.headBlock().Number()
+ }
glog.V(logger.Warn).Infof("Rolled back %d headers (LH: %d->%d, FB: %d->%d, LB: %d->%d)",
- len(hashes), lastHeader, d.headHeader().Number, lastFastBlock, d.headFastBlock().Number(), lastBlock, d.headBlock().Number())
+ len(hashes), lastHeader, d.headHeader().Number, lastFastBlock, curFastBlock, lastBlock, curBlock)
// If we're already past the pivot point, this could be an attack, thread carefully
if rollback[len(rollback)-1].Number.Uint64() > pivot {
@@ -1229,8 +1242,10 @@ func (d *Downloader) processHeaders(origin uint64, td *big.Int) error {
// L: Sync begins, and finds common ancestor at 11
// L: Request new headers up from 11 (R's TD was higher, it must have something)
// R: Nothing to give
- if !gotHeaders && td.Cmp(d.getTd(d.headBlock().Hash())) > 0 {
- return errStallingPeer
+ if d.mode != LightSync {
+ if !gotHeaders && td.Cmp(d.getTd(d.headBlock().Hash())) > 0 {
+ return errStallingPeer
+ }
}
// If fast or light syncing, ensure promised headers are indeed delivered. This is
// needed to detect scenarios where an attacker feeds a bad pivot and then bails out
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index 2849712ab..ff8cd1044 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -96,7 +96,7 @@ func newTester() *downloadTester {
tester.stateDb, _ = ethdb.NewMemDatabase()
tester.stateDb.Put(genesis.Root().Bytes(), []byte{0x00})
- tester.downloader = New(tester.stateDb, new(event.TypeMux), tester.hasHeader, tester.hasBlock, tester.getHeader,
+ tester.downloader = New(FullSync, tester.stateDb, new(event.TypeMux), tester.hasHeader, tester.hasBlock, tester.getHeader,
tester.getBlock, tester.headHeader, tester.headBlock, tester.headFastBlock, tester.commitHeadBlock, tester.getTd,
tester.insertHeaders, tester.insertBlocks, tester.insertReceipts, tester.rollback, tester.dropPeer)
diff --git a/eth/filters/api.go b/eth/filters/api.go
index 3bc220348..834513262 100644
--- a/eth/filters/api.go
+++ b/eth/filters/api.go
@@ -52,6 +52,8 @@ type filter struct {
// PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various
// information related to the Ethereum protocol such als blocks, transactions and logs.
type PublicFilterAPI struct {
+ backend Backend
+ useMipMap bool
mux *event.TypeMux
quit chan struct{}
chainDb ethdb.Database
@@ -61,12 +63,14 @@ type PublicFilterAPI struct {
}
// NewPublicFilterAPI returns a new PublicFilterAPI instance.
-func NewPublicFilterAPI(chainDb ethdb.Database, mux *event.TypeMux) *PublicFilterAPI {
+func NewPublicFilterAPI(backend Backend, lightMode bool) *PublicFilterAPI {
api := &PublicFilterAPI{
- mux: mux,
- chainDb: chainDb,
- events: NewEventSystem(mux),
- filters: make(map[rpc.ID]*filter),
+ backend: backend,
+ useMipMap: !lightMode,
+ mux: backend.EventMux(),
+ chainDb: backend.ChainDb(),
+ events: NewEventSystem(backend.EventMux(), backend, lightMode),
+ filters: make(map[rpc.ID]*filter),
}
go api.timeoutLoop()
@@ -314,7 +318,7 @@ func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) rpc.ID {
// GetLogs returns logs matching the given argument that are stored within the state.
//
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs
-func (api *PublicFilterAPI) GetLogs(crit FilterCriteria) []Log {
+func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]Log, error) {
if crit.FromBlock == nil {
crit.FromBlock = big.NewInt(rpc.LatestBlockNumber.Int64())
}
@@ -322,13 +326,14 @@ func (api *PublicFilterAPI) GetLogs(crit FilterCriteria) []Log {
crit.ToBlock = big.NewInt(rpc.LatestBlockNumber.Int64())
}
- filter := New(api.chainDb)
+ filter := New(api.backend, api.useMipMap)
filter.SetBeginBlock(crit.FromBlock.Int64())
filter.SetEndBlock(crit.ToBlock.Int64())
filter.SetAddresses(crit.Addresses)
filter.SetTopics(crit.Topics)
- return returnLogs(filter.Find())
+ logs, err := filter.Find(ctx)
+ return returnLogs(logs), err
}
// UninstallFilter removes the filter with the given filter id.
@@ -352,22 +357,23 @@ func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool {
// If the filter could not be found an empty array of logs is returned.
//
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
-func (api *PublicFilterAPI) GetFilterLogs(id rpc.ID) []Log {
+func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]Log, error) {
api.filtersMu.Lock()
f, found := api.filters[id]
api.filtersMu.Unlock()
if !found || f.typ != LogsSubscription {
- return []Log{}
+ return []Log{}, nil
}
- filter := New(api.chainDb)
+ filter := New(api.backend, api.useMipMap)
filter.SetBeginBlock(f.crit.FromBlock.Int64())
filter.SetEndBlock(f.crit.ToBlock.Int64())
filter.SetAddresses(f.crit.Addresses)
filter.SetTopics(f.crit.Topics)
- return returnLogs(filter.Find())
+ logs, err := filter.Find(ctx)
+ return returnLogs(logs), err
}
// GetFilterChanges returns the logs for the filter with the given id since
diff --git a/eth/filters/filter.go b/eth/filters/filter.go
index 4226620dc..4004af300 100644
--- a/eth/filters/filter.go
+++ b/eth/filters/filter.go
@@ -24,10 +24,23 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/event"
+ "github.com/ethereum/go-ethereum/rpc"
+ "golang.org/x/net/context"
)
+type Backend interface {
+ ChainDb() ethdb.Database
+ EventMux() *event.TypeMux
+ HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
+ GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error)
+}
+
// Filter can be used to retrieve and filter logs
type Filter struct {
+ backend Backend
+ useMipMap bool
+
created time.Time
db ethdb.Database
@@ -38,8 +51,12 @@ type Filter struct {
// New creates a new filter which uses a bloom filter on blocks to figure out whether
// a particular block is interesting or not.
-func New(db ethdb.Database) *Filter {
- return &Filter{db: db}
+func New(backend Backend, useMipMap bool) *Filter {
+ return &Filter{
+ backend: backend,
+ useMipMap: useMipMap,
+ db: backend.ChainDb(),
+ }
}
// SetBeginBlock sets the earliest block for filtering.
@@ -66,30 +83,29 @@ func (f *Filter) SetTopics(topics [][]common.Hash) {
}
// Run filters logs with the current parameters set
-func (f *Filter) Find() []Log {
- latestHash := core.GetHeadBlockHash(f.db)
- latestBlock := core.GetBlock(f.db, latestHash, core.GetBlockNumber(f.db, latestHash))
- if latestBlock == nil {
- return []Log{}
+func (f *Filter) Find(ctx context.Context) ([]Log, error) {
+ head, _ := f.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
+ if head == nil {
+ return nil, nil
}
+ headBlockNumber := head.Number.Uint64()
var beginBlockNo uint64 = uint64(f.begin)
if f.begin == -1 {
- beginBlockNo = latestBlock.NumberU64()
+ beginBlockNo = headBlockNumber
}
-
- endBlockNo := uint64(f.end)
+ var endBlockNo uint64 = uint64(f.end)
if f.end == -1 {
- endBlockNo = latestBlock.NumberU64()
+ endBlockNo = headBlockNumber
}
// if no addresses are present we can't make use of fast search which
// uses the mipmap bloom filters to check for fast inclusion and uses
// higher range probability in order to ensure at least a false positive
- if len(f.addresses) == 0 {
- return f.getLogs(beginBlockNo, endBlockNo)
+ if !f.useMipMap || len(f.addresses) == 0 {
+ return f.getLogs(ctx, beginBlockNo, endBlockNo)
}
- return f.mipFind(beginBlockNo, endBlockNo, 0)
+ return f.mipFind(beginBlockNo, endBlockNo, 0), nil
}
func (f *Filter) mipFind(start, end uint64, depth int) (logs []Log) {
@@ -107,7 +123,8 @@ func (f *Filter) mipFind(start, end uint64, depth int) (logs []Log) {
start := uint64(math.Max(float64(num), float64(start)))
end := uint64(math.Min(float64(num+level-1), float64(end)))
if depth+1 == len(core.MIPMapLevels) {
- logs = append(logs, f.getLogs(start, end)...)
+ l, _ := f.getLogs(context.Background(), start, end)
+ logs = append(logs, l...)
} else {
logs = append(logs, f.mipFind(start, end, depth+1)...)
}
@@ -122,28 +139,22 @@ func (f *Filter) mipFind(start, end uint64, depth int) (logs []Log) {
return logs
}
-func (f *Filter) getLogs(start, end uint64) (logs []Log) {
- var block *types.Block
-
+func (f *Filter) getLogs(ctx context.Context, start, end uint64) (logs []Log, err error) {
for i := start; i <= end; i++ {
- hash := core.GetCanonicalHash(f.db, i)
- if hash != (common.Hash{}) {
- block = core.GetBlock(f.db, hash, i)
- } else { // block not found
- return logs
- }
- if block == nil { // block not found/written
- return logs
+ header, err := f.backend.HeaderByNumber(ctx, rpc.BlockNumber(i))
+ if header == nil || err != nil {
+ return logs, err
}
// Use bloom filtering to see if this block is interesting given the
// current parameters
- if f.bloomFilter(block) {
+ if f.bloomFilter(header.Bloom) {
// Get the logs of the block
- var (
- receipts = core.GetBlockReceipts(f.db, block.Hash(), i)
- unfiltered []Log
- )
+ receipts, err := f.backend.GetReceipts(ctx, header.Hash())
+ if err != nil {
+ return nil, err
+ }
+ var unfiltered []Log
for _, receipt := range receipts {
rl := make([]Log, len(receipt.Logs))
for i, l := range receipt.Logs {
@@ -155,7 +166,7 @@ func (f *Filter) getLogs(start, end uint64) (logs []Log) {
}
}
- return logs
+ return logs, nil
}
func includes(addresses []common.Address, a common.Address) bool {
@@ -207,11 +218,15 @@ Logs:
return ret
}
-func (f *Filter) bloomFilter(block *types.Block) bool {
- if len(f.addresses) > 0 {
+func (f *Filter) bloomFilter(bloom types.Bloom) bool {
+ return bloomFilter(bloom, f.addresses, f.topics)
+}
+
+func bloomFilter(bloom types.Bloom, addresses []common.Address, topics [][]common.Hash) bool {
+ if len(addresses) > 0 {
var included bool
- for _, addr := range f.addresses {
- if types.BloomLookup(block.Bloom(), addr) {
+ for _, addr := range addresses {
+ if types.BloomLookup(bloom, addr) {
included = true
break
}
@@ -222,10 +237,10 @@ func (f *Filter) bloomFilter(block *types.Block) bool {
}
}
- for _, sub := range f.topics {
+ for _, sub := range topics {
var included bool
for _, topic := range sub {
- if (topic == common.Hash{}) || types.BloomLookup(block.Bloom(), topic) {
+ if (topic == common.Hash{}) || types.BloomLookup(bloom, topic) {
included = true
break
}
diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go
index 04a55fd09..c2c072a9f 100644
--- a/eth/filters/filter_system.go
+++ b/eth/filters/filter_system.go
@@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"
+ "golang.org/x/net/context"
)
// Type determines the kind of filter and is used to put the filter in to
@@ -95,6 +96,9 @@ type subscription struct {
type EventSystem struct {
mux *event.TypeMux
sub event.Subscription
+ backend Backend
+ lightMode bool
+ lastHead *types.Header
install chan *subscription // install filter for event notification
uninstall chan *subscription // remove filter for event notification
}
@@ -105,9 +109,11 @@ type EventSystem struct {
//
// The returned manager has a loop that needs to be stopped with the Stop function
// or by stopping the given mux.
-func NewEventSystem(mux *event.TypeMux) *EventSystem {
+func NewEventSystem(mux *event.TypeMux, backend Backend, lightMode bool) *EventSystem {
m := &EventSystem{
mux: mux,
+ backend: backend,
+ lightMode: lightMode,
install: make(chan *subscription),
uninstall: make(chan *subscription),
}
@@ -235,7 +241,7 @@ func (es *EventSystem) SubscribeNewHeads(headers chan *types.Header) *Subscripti
type filterIndex map[Type]map[rpc.ID]*subscription
// broadcast event to filters that match criteria.
-func broadcast(filters filterIndex, ev *event.Event) {
+func (es *EventSystem) broadcast(filters filterIndex, ev *event.Event) {
if ev == nil {
return
}
@@ -279,7 +285,77 @@ func broadcast(filters filterIndex, ev *event.Event) {
f.headers <- e.Block.Header()
}
}
+ if es.lightMode && len(filters[LogsSubscription]) > 0 {
+ es.lightFilterNewHead(e.Block.Header(), func(header *types.Header, remove bool) {
+ for _, f := range filters[LogsSubscription] {
+ if ev.Time.After(f.created) {
+ if matchedLogs := es.lightFilterLogs(header, f.logsCrit.Addresses, f.logsCrit.Topics, remove); len(matchedLogs) > 0 {
+ f.logs <- matchedLogs
+ }
+ }
+ }
+ })
+ }
+ }
+}
+
+func (es *EventSystem) lightFilterNewHead(newHeader *types.Header, callBack func(*types.Header, bool)) {
+ oldh := es.lastHead
+ es.lastHead = newHeader
+ if oldh == nil {
+ return
+ }
+ newh := newHeader
+ // find common ancestor, create list of rolled back and new block hashes
+ var oldHeaders, newHeaders []*types.Header
+ for oldh.Hash() != newh.Hash() {
+ if oldh.Number.Uint64() >= newh.Number.Uint64() {
+ oldHeaders = append(oldHeaders, oldh)
+ oldh = core.GetHeader(es.backend.ChainDb(), oldh.ParentHash, oldh.Number.Uint64()-1)
+ }
+ if oldh.Number.Uint64() < newh.Number.Uint64() {
+ newHeaders = append(newHeaders, newh)
+ newh = core.GetHeader(es.backend.ChainDb(), newh.ParentHash, newh.Number.Uint64()-1)
+ if newh == nil {
+ // happens when CHT syncing, nothing to do
+ newh = oldh
+ }
+ }
+ }
+ // roll back old blocks
+ for _, h := range oldHeaders {
+ callBack(h, true)
+ }
+ // check new blocks (array is in reverse order)
+ for i := len(newHeaders) - 1; i >= 0; i-- {
+ callBack(newHeaders[i], false)
+ }
+}
+
+// filter logs of a single header in light client mode
+func (es *EventSystem) lightFilterLogs(header *types.Header, addresses []common.Address, topics [][]common.Hash, remove bool) []Log {
+ //fmt.Println("lightFilterLogs", header.Number.Uint64(), remove)
+ if bloomFilter(header.Bloom, addresses, topics) {
+ //fmt.Println("bloom match")
+ // Get the logs of the block
+ ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
+ receipts, err := es.backend.GetReceipts(ctx, header.Hash())
+ if err != nil {
+ return nil
+ }
+ var unfiltered []Log
+ for _, receipt := range receipts {
+ rl := make([]Log, len(receipt.Logs))
+ for i, l := range receipt.Logs {
+ rl[i] = Log{l, remove}
+ }
+ unfiltered = append(unfiltered, rl...)
+ }
+ logs := filterLogs(unfiltered, addresses, topics)
+ //fmt.Println("found", len(logs))
+ return logs
}
+ return nil
}
// eventLoop (un)installs filters and processes mux events.
@@ -294,7 +370,7 @@ func (es *EventSystem) eventLoop() {
if !active { // system stopped
return
}
- broadcast(index, ev)
+ es.broadcast(index, ev)
case f := <-es.install:
if _, found := index[f.typ]; !found {
index[f.typ] = make(map[rpc.ID]*subscription)
diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go
index 9e6fde1c6..48d6811c0 100644
--- a/eth/filters/filter_system_test.go
+++ b/eth/filters/filter_system_test.go
@@ -22,6 +22,8 @@ import (
"testing"
"time"
+ "golang.org/x/net/context"
+
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -32,11 +34,43 @@ import (
)
var (
- mux = new(event.TypeMux)
- db, _ = ethdb.NewMemDatabase()
- api = NewPublicFilterAPI(db, mux)
+ mux = new(event.TypeMux)
+ db, _ = ethdb.NewMemDatabase()
+ backend = &testBackend{mux, db}
+ api = NewPublicFilterAPI(backend, false)
)
+type testBackend struct {
+ mux *event.TypeMux
+ db ethdb.Database
+}
+
+func (b *testBackend) ChainDb() ethdb.Database {
+ return b.db
+}
+
+func (b *testBackend) EventMux() *event.TypeMux {
+ return b.mux
+}
+
+func (b *testBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error) {
+ var hash common.Hash
+ var num uint64
+ if blockNr == rpc.LatestBlockNumber {
+ hash = core.GetHeadBlockHash(b.db)
+ num = core.GetBlockNumber(b.db, hash)
+ } else {
+ num = uint64(blockNr)
+ hash = core.GetCanonicalHash(b.db, num)
+ }
+ return core.GetHeader(b.db, hash, num), nil
+}
+
+func (b *testBackend) GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error) {
+ num := core.GetBlockNumber(b.db, blockHash)
+ return core.GetBlockReceipts(b.db, blockHash, num), nil
+}
+
// TestBlockSubscription tests if a block subscription returns block hashes for posted chain events.
// It creates multiple subscriptions:
// - one at the start and should receive all posted chain events and a second (blockHashes)
diff --git a/eth/filters/filter_test.go b/eth/filters/filter_test.go
index 7b714f5d5..e0b24046c 100644
--- a/eth/filters/filter_test.go
+++ b/eth/filters/filter_test.go
@@ -22,6 +22,8 @@ import (
"os"
"testing"
+ "golang.org/x/net/context"
+
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -48,6 +50,7 @@ func BenchmarkMipmaps(b *testing.B) {
var (
db, _ = ethdb.NewLDBDatabase(dir, 0, 0)
+ backend = &testBackend{mux, db}
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr1 = crypto.PubkeyToAddress(key1.PublicKey)
addr2 = common.BytesToAddress([]byte("jeff"))
@@ -100,13 +103,13 @@ func BenchmarkMipmaps(b *testing.B) {
}
b.ResetTimer()
- filter := New(db)
+ filter := New(backend, true)
filter.SetAddresses([]common.Address{addr1, addr2, addr3, addr4})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
for i := 0; i < b.N; i++ {
- logs := filter.Find()
+ logs, _ := filter.Find(context.Background())
if len(logs) != 4 {
b.Fatal("expected 4 log, got", len(logs))
}
@@ -122,6 +125,7 @@ func TestFilters(t *testing.T) {
var (
db, _ = ethdb.NewLDBDatabase(dir, 0, 0)
+ backend = &testBackend{mux, db}
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr = crypto.PubkeyToAddress(key1.PublicKey)
@@ -201,23 +205,23 @@ func TestFilters(t *testing.T) {
}
}
- filter := New(db)
+ filter := New(backend, true)
filter.SetAddresses([]common.Address{addr})
filter.SetTopics([][]common.Hash{[]common.Hash{hash1, hash2, hash3, hash4}})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
- logs := filter.Find()
+ logs, _ := filter.Find(context.Background())
if len(logs) != 4 {
t.Error("expected 4 log, got", len(logs))
}
- filter = New(db)
+ filter = New(backend, true)
filter.SetAddresses([]common.Address{addr})
filter.SetTopics([][]common.Hash{[]common.Hash{hash3}})
filter.SetBeginBlock(900)
filter.SetEndBlock(999)
- logs = filter.Find()
+ logs, _ = filter.Find(context.Background())
if len(logs) != 1 {
t.Error("expected 1 log, got", len(logs))
}
@@ -225,12 +229,12 @@ func TestFilters(t *testing.T) {
t.Errorf("expected log[0].Topics[0] to be %x, got %x", hash3, logs[0].Topics[0])
}
- filter = New(db)
+ filter = New(backend, true)
filter.SetAddresses([]common.Address{addr})
filter.SetTopics([][]common.Hash{[]common.Hash{hash3}})
filter.SetBeginBlock(990)
filter.SetEndBlock(-1)
- logs = filter.Find()
+ logs, _ = filter.Find(context.Background())
if len(logs) != 1 {
t.Error("expected 1 log, got", len(logs))
}
@@ -238,44 +242,44 @@ func TestFilters(t *testing.T) {
t.Errorf("expected log[0].Topics[0] to be %x, got %x", hash3, logs[0].Topics[0])
}
- filter = New(db)
+ filter = New(backend, true)
filter.SetTopics([][]common.Hash{[]common.Hash{hash1, hash2}})
filter.SetBeginBlock(1)
filter.SetEndBlock(10)
- logs = filter.Find()
+ logs, _ = filter.Find(context.Background())
if len(logs) != 2 {
t.Error("expected 2 log, got", len(logs))
}
failHash := common.BytesToHash([]byte("fail"))
- filter = New(db)
+ filter = New(backend, true)
filter.SetTopics([][]common.Hash{[]common.Hash{failHash}})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
- logs = filter.Find()
+ logs, _ = filter.Find(context.Background())
if len(logs) != 0 {
t.Error("expected 0 log, got", len(logs))
}
failAddr := common.BytesToAddress([]byte("failmenow"))
- filter = New(db)
+ filter = New(backend, true)
filter.SetAddresses([]common.Address{failAddr})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
- logs = filter.Find()
+ logs, _ = filter.Find(context.Background())
if len(logs) != 0 {
t.Error("expected 0 log, got", len(logs))
}
- filter = New(db)
+ filter = New(backend, true)
filter.SetTopics([][]common.Hash{[]common.Hash{failHash}, []common.Hash{hash1}})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
- logs = filter.Find()
+ logs, _ = filter.Find(context.Background())
if len(logs) != 0 {
t.Error("expected 0 log, got", len(logs))
}
diff --git a/eth/gasprice/lightprice.go b/eth/gasprice/lightprice.go
new file mode 100644
index 000000000..8886d32d7
--- /dev/null
+++ b/eth/gasprice/lightprice.go
@@ -0,0 +1,160 @@
+// Copyright 2016 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+package gasprice
+
+import (
+ "math/big"
+ "sort"
+ "sync"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/internal/ethapi"
+ "github.com/ethereum/go-ethereum/rpc"
+ "golang.org/x/net/context"
+)
+
+const (
+ LpoAvgCount = 5
+ LpoMinCount = 3
+ LpoMaxBlocks = 20
+ LpoSelect = 50
+ LpoDefaultPrice = 20000000000
+)
+
+// LightPriceOracle recommends gas prices based on the content of recent
+// blocks. Suitable for both light and full clients.
+type LightPriceOracle struct {
+ backend ethapi.Backend
+ lastHead common.Hash
+ lastPrice *big.Int
+ cacheLock sync.RWMutex
+ fetchLock sync.Mutex
+}
+
+// NewLightPriceOracle returns a new oracle.
+func NewLightPriceOracle(backend ethapi.Backend) *LightPriceOracle {
+ return &LightPriceOracle{
+ backend: backend,
+ lastPrice: big.NewInt(LpoDefaultPrice),
+ }
+}
+
+// SuggestPrice returns the recommended gas price.
+func (self *LightPriceOracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
+ self.cacheLock.RLock()
+ lastHead := self.lastHead
+ lastPrice := self.lastPrice
+ self.cacheLock.RUnlock()
+
+ head, _ := self.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
+ headHash := head.Hash()
+ if headHash == lastHead {
+ return lastPrice, nil
+ }
+
+ self.fetchLock.Lock()
+ defer self.fetchLock.Unlock()
+
+ // try checking the cache again, maybe the last fetch fetched what we need
+ self.cacheLock.RLock()
+ lastHead = self.lastHead
+ lastPrice = self.lastPrice
+ self.cacheLock.RUnlock()
+ if headHash == lastHead {
+ return lastPrice, nil
+ }
+
+ blockNum := head.Number.Uint64()
+ chn := make(chan lpResult, LpoMaxBlocks)
+ sent := 0
+ exp := 0
+ var lps bigIntArray
+ for sent < LpoAvgCount && blockNum > 0 {
+ go self.getLowestPrice(ctx, blockNum, chn)
+ sent++
+ exp++
+ blockNum--
+ }
+ maxEmpty := LpoAvgCount - LpoMinCount
+ for exp > 0 {
+ res := <-chn
+ if res.err != nil {
+ return nil, res.err
+ }
+ exp--
+ if res.price != nil {
+ lps = append(lps, res.price)
+ } else {
+ if maxEmpty > 0 {
+ maxEmpty--
+ } else {
+ if blockNum > 0 && sent < LpoMaxBlocks {
+ go self.getLowestPrice(ctx, blockNum, chn)
+ sent++
+ exp++
+ blockNum--
+ }
+ }
+ }
+ }
+ price := lastPrice
+ if len(lps) > 0 {
+ sort.Sort(lps)
+ price = lps[(len(lps)-1)*LpoSelect/100]
+ }
+
+ self.cacheLock.Lock()
+ self.lastHead = headHash
+ self.lastPrice = price
+ self.cacheLock.Unlock()
+ return price, nil
+}
+
+type lpResult struct {
+ price *big.Int
+ err error
+}
+
+// getLowestPrice calculates the lowest transaction gas price in a given block
+// and sends it to the result channel. If the block is empty, price is nil.
+func (self *LightPriceOracle) getLowestPrice(ctx context.Context, blockNum uint64, chn chan lpResult) {
+ block, err := self.backend.BlockByNumber(ctx, rpc.BlockNumber(blockNum))
+ if block == nil {
+ chn <- lpResult{nil, err}
+ return
+ }
+ txs := block.Transactions()
+ if len(txs) == 0 {
+ chn <- lpResult{nil, nil}
+ return
+ }
+ // find smallest gasPrice
+ minPrice := txs[0].GasPrice()
+ for i := 1; i < len(txs); i++ {
+ price := txs[i].GasPrice()
+ if price.Cmp(minPrice) < 0 {
+ minPrice = price
+ }
+ }
+ chn <- lpResult{minPrice, nil}
+}
+
+type bigIntArray []*big.Int
+
+func (s bigIntArray) Len() int { return len(s) }
+func (s bigIntArray) Less(i, j int) bool { return s[i].Cmp(s[j]) < 0 }
+func (s bigIntArray) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
diff --git a/eth/handler.go b/eth/handler.go
index e478990f7..9d6b1ced2 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -68,6 +68,7 @@ type ProtocolManager struct {
blockchain *core.BlockChain
chaindb ethdb.Database
chainconfig *core.ChainConfig
+ maxPeers int
downloader *downloader.Downloader
fetcher *fetcher.Fetcher
@@ -94,7 +95,7 @@ type ProtocolManager struct {
// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
// with the ethereum network.
-func NewProtocolManager(config *core.ChainConfig, fastSync bool, networkId int, mux *event.TypeMux, txpool txPool, pow pow.PoW, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error) {
+func NewProtocolManager(config *core.ChainConfig, fastSync bool, networkId int, maxPeers int, mux *event.TypeMux, txpool txPool, pow pow.PoW, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error) {
// Create the protocol manager with the base fields
manager := &ProtocolManager{
networkId: networkId,
@@ -103,6 +104,7 @@ func NewProtocolManager(config *core.ChainConfig, fastSync bool, networkId int,
blockchain: blockchain,
chaindb: chaindb,
chainconfig: config,
+ maxPeers: maxPeers,
peers: newPeerSet(),
newPeerCh: make(chan *peer),
noMorePeers: make(chan struct{}),
@@ -156,7 +158,7 @@ func NewProtocolManager(config *core.ChainConfig, fastSync bool, networkId int,
return nil, errIncompatibleConfig
}
// Construct the different synchronisation mechanisms
- manager.downloader = downloader.New(chaindb, manager.eventMux, blockchain.HasHeader, blockchain.HasBlockAndState, blockchain.GetHeaderByHash,
+ manager.downloader = downloader.New(downloader.FullSync, chaindb, manager.eventMux, blockchain.HasHeader, blockchain.HasBlockAndState, blockchain.GetHeaderByHash,
blockchain.GetBlockByHash, blockchain.CurrentHeader, blockchain.CurrentBlock, blockchain.CurrentFastBlock, blockchain.FastSyncCommitHead,
blockchain.GetTdByHash, blockchain.InsertHeaderChain, manager.insertChain, blockchain.InsertReceiptChain, blockchain.Rollback,
manager.removePeer)
@@ -253,6 +255,10 @@ func (pm *ProtocolManager) newPeer(pv int, p *p2p.Peer, rw p2p.MsgReadWriter) *p
// handle is the callback invoked to manage the life cycle of an eth peer. When
// this function terminates, the peer is disconnected.
func (pm *ProtocolManager) handle(p *peer) error {
+ if pm.peers.Len() >= pm.maxPeers {
+ return p2p.DiscTooManyPeers
+ }
+
glog.V(logger.Debug).Infof("%v: peer connected [%s]", p, p.Name())
// Execute the Ethereum handshake
diff --git a/eth/handler_test.go b/eth/handler_test.go
index f0f18d0a6..64449afda 100644
--- a/eth/handler_test.go
+++ b/eth/handler_test.go
@@ -469,7 +469,7 @@ func testDAOChallenge(t *testing.T, localForked, remoteForked bool, timeout bool
config = &core.ChainConfig{DAOForkBlock: big.NewInt(1), DAOForkSupport: localForked}
blockchain, _ = core.NewBlockChain(db, config, pow, evmux)
)
- pm, err := NewProtocolManager(config, false, NetworkId, evmux, new(testTxPool), pow, blockchain, db)
+ pm, err := NewProtocolManager(config, false, NetworkId, 1000, evmux, new(testTxPool), pow, blockchain, db)
if err != nil {
t.Fatalf("failed to start test protocol manager: %v", err)
}
diff --git a/eth/helper_test.go b/eth/helper_test.go
index 732fe89ee..d5295b398 100644
--- a/eth/helper_test.go
+++ b/eth/helper_test.go
@@ -62,7 +62,7 @@ func newTestProtocolManager(fastSync bool, blocks int, generator func(int, *core
panic(err)
}
- pm, err := NewProtocolManager(chainConfig, fastSync, NetworkId, evmux, &testTxPool{added: newtx}, pow, blockchain, db)
+ pm, err := NewProtocolManager(chainConfig, fastSync, NetworkId, 1000, evmux, &testTxPool{added: newtx}, pow, blockchain, db)
if err != nil {
return nil, err
}