aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
Diffstat (limited to 'eth')
-rw-r--r--eth/api.go20
-rw-r--r--eth/backend.go6
-rw-r--r--eth/downloader/downloader_test.go49
-rw-r--r--eth/filters/api.go1
-rw-r--r--eth/filters/filter.go3
-rw-r--r--eth/filters/filter_system.go1
-rw-r--r--eth/filters/filter_system_test.go7
-rw-r--r--eth/sync.go6
8 files changed, 45 insertions, 48 deletions
diff --git a/eth/api.go b/eth/api.go
index 0d90759b6..f5214fc37 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -465,26 +465,6 @@ func (api *PrivateDebugAPI) traceBlock(block *types.Block, logConfig *vm.LogConf
return true, structLogger.StructLogs(), nil
}
-// callmsg is the message type used for call transitions.
-type callmsg struct {
- addr common.Address
- to *common.Address
- gas, gasPrice *big.Int
- value *big.Int
- data []byte
-}
-
-// accessor boilerplate to implement core.Message
-func (m callmsg) From() (common.Address, error) { return m.addr, nil }
-func (m callmsg) FromFrontier() (common.Address, error) { return m.addr, nil }
-func (m callmsg) Nonce() uint64 { return 0 }
-func (m callmsg) CheckNonce() bool { return false }
-func (m callmsg) To() *common.Address { return m.to }
-func (m callmsg) GasPrice() *big.Int { return m.gasPrice }
-func (m callmsg) Gas() *big.Int { return m.gas }
-func (m callmsg) Value() *big.Int { return m.value }
-func (m callmsg) Data() []byte { return m.data }
-
// formatError formats a Go error into either an empty string or the data content
// of the error itself.
func formatError(err error) string {
diff --git a/eth/backend.go b/eth/backend.go
index c7df517c0..8a837f7b8 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -148,8 +148,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
core.WriteChainConfig(chainDb, genesisHash, chainConfig)
}
- newPool := core.NewTxPool(config.TxPool, eth.chainConfig, eth.EventMux(), eth.blockchain.State, eth.blockchain.GasLimit)
- eth.txPool = newPool
+ if config.TxPool.Journal != "" {
+ config.TxPool.Journal = ctx.ResolvePath(config.TxPool.Journal)
+ }
+ eth.txPool = core.NewTxPool(config.TxPool, eth.chainConfig, eth.EventMux(), eth.blockchain.State, eth.blockchain.GasLimit)
maxPeers := config.MaxPeers
if config.LightServ > 0 {
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index b354682a1..d66aafe94 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -403,8 +403,7 @@ func (dl *downloadTester) newSlowPeer(id string, version int, hashes []common.Ha
dl.lock.Lock()
defer dl.lock.Unlock()
- var err error
- err = dl.downloader.RegisterPeer(id, version, &downloadTesterPeer{dl, id, delay})
+ var err = dl.downloader.RegisterPeer(id, version, &downloadTesterPeer{dl: dl, id: id, delay: delay})
if err == nil {
// Assign the owned hashes, headers and blocks to the peer (deep copy)
dl.peerHashes[id] = make([]common.Hash, len(hashes))
@@ -466,6 +465,24 @@ type downloadTesterPeer struct {
dl *downloadTester
id string
delay time.Duration
+ lock sync.RWMutex
+}
+
+// setDelay is a thread safe setter for the network delay value.
+func (dlp *downloadTesterPeer) setDelay(delay time.Duration) {
+ dlp.lock.Lock()
+ defer dlp.lock.Unlock()
+
+ dlp.delay = delay
+}
+
+// waitDelay is a thread safe way to sleep for the configured time.
+func (dlp *downloadTesterPeer) waitDelay() {
+ dlp.lock.RLock()
+ delay := dlp.delay
+ dlp.lock.RUnlock()
+
+ time.Sleep(delay)
}
// Head constructs a function to retrieve a peer's current head hash
@@ -500,7 +517,7 @@ func (dlp *downloadTesterPeer) RequestHeadersByHash(origin common.Hash, amount i
// origin; associated with a particular peer in the download tester. The returned
// function can be used to retrieve batches of headers from the particular peer.
func (dlp *downloadTesterPeer) RequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool) error {
- time.Sleep(dlp.delay)
+ dlp.waitDelay()
dlp.dl.lock.RLock()
defer dlp.dl.lock.RUnlock()
@@ -526,7 +543,7 @@ func (dlp *downloadTesterPeer) RequestHeadersByNumber(origin uint64, amount int,
// peer in the download tester. The returned function can be used to retrieve
// batches of block bodies from the particularly requested peer.
func (dlp *downloadTesterPeer) RequestBodies(hashes []common.Hash) error {
- time.Sleep(dlp.delay)
+ dlp.waitDelay()
dlp.dl.lock.RLock()
defer dlp.dl.lock.RUnlock()
@@ -551,7 +568,7 @@ func (dlp *downloadTesterPeer) RequestBodies(hashes []common.Hash) error {
// peer in the download tester. The returned function can be used to retrieve
// batches of block receipts from the particularly requested peer.
func (dlp *downloadTesterPeer) RequestReceipts(hashes []common.Hash) error {
- time.Sleep(dlp.delay)
+ dlp.waitDelay()
dlp.dl.lock.RLock()
defer dlp.dl.lock.RUnlock()
@@ -573,7 +590,7 @@ func (dlp *downloadTesterPeer) RequestReceipts(hashes []common.Hash) error {
// peer in the download tester. The returned function can be used to retrieve
// batches of node state data from the particularly requested peer.
func (dlp *downloadTesterPeer) RequestNodeData(hashes []common.Hash) error {
- time.Sleep(dlp.delay)
+ dlp.waitDelay()
dlp.dl.lock.RLock()
defer dlp.dl.lock.RUnlock()
@@ -1381,7 +1398,7 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("peer-half", nil, mode); err != nil {
- t.Fatalf("failed to synchronise blocks: %v", err)
+ panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
}
}()
<-starting
@@ -1398,7 +1415,7 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("peer-full", nil, mode); err != nil {
- t.Fatalf("failed to synchronise blocks: %v", err)
+ panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
}
}()
<-starting
@@ -1454,7 +1471,7 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("fork A", nil, mode); err != nil {
- t.Fatalf("failed to synchronise blocks: %v", err)
+ panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
}
}()
<-starting
@@ -1474,7 +1491,7 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("fork B", nil, mode); err != nil {
- t.Fatalf("failed to synchronise blocks: %v", err)
+ panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
}
}()
<-starting
@@ -1535,7 +1552,7 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("faulty", nil, mode); err == nil {
- t.Fatalf("succeeded faulty synchronisation")
+ panic("succeeded faulty synchronisation")
}
}()
<-starting
@@ -1552,7 +1569,7 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("valid", nil, mode); err != nil {
- t.Fatalf("failed to synchronise blocks: %v", err)
+ panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
}
}()
<-starting
@@ -1613,7 +1630,7 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("attack", nil, mode); err == nil {
- t.Fatalf("succeeded attacker synchronisation")
+ panic("succeeded attacker synchronisation")
}
}()
<-starting
@@ -1630,7 +1647,7 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
go func() {
defer pending.Done()
if err := tester.sync("valid", nil, mode); err != nil {
- t.Fatalf("failed to synchronise blocks: %v", err)
+ panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
}
}()
<-starting
@@ -1747,7 +1764,7 @@ func testFastCriticalRestarts(t *testing.T, protocol int, progress bool) {
for i := 0; i < fsPivotInterval; i++ {
tester.peerMissingStates["peer"][headers[hashes[fsMinFullBlocks+i]].Root] = true
}
- (tester.downloader.peers.peers["peer"].peer).(*downloadTesterPeer).delay = 500 * time.Millisecond // Enough to reach the critical section
+ (tester.downloader.peers.peers["peer"].peer).(*downloadTesterPeer).setDelay(500 * time.Millisecond) // Enough to reach the critical section
// Synchronise with the peer a few times and make sure they fail until the retry limit
for i := 0; i < int(fsCriticalTrials)-1; i++ {
@@ -1766,7 +1783,7 @@ func testFastCriticalRestarts(t *testing.T, protocol int, progress bool) {
tester.lock.Lock()
tester.peerHeaders["peer"][hashes[fsMinFullBlocks-1]] = headers[hashes[fsMinFullBlocks-1]]
tester.peerMissingStates["peer"] = map[common.Hash]bool{tester.downloader.fsPivotLock.Root: true}
- (tester.downloader.peers.peers["peer"].peer).(*downloadTesterPeer).delay = 0
+ (tester.downloader.peers.peers["peer"].peer).(*downloadTesterPeer).setDelay(0)
tester.lock.Unlock()
}
}
diff --git a/eth/filters/api.go b/eth/filters/api.go
index 61647a5d0..fff58a268 100644
--- a/eth/filters/api.go
+++ b/eth/filters/api.go
@@ -54,7 +54,6 @@ type PublicFilterAPI struct {
backend Backend
useMipMap bool
mux *event.TypeMux
- quit chan struct{}
chainDb ethdb.Database
events *EventSystem
filtersMu sync.Mutex
diff --git a/eth/filters/filter.go b/eth/filters/filter.go
index 0a0b81224..f27b76929 100644
--- a/eth/filters/filter.go
+++ b/eth/filters/filter.go
@@ -20,7 +20,6 @@ import (
"context"
"math"
"math/big"
- "time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
@@ -42,8 +41,6 @@ type Filter struct {
backend Backend
useMipMap bool
- created time.Time
-
db ethdb.Database
begin, end int64
addresses []common.Address
diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go
index 7abace1e6..ab0b7473e 100644
--- a/eth/filters/filter_system.go
+++ b/eth/filters/filter_system.go
@@ -74,7 +74,6 @@ type subscription struct {
// subscription which match the subscription criteria.
type EventSystem struct {
mux *event.TypeMux
- sub *event.TypeMuxSubscription
backend Backend
lightMode bool
lastHead *types.Header
diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go
index 822580b56..23e6d66e1 100644
--- a/eth/filters/filter_system_test.go
+++ b/eth/filters/filter_system_test.go
@@ -18,6 +18,7 @@ package filters
import (
"context"
+ "fmt"
"math/big"
"reflect"
"testing"
@@ -439,15 +440,15 @@ func TestPendingLogsSubscription(t *testing.T) {
}
if len(fetched) != len(tt.expected) {
- t.Fatalf("invalid number of logs for case %d, want %d log(s), got %d", i, len(tt.expected), len(fetched))
+ panic(fmt.Sprintf("invalid number of logs for case %d, want %d log(s), got %d", i, len(tt.expected), len(fetched)))
}
for l := range fetched {
if fetched[l].Removed {
- t.Errorf("expected log not to be removed for log %d in case %d", l, i)
+ panic(fmt.Sprintf("expected log not to be removed for log %d in case %d", l, i))
}
if !reflect.DeepEqual(fetched[l], tt.expected[l]) {
- t.Errorf("invalid log on index %d for case %d", l, i)
+ panic(fmt.Sprintf("invalid log on index %d for case %d", l, i))
}
}
}()
diff --git a/eth/sync.go b/eth/sync.go
index 8784b225d..7442f912c 100644
--- a/eth/sync.go
+++ b/eth/sync.go
@@ -138,7 +138,9 @@ func (pm *ProtocolManager) syncer() {
defer pm.downloader.Terminate()
// Wait for different events to fire synchronisation operations
- forceSync := time.Tick(forceSyncCycle)
+ forceSync := time.NewTicker(forceSyncCycle)
+ defer forceSync.Stop()
+
for {
select {
case <-pm.newPeerCh:
@@ -148,7 +150,7 @@ func (pm *ProtocolManager) syncer() {
}
go pm.synchronise(pm.peers.BestPeer())
- case <-forceSync:
+ case <-forceSync.C:
// Force a sync even if not enough peers are present
go pm.synchronise(pm.peers.BestPeer())