aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--eth/fetcher/fetcher.go19
-rw-r--r--eth/handler.go8
-rw-r--r--rpc/args_test.go54
4 files changed, 74 insertions, 8 deletions
diff --git a/README.md b/README.md
index df335f242..a411d9eb8 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,7 @@ The following builds are build automatically by our build servers after each pus
[trusty](https://build.ethdev.com/builds/Linux%20Go%20develop%20deb%20i386-trusty/latest/) |
[utopic](https://build.ethdev.com/builds/Linux%20Go%20develop%20deb%20i386-utopic/latest/)
* [Windows 64-bit](https://build.ethdev.com/builds/Windows%20Go%20develop%20branch/Geth-Win64-latest.zip)
+* [ARM](https://build.ethdev.com/builds/ARM%20Go%20develop%20branch/geth-ARM-latest.tar.bz2)
Building the source
===================
diff --git a/eth/fetcher/fetcher.go b/eth/fetcher/fetcher.go
index 98170cf79..b80182a45 100644
--- a/eth/fetcher/fetcher.go
+++ b/eth/fetcher/fetcher.go
@@ -3,6 +3,7 @@ package fetcher
import (
"errors"
+ "fmt"
"math/rand"
"time"
@@ -15,9 +16,10 @@ import (
const (
arriveTimeout = 500 * time.Millisecond // Time allowance before an announced block is explicitly requested
+ gatherSlack = 100 * time.Millisecond // Interval used to collate almost-expired announces with fetches
fetchTimeout = 5 * time.Second // Maximum alloted time to return an explicitly requested block
maxUncleDist = 7 // Maximum allowed backward distance from the chain head
- maxQueueDist = 256 // Maximum allowed distance from the chain head to queue
+ maxQueueDist = 32 // Maximum allowed distance from the chain head to queue
)
var (
@@ -239,7 +241,7 @@ func (f *Fetcher) loop() {
request := make(map[string][]common.Hash)
for hash, announces := range f.announced {
- if time.Since(announces[0].time) > arriveTimeout {
+ if time.Since(announces[0].time) > arriveTimeout-gatherSlack {
announce := announces[rand.Intn(len(announces))]
if f.getBlock(hash) == nil {
request[announce.origin] = append(request[announce.origin], hash)
@@ -249,7 +251,16 @@ func (f *Fetcher) loop() {
}
}
// Send out all block requests
- for _, hashes := range request {
+ for peer, hashes := range request {
+ if glog.V(logger.Detail) && len(hashes) > 0 {
+ list := "["
+ for _, hash := range hashes {
+ list += fmt.Sprintf("%x, ", hash[:4])
+ }
+ list = list[:len(list)-2] + "]"
+
+ glog.V(logger.Detail).Infof("Peer %s: fetching %s", peer, list)
+ }
go f.fetching[hashes[0]].fetch(hashes)
}
// Schedule the next fetch if blocks are still pending
@@ -319,7 +330,7 @@ func (f *Fetcher) enqueue(peer string, block *types.Block) {
// Discard any past or too distant blocks
if dist := int64(block.NumberU64()) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
- glog.V(logger.Detail).Infof("Peer %s: discarded block #%d [%x], distance %d", peer, block.NumberU64(), hash.Bytes()[:4], dist)
+ glog.V(logger.Debug).Infof("Peer %s: discarded block #%d [%x], distance %d", peer, block.NumberU64(), hash.Bytes()[:4], dist)
return
}
// Schedule the block for future importing
diff --git a/eth/handler.go b/eth/handler.go
index a5986b779..ad88e9c59 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -6,7 +6,6 @@ import (
"sync"
"time"
- "github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -16,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/p2p"
+ "github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -307,7 +307,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
blocks = nil
}
// Update the receive timestamp of each block
- for i:=0; i<len(blocks); i++ {
+ for i := 0; i < len(blocks); i++ {
blocks[i].ReceivedAt = msg.ReceivedAt
}
// Filter out any explicitly requested blocks, deliver the rest to the downloader
@@ -417,8 +417,8 @@ func (self *ProtocolManager) minedBroadcastLoop() {
for obj := range self.minedBlockSub.Chan() {
switch ev := obj.(type) {
case core.NewMinedBlockEvent:
- self.BroadcastBlock(ev.Block, false)
- self.BroadcastBlock(ev.Block, true)
+ self.BroadcastBlock(ev.Block, true) // First propagate block to peers
+ self.BroadcastBlock(ev.Block, false) // Only then announce to the rest
}
}
}
diff --git a/rpc/args_test.go b/rpc/args_test.go
index 81a2972cd..fd20dbab8 100644
--- a/rpc/args_test.go
+++ b/rpc/args_test.go
@@ -2577,3 +2577,57 @@ func TestSigArgsEmpty(t *testing.T) {
t.Error(str)
}
}
+
+func TestDataArgs(t *testing.T) {
+ input := `["0x0123"]`
+ expected := new(NewDataArgs)
+ expected.Data = "0x0123"
+
+ args := new(NewDataArgs)
+ if err := json.Unmarshal([]byte(input), &args); err != nil {
+ t.Error(err)
+ }
+
+ if expected.Data != args.Data {
+ t.Errorf("Data should be %v but is %v", expected.Data, args.Data)
+ }
+}
+
+func TestDataArgsEmptyData(t *testing.T) {
+ input := `[""]`
+
+ args := new(NewDataArgs)
+ str := ExpectValidationError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestDataArgsDataType(t *testing.T) {
+ input := `[13]`
+
+ args := new(NewDataArgs)
+ str := ExpectInvalidTypeError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestDataArgsEmpty(t *testing.T) {
+ input := `[]`
+ args := new(NewDataArgs)
+ str := ExpectInsufficientParamsError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}
+
+func TestDataArgsInvalid(t *testing.T) {
+ input := `{}`
+
+ args := new(NewDataArgs)
+ str := ExpectDecodeParamError(json.Unmarshal([]byte(input), args))
+ if len(str) > 0 {
+ t.Error(str)
+ }
+}