aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go11
-rw-r--r--eth/handler.go1
-rw-r--r--eth/protocol.go2
-rw-r--r--eth/protocol_test.go4
4 files changed, 14 insertions, 4 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 4bc00edde..dc592e7fc 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -45,6 +45,7 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
+ "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/whisper"
)
@@ -80,6 +81,7 @@ type Config struct {
BlockChainVersion int
SkipBcVersionCheck bool // e.g. blockchain export
+ DatabaseCache int
DataDir string
LogFile string
@@ -261,7 +263,7 @@ func New(config *Config) (*Ethereum, error) {
newdb := config.NewDB
if newdb == nil {
- newdb = func(path string) (common.Database, error) { return ethdb.NewLDBDatabase(path) }
+ newdb = func(path string) (common.Database, error) { return ethdb.NewLDBDatabase(path, config.DatabaseCache) }
}
blockDb, err := newdb(filepath.Join(config.DataDir, "blockchain"))
if err != nil {
@@ -367,6 +369,13 @@ func New(config *Config) (*Ethereum, error) {
eth.miner = miner.New(eth, eth.EventMux(), eth.pow)
eth.miner.SetGasPrice(config.GasPrice)
+
+ extra := config.Name
+ if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() {
+ extra = extra[:params.MaximumExtraDataSize.Uint64()]
+ }
+ eth.miner.SetExtra([]byte(extra))
+
if config.Shh {
eth.whisper = whisper.New()
eth.shhVersionId = int(eth.whisper.Version())
diff --git a/eth/handler.go b/eth/handler.go
index f427854ac..2bd369901 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -95,6 +95,7 @@ func NewProtocolManager(networkId int, mux *event.TypeMux, txpool txPool, pow po
newPeerCh: make(chan *peer, 1),
txsyncCh: make(chan *txsync),
quitSync: make(chan struct{}),
+ netId: networkId,
}
// Initiate a sub-protocol for every implemented version we can handle
manager.SubProtocols = make([]p2p.Protocol, len(ProtocolVersions))
diff --git a/eth/protocol.go b/eth/protocol.go
index 0bc845660..b8c9b50d0 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -30,7 +30,7 @@ var ProtocolVersions = []uint{61, 60}
var ProtocolLengths = []uint64{9, 8}
const (
- NetworkId = 0
+ NetworkId = 1
ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
diff --git a/eth/protocol_test.go b/eth/protocol_test.go
index c01f59691..a24d98f69 100644
--- a/eth/protocol_test.go
+++ b/eth/protocol_test.go
@@ -60,7 +60,7 @@ func TestStatusMsgErrors(t *testing.T) {
},
{
code: StatusMsg, data: statusData{uint32(ProtocolVersions[0]), 999, td, currentBlock, genesis},
- wantError: errResp(ErrNetworkIdMismatch, "999 (!= 0)"),
+ wantError: errResp(ErrNetworkIdMismatch, "999 (!= 1)"),
},
{
code: StatusMsg, data: statusData{uint32(ProtocolVersions[0]), NetworkId, td, currentBlock, common.Hash{3}},
@@ -184,7 +184,7 @@ func newProtocolManagerForTesting(txAdded chan<- []*types.Transaction) *Protocol
em = new(event.TypeMux)
chain, _ = core.NewChainManager(db, db, db, core.FakePow{}, em)
txpool = &fakeTxPool{added: txAdded}
- pm = NewProtocolManager(0, em, txpool, core.FakePow{}, chain)
+ pm = NewProtocolManager(NetworkId, em, txpool, core.FakePow{}, chain)
)
pm.Start()
return pm