all: import "context" instead of "golang.org/x/net/context"
There is no need to depend on the old context package now that the minimum Go version is 1.7. The move to "context" eliminates our weird vendoring setup. Some vendored code still uses golang.org/x/net/context and it is now vendored in the normal way. This change triggered new vet checks around context.WithTimeout which didn't fire with golang.org/x/net/context.
This commit is contained in:
parent
525116dbff
commit
c213fd1fd8
@ -17,13 +17,13 @@
|
||||
package bind
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,6 +17,7 @@
|
||||
package backends
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@ -34,7 +35,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/pow"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Default chain configuration which sets homestead phase at block 0 (i.e. no frontier)
|
||||
|
@ -17,6 +17,7 @@
|
||||
package bind
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@ -26,7 +27,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// SignerFn is a signer function callback when a contract requires a method to
|
||||
|
@ -17,13 +17,13 @@
|
||||
package bind
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// WaitMined waits for tx to be mined on the blockchain.
|
||||
|
@ -17,6 +17,7 @@
|
||||
package bind_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
@ -27,7 +28,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
|
@ -21,6 +21,7 @@
|
||||
package usbwallet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
@ -38,7 +39,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/karalabe/hid"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Maximum time between wallet health checks to detect USB unplugs.
|
||||
|
@ -1,27 +0,0 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -1,18 +1,3 @@
|
||||
# Vendored Dependencies
|
||||
|
||||
Dependencies are almost all vendored in at the standard Go `/vendor` path. This allows
|
||||
people to build go-ethereum using the standard toolchain without any particular package
|
||||
manager. It also plays nicely with `go get`, not requiring external code to be relied on.
|
||||
|
||||
The one single dependent package missing from `vendor` is `golang.org/x/net/context`. As
|
||||
this is a package exposed via public library APIs, it must not be vendored as dependent
|
||||
code woulnd't be able to instantiate.
|
||||
|
||||
To allow reproducible builds of go-ethereum nonetheless that don't need network access
|
||||
during build time to fetch `golang.org/x/net/context`, a version was copied into our repo
|
||||
at the very specific `/build/_vendor` path, which is added automatically by all CI build
|
||||
scripts and the makefile too.
|
||||
|
||||
# Debian Packaging
|
||||
|
||||
Tagged releases and develop branch commits are available as installable Debian packages
|
||||
|
@ -26,6 +26,7 @@ package chequebook
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@ -43,7 +44,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/services/swap/swap"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// TODO(zelig): watch peer solvency and notify of bouncing cheques
|
||||
|
@ -20,6 +20,7 @@ package release
|
||||
//go:generate abigen --sol ./contract.sol --pkg release --out ./contract.go
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@ -33,7 +34,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Interval to check for new releases
|
||||
@ -116,22 +116,31 @@ func (r *ReleaseService) checker() {
|
||||
|
||||
for {
|
||||
select {
|
||||
// If the time arrived, check for a new release
|
||||
case <-timer.C:
|
||||
// Rechedule the timer before continuing
|
||||
timer.Reset(releaseRecheckInterval)
|
||||
r.checkVersion()
|
||||
case errc := <-r.quit:
|
||||
errc <- nil
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ReleaseService) checkVersion() {
|
||||
// Retrieve the current version, and handle missing contracts gracefully
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
opts := &bind.CallOpts{Context: ctx}
|
||||
defer cancel()
|
||||
|
||||
version, err := r.oracle.CurrentVersion(opts)
|
||||
if err != nil {
|
||||
if err == bind.ErrNoCode {
|
||||
log.Debug("Release oracle not found", "contract", r.config.Oracle)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
log.Error("Failed to retrieve current release", "err", err)
|
||||
continue
|
||||
}
|
||||
return
|
||||
}
|
||||
// Version was successfully retrieved, notify if newer than ours
|
||||
if version.Major > r.config.Major ||
|
||||
@ -152,11 +161,4 @@ func (r *ReleaseService) checker() {
|
||||
"local", fmt.Sprintf("v%d.%d.%d-%x", r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4]),
|
||||
"upstream", fmt.Sprintf("v%d.%d.%d-%x", version.Major, version.Minor, version.Patch, version.Commit[:4]))
|
||||
}
|
||||
|
||||
// If termination was requested, return
|
||||
case errc := <-r.quit:
|
||||
errc <- nil
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package eth
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -39,7 +40,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/miner"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const defaultTraceTimeout = 5 * time.Second
|
||||
|
@ -17,6 +17,7 @@
|
||||
package eth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
@ -33,7 +34,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// EthApiBackend implements ethapi.Backend for full nodes
|
||||
|
@ -17,6 +17,7 @@
|
||||
package eth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum"
|
||||
@ -26,7 +27,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// ContractBackend implements bind.ContractBackend with direct calls to Ethereum
|
||||
|
@ -17,12 +17,12 @@
|
||||
package downloader
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// PublicDownloaderAPI provides an API which gives information about the current synchronisation status.
|
||||
|
@ -17,6 +17,7 @@
|
||||
package filters
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -24,8 +25,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
@ -17,10 +17,10 @@
|
||||
package filters
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
@ -28,7 +28,6 @@ import (
|
||||
"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 {
|
||||
|
@ -19,6 +19,7 @@
|
||||
package filters
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
@ -29,7 +30,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"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
|
||||
@ -372,7 +372,8 @@ func (es *EventSystem) lightFilterNewHead(newHeader *types.Header, callBack func
|
||||
func (es *EventSystem) lightFilterLogs(header *types.Header, addresses []common.Address, topics [][]common.Hash, remove bool) []*types.Log {
|
||||
if bloomFilter(header.Bloom, addresses, topics) {
|
||||
// Get the logs of the block
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
receipts, err := es.backend.GetReceipts(ctx, header.Hash())
|
||||
if err != nil {
|
||||
return nil
|
||||
|
@ -17,13 +17,12 @@
|
||||
package filters
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"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"
|
||||
|
@ -17,13 +17,12 @@
|
||||
package filters
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"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"
|
||||
|
@ -17,6 +17,7 @@
|
||||
package gasprice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"sort"
|
||||
"sync"
|
||||
@ -24,7 +25,6 @@ import (
|
||||
"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 (
|
||||
|
@ -18,6 +18,7 @@
|
||||
package ethclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@ -28,7 +29,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Client defines typed wrappers for the Ethereum RPC API.
|
||||
|
@ -17,11 +17,11 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/mclock"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Subscription represents a stream of events. The carrier of the events is typically a
|
||||
|
@ -17,11 +17,10 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var errInts = errors.New("error in subscribeInts")
|
||||
|
@ -18,12 +18,12 @@
|
||||
package ethereum
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// NotFound is returned by API methods if the requested item does not exist.
|
||||
|
@ -52,19 +52,10 @@ func MustRunCommand(cmd string, args ...string) {
|
||||
// GOPATH returns the value that the GOPATH environment
|
||||
// variable should be set to.
|
||||
func GOPATH() string {
|
||||
path := filepath.SplitList(os.Getenv("GOPATH"))
|
||||
if len(path) == 0 {
|
||||
if os.Getenv("GOPATH") == "" {
|
||||
log.Fatal("GOPATH is not set")
|
||||
}
|
||||
// Ensure that our internal vendor folder is on GOPATH
|
||||
vendor, _ := filepath.Abs(filepath.Join("build", "_vendor"))
|
||||
for _, dir := range path {
|
||||
if dir == vendor {
|
||||
return strings.Join(path, string(filepath.ListSeparator))
|
||||
}
|
||||
}
|
||||
newpath := append(path[:1], append([]string{vendor}, path[1:]...)...)
|
||||
return strings.Join(newpath, string(filepath.ListSeparator))
|
||||
return os.Getenv("GOPATH")
|
||||
}
|
||||
|
||||
// VERSION returns the content of the VERSION file.
|
||||
|
@ -18,6 +18,7 @@ package ethapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -43,7 +44,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"github.com/syndtr/goleveldb/leveldb/util"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -18,6 +18,7 @@
|
||||
package ethapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
@ -30,7 +31,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Backend interface provides the common API services (that are provided by
|
||||
|
@ -17,6 +17,7 @@
|
||||
package les
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
@ -33,7 +34,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/light"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type LesApiBackend struct {
|
||||
|
@ -17,6 +17,7 @@
|
||||
package les
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"sync"
|
||||
@ -26,7 +27,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/light"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -18,6 +18,7 @@ package les
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
@ -32,7 +33,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/light"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type odrTestFn func(ctx context.Context, db ethdb.Database, config *params.ChainConfig, bc *core.BlockChain, lc *light.LightChain, bhash common.Hash) []byte
|
||||
@ -181,8 +181,11 @@ func testOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) {
|
||||
for i := uint64(0); i <= pm.blockchain.CurrentHeader().Number.Uint64(); i++ {
|
||||
bhash := core.GetCanonicalHash(db, i)
|
||||
b1 := fn(light.NoOdr, db, pm.chainConfig, pm.blockchain.(*core.BlockChain), nil, bhash)
|
||||
ctx, _ := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
defer cancel()
|
||||
b2 := fn(ctx, ldb, lpm.chainConfig, nil, lpm.blockchain.(*light.LightChain), bhash)
|
||||
|
||||
eq := bytes.Equal(b1, b2)
|
||||
exp := i < expFail
|
||||
if exp && !eq {
|
||||
|
@ -17,6 +17,7 @@
|
||||
package les
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -25,7 +26,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/light"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var testBankSecureTrieKey = secAddr(testBankAddress)
|
||||
@ -91,7 +91,9 @@ func testAccess(t *testing.T, protocol int, fn accessTestFn) {
|
||||
for i := uint64(0); i <= pm.blockchain.CurrentHeader().Number.Uint64(); i++ {
|
||||
bhash := core.GetCanonicalHash(db, i)
|
||||
if req := fn(ldb, bhash, i); req != nil {
|
||||
ctx, _ := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
defer cancel()
|
||||
|
||||
err := odr.Retrieve(ctx, req)
|
||||
got := err == nil
|
||||
exp := i < expFail
|
||||
|
@ -17,12 +17,12 @@
|
||||
package les
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
"github.com/ethereum/go-ethereum/light"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -77,8 +77,8 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
pm.blockchain.(*light.LightChain).SyncCht(ctx)
|
||||
|
||||
pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td(), downloader.LightSync)
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -32,7 +33,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/pow"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,6 +17,7 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"runtime"
|
||||
@ -30,7 +31,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/pow"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// So we can deterministically seed different blockchains
|
||||
|
@ -19,6 +19,7 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@ -27,7 +28,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// NoOdr is the default context passed to an ODR capable function when the ODR
|
||||
|
@ -18,6 +18,7 @@ package light
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"math/big"
|
||||
"testing"
|
||||
@ -36,7 +37,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/pow"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -277,8 +277,11 @@ func testChainOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) {
|
||||
for i := uint64(0); i <= blockchain.CurrentHeader().Number.Uint64(); i++ {
|
||||
bhash := core.GetCanonicalHash(sdb, i)
|
||||
b1 := fn(NoOdr, sdb, blockchain, nil, bhash)
|
||||
ctx, _ := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
defer cancel()
|
||||
b2 := fn(ctx, ldb, nil, lightchain, bhash)
|
||||
|
||||
eq := bytes.Equal(b1, b2)
|
||||
exp := i < expFail
|
||||
if exp && !eq {
|
||||
|
@ -18,6 +18,7 @@ package light
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
@ -27,7 +28,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var sha3_nil = crypto.Keccak256Hash(nil)
|
||||
|
@ -17,11 +17,11 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// LightState is a memory representation of a state.
|
||||
|
@ -18,13 +18,13 @@ package light
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var emptyCodeHash = crypto.Keccak256(nil)
|
||||
|
@ -18,6 +18,7 @@ package light
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
@ -26,7 +27,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func makeTestState() (common.Hash, ethdb.Database) {
|
||||
|
@ -17,9 +17,10 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// LightTrie is an ODR-capable wrapper around trie.SecureTrie
|
||||
|
@ -17,6 +17,7 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
@ -29,7 +30,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// txPermanent is the number of mined blocks after a mined transaction is
|
||||
@ -230,13 +230,13 @@ func (pool *TxPool) rollbackTxs(hash common.Hash, txc txStateChanges) {
|
||||
}
|
||||
}
|
||||
|
||||
// setNewHead sets a new head header, processing (and rolling back if necessary)
|
||||
// reorgOnNewHead sets a new head header, processing (and rolling back if necessary)
|
||||
// the blocks since the last known head and returns a txStateChanges map containing
|
||||
// the recently mined and rolled back transaction hashes. If an error (context
|
||||
// timeout) occurs during checking new blocks, it leaves the locally known head
|
||||
// at the latest checked block and still returns a valid txStateChanges, making it
|
||||
// possible to continue checking the missing blocks at the next chain head event
|
||||
func (pool *TxPool) setNewHead(ctx context.Context, newHeader *types.Header) (txStateChanges, error) {
|
||||
func (pool *TxPool) reorgOnNewHead(ctx context.Context, newHeader *types.Header) (txStateChanges, error) {
|
||||
txc := make(txStateChanges)
|
||||
oldh := pool.chain.GetHeaderByHash(pool.head)
|
||||
newh := newHeader
|
||||
@ -305,18 +305,26 @@ func (pool *TxPool) eventLoop() {
|
||||
for ev := range pool.events.Chan() {
|
||||
switch ev.Data.(type) {
|
||||
case core.ChainHeadEvent:
|
||||
head := pool.chain.CurrentHeader()
|
||||
pool.setNewHead(ev.Data.(core.ChainHeadEvent).Block.Header())
|
||||
// hack in order to avoid hogging the lock; this part will
|
||||
// be replaced by a subsequent PR.
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (pool *TxPool) setNewHead(head *types.Header) {
|
||||
pool.mu.Lock()
|
||||
ctx, _ := context.WithTimeout(context.Background(), blockCheckTimeout)
|
||||
txc, _ := pool.setNewHead(ctx, head)
|
||||
defer pool.mu.Unlock()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), blockCheckTimeout)
|
||||
defer cancel()
|
||||
|
||||
txc, _ := pool.reorgOnNewHead(ctx, head)
|
||||
m, r := txc.getLists()
|
||||
pool.relay.NewHead(pool.head, m, r)
|
||||
pool.homestead = pool.config.IsHomestead(head.Number)
|
||||
pool.signer = types.MakeSigner(pool.config, head.Number)
|
||||
pool.mu.Unlock()
|
||||
time.Sleep(time.Millisecond) // hack in order to avoid hogging the lock; this part will be replaced by a subsequent PR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stop stops the light transaction pool
|
||||
|
@ -17,6 +17,7 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"math/big"
|
||||
"testing"
|
||||
@ -30,7 +31,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/pow"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type testTxRelay struct {
|
||||
@ -107,10 +107,11 @@ func TestTxPool(t *testing.T) {
|
||||
lightchain.SetValidator(bproc{})
|
||||
txPermanent = 50
|
||||
pool := NewTxPool(testChainConfig(), evmux, lightchain, relay)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
|
||||
for ii, block := range gchain {
|
||||
i := ii + 1
|
||||
ctx, _ := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
s := sentTx(i - 1)
|
||||
e := sentTx(i)
|
||||
for i := s; i < e; i++ {
|
||||
|
@ -17,12 +17,12 @@
|
||||
package light
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// VMState is a wrapper for the light state that holds the actual context and
|
||||
|
@ -20,9 +20,8 @@
|
||||
package geth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Context carries a deadline, a cancelation signal, and other values across API
|
||||
|
@ -19,6 +19,7 @@ package rpc
|
||||
import (
|
||||
"bytes"
|
||||
"container/list"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -31,7 +32,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1,60 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
// +build !go1.5
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// In older versions of Go (below 1.5), dials cannot be canceled
|
||||
// via a channel or context. The context deadline can still applied.
|
||||
|
||||
// contextDialer returns a dialer that applies the deadline value from the given context.
|
||||
func contextDialer(ctx context.Context) *net.Dialer {
|
||||
dialer := &net.Dialer{KeepAlive: tcpKeepAliveInterval}
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
dialer.Deadline = deadline
|
||||
} else {
|
||||
dialer.Deadline = time.Now().Add(defaultDialTimeout)
|
||||
}
|
||||
return dialer
|
||||
}
|
||||
|
||||
// dialContext connects to the given address, aborting the dial if ctx is canceled.
|
||||
func dialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
return contextDialer(ctx).Dial(network, addr)
|
||||
}
|
||||
|
||||
// requestWithContext copies req, adding the cancelation channel and deadline from ctx.
|
||||
func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) {
|
||||
// Set Timeout on the client if the context has a deadline.
|
||||
// Note that there is no default timeout (unlike in contextDialer) because
|
||||
// the timeout applies to the entire request, including reads from body.
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
c2 := *c
|
||||
c2.Timeout = deadline.Sub(time.Now())
|
||||
c = &c2
|
||||
}
|
||||
req2 := *req
|
||||
return c, &req2
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
// +build go1.5,!go1.6
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// In Go 1.5, dials cannot be canceled via a channel or context. The context deadline can
|
||||
// still be applied. Go 1.5 adds the ability to cancel HTTP requests via a channel.
|
||||
|
||||
// contextDialer returns a dialer that applies the deadline value from the given context.
|
||||
func contextDialer(ctx context.Context) *net.Dialer {
|
||||
dialer := &net.Dialer{KeepAlive: tcpKeepAliveInterval}
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
dialer.Deadline = deadline
|
||||
} else {
|
||||
dialer.Deadline = time.Now().Add(defaultDialTimeout)
|
||||
}
|
||||
return dialer
|
||||
}
|
||||
|
||||
// dialContext connects to the given address, aborting the dial if ctx is canceled.
|
||||
func dialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
return contextDialer(ctx).Dial(network, addr)
|
||||
}
|
||||
|
||||
// requestWithContext copies req, adding the cancelation channel and deadline from ctx.
|
||||
func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) {
|
||||
// Set Timeout on the client if the context has a deadline.
|
||||
// Note that there is no default timeout (unlike in contextDialer) because
|
||||
// the timeout applies to the entire request, including reads from body.
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
c2 := *c
|
||||
c2.Timeout = deadline.Sub(time.Now())
|
||||
c = &c2
|
||||
}
|
||||
req2 := *req
|
||||
req2.Cancel = ctx.Done()
|
||||
return c, &req2
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
// +build go1.6,!go1.7
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// In Go 1.6, net.Dialer gained the ability to cancel via a channel.
|
||||
|
||||
// contextDialer returns a dialer that applies the deadline value from the given context.
|
||||
func contextDialer(ctx context.Context) *net.Dialer {
|
||||
dialer := &net.Dialer{Cancel: ctx.Done(), KeepAlive: tcpKeepAliveInterval}
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
dialer.Deadline = deadline
|
||||
} else {
|
||||
dialer.Deadline = time.Now().Add(defaultDialTimeout)
|
||||
}
|
||||
return dialer
|
||||
}
|
||||
|
||||
// dialContext connects to the given address, aborting the dial if ctx is canceled.
|
||||
func dialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
return contextDialer(ctx).Dial(network, addr)
|
||||
}
|
||||
|
||||
// requestWithContext copies req, adding the cancelation channel and deadline from ctx.
|
||||
func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) {
|
||||
// We set Timeout on the client for Go <= 1.5. There
|
||||
// is no need to do that here because the dial will be canceled
|
||||
// by package http.
|
||||
req2 := *req
|
||||
req2.Cancel = ctx.Done()
|
||||
return c, &req2
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
// +build go1.7
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// In Go 1.7, context moved into the standard library and support
|
||||
// for cancelation via context was added to net.Dialer and http.Request.
|
||||
|
||||
// contextDialer returns a dialer that applies the deadline value from the given context.
|
||||
func contextDialer(ctx context.Context) *net.Dialer {
|
||||
dialer := &net.Dialer{Cancel: ctx.Done(), KeepAlive: tcpKeepAliveInterval}
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
dialer.Deadline = deadline
|
||||
} else {
|
||||
dialer.Deadline = time.Now().Add(defaultDialTimeout)
|
||||
}
|
||||
return dialer
|
||||
}
|
||||
|
||||
// dialContext connects to the given address, aborting the dial if ctx is canceled.
|
||||
func dialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
d := &net.Dialer{KeepAlive: tcpKeepAliveInterval}
|
||||
return d.DialContext(ctx, network, addr)
|
||||
}
|
||||
|
||||
// requestWithContext copies req, adding the cancelation channel and deadline from ctx.
|
||||
func requestWithContext(c *http.Client, req *http.Request, ctx context.Context) (*http.Client, *http.Request) {
|
||||
return c, req.WithContext(ctx)
|
||||
}
|
@ -17,12 +17,12 @@
|
||||
package rpc_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// In this example, our client whishes to track the latest 'block number'
|
||||
|
@ -17,6 +17,7 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
@ -31,7 +32,6 @@ import (
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestClientRequest(t *testing.T) {
|
||||
|
@ -18,6 +18,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -29,7 +30,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/cors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -115,11 +115,11 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, req := requestWithContext(hc.client, hc.req, ctx)
|
||||
req := hc.req.WithContext(ctx)
|
||||
req.Body = ioutil.NopCloser(bytes.NewReader(body))
|
||||
req.ContentLength = int64(len(body))
|
||||
|
||||
resp, err := client.Do(req)
|
||||
resp, err := hc.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -17,9 +17,8 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// NewInProcClient attaches an in-process connection to the given RPC server.
|
||||
|
@ -17,12 +17,11 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// CreateIPCListener creates an listener, on Unix platforms this is a unix socket, on
|
||||
|
@ -19,11 +19,10 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// ipcListen will create a Unix socket on the given endpoint.
|
||||
|
@ -19,10 +19,10 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"gopkg.in/natefinch/npipe.v2"
|
||||
)
|
||||
|
||||
|
@ -17,14 +17,13 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"gopkg.in/fatih/set.v0"
|
||||
)
|
||||
|
||||
|
@ -17,13 +17,12 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type Service struct{}
|
||||
|
@ -17,10 +17,9 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,13 +17,12 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type NotificationTestService struct {
|
||||
|
@ -18,6 +18,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
crand "crypto/rand"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
@ -29,8 +30,6 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,6 +17,7 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
@ -24,10 +25,9 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/net/websocket"
|
||||
"gopkg.in/fatih/set.v0"
|
||||
)
|
||||
@ -150,3 +150,18 @@ func wsDialAddress(location *url.URL) string {
|
||||
}
|
||||
return location.Host
|
||||
}
|
||||
|
||||
func dialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
d := &net.Dialer{KeepAlive: tcpKeepAliveInterval}
|
||||
return d.DialContext(ctx, network, addr)
|
||||
}
|
||||
|
||||
func contextDialer(ctx context.Context) *net.Dialer {
|
||||
dialer := &net.Dialer{Cancel: ctx.Done(), KeepAlive: tcpKeepAliveInterval}
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
dialer.Deadline = deadline
|
||||
} else {
|
||||
dialer.Deadline = time.Now().Add(defaultDialTimeout)
|
||||
}
|
||||
return dialer
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package swap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@ -33,7 +34,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/swarm/services/swap/swap"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// SwAP Swarm Accounting Protocol with
|
||||
|
@ -18,6 +18,7 @@ package swarm
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"fmt"
|
||||
|
||||
@ -35,7 +36,6 @@ import (
|
||||
httpapi "github.com/ethereum/go-ethereum/swarm/api/http"
|
||||
"github.com/ethereum/go-ethereum/swarm/network"
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// the swarm stack
|
||||
|
8
vendor/vendor.json
vendored
8
vendor/vendor.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"comment": "",
|
||||
"ignore": "test golang.org/x/net/context",
|
||||
"ignore": "test",
|
||||
"package": [
|
||||
{
|
||||
"checksumSHA1": "M30X+Wqn7AnUr1numUOkQRI7ET0=",
|
||||
@ -383,6 +383,12 @@
|
||||
"revision": "453249f01cfeb54c3d549ddb75ff152ca243f9d8",
|
||||
"revisionTime": "2017-02-08T20:51:15Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "Y+HGqEkYM15ir+J93MEaHdyFy0c=",
|
||||
"path": "golang.org/x/net/context",
|
||||
"revision": "a6577fac2d73be281a500b310739095313165611",
|
||||
"revisionTime": "2017-03-08T20:54:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "vqc3a+oTUGX8PmD0TS+qQ7gmN8I=",
|
||||
"path": "golang.org/x/net/html",
|
||||
|
Loading…
Reference in New Issue
Block a user