From 806b56b5abd4872eda8bc25f2b95029c7630eac6 Mon Sep 17 00:00:00 2001 From: Julian Yap Date: Sat, 28 Jul 2018 00:20:56 -1000 Subject: [PATCH] all: import "context" instead of "golang.org/x/net/context" --- accounts/abi/bind/backend.go | 2 +- accounts/abi/bind/backends/simulated.go | 2 +- accounts/abi/bind/base.go | 2 +- accounts/abi/bind/util.go | 2 +- accounts/abi/bind/util_test.go | 2 +- accounts/usbwallet/ledger_wallet.go | 2 +- build/_vendor/src/golang.org/x/net/LICENSE | 27 -- .../src/golang.org/x/net/context/context.go | 156 --------- .../src/golang.org/x/net/context/go17.go | 72 ----- .../src/golang.org/x/net/context/pre_go17.go | 300 ------------------ build/ci-notes.md | 15 - contracts/chequebook/cheque.go | 2 +- contracts/release/release.go | 72 +++-- eth/api.go | 2 +- eth/api_backend.go | 2 +- eth/bind.go | 2 +- eth/downloader/api.go | 2 +- eth/filters/api.go | 3 +- eth/filters/filter.go | 2 +- eth/filters/filter_system.go | 5 +- eth/filters/filter_system_test.go | 3 +- eth/filters/filter_test.go | 3 +- eth/gasprice/lightprice.go | 2 +- ethclient/ethclient.go | 2 +- event/subscription.go | 2 +- event/subscription_test.go | 3 +- interfaces.go | 2 +- internal/build/util.go | 13 +- internal/ethapi/api.go | 2 +- internal/ethapi/backend.go | 2 +- les/api_backend.go | 2 +- les/odr.go | 2 +- les/odr_test.go | 5 +- les/request_test.go | 6 +- les/sync.go | 6 +- light/lightchain.go | 2 +- light/lightchain_test.go | 2 +- light/odr.go | 2 +- light/odr_test.go | 5 +- light/odr_util.go | 2 +- light/state.go | 2 +- light/state_object.go | 2 +- light/state_test.go | 2 +- light/trie.go | 2 +- light/txpool.go | 51 +-- light/txpool_test.go | 5 +- light/vm_env.go | 2 +- mobile/context.go | 6 +- rpc/client.go | 2 +- rpc/client_context_go1.4.go | 60 ---- rpc/client_context_go1.5.go | 61 ---- rpc/client_context_go1.6.go | 55 ---- rpc/client_context_go1.7.go | 51 --- rpc/client_example_test.go | 2 +- rpc/client_test.go | 2 +- rpc/http.go | 6 +- rpc/inproc.go | 3 +- rpc/ipc.go | 2 +- rpc/ipc_unix.go | 3 +- rpc/ipc_windows.go | 2 +- rpc/server.go | 2 +- rpc/server_test.go | 3 +- rpc/subscription.go | 3 +- rpc/subscription_test.go | 3 +- rpc/utils.go | 3 +- rpc/websocket.go | 18 +- swarm/services/swap/swap.go | 2 +- swarm/swarm.go | 2 +- vendor.conf | 2 - .../Azure/azure-sdk-for-go/.travis.yml | 1 - vendor/github.com/rs/cors/cors.go | 2 +- vendor/github.com/rs/xhandler/chain.go | 3 +- vendor/github.com/rs/xhandler/middleware.go | 3 +- vendor/github.com/rs/xhandler/xhandler.go | 3 +- 74 files changed, 161 insertions(+), 952 deletions(-) delete mode 100644 build/_vendor/src/golang.org/x/net/LICENSE delete mode 100644 build/_vendor/src/golang.org/x/net/context/context.go delete mode 100644 build/_vendor/src/golang.org/x/net/context/go17.go delete mode 100644 build/_vendor/src/golang.org/x/net/context/pre_go17.go delete mode 100644 rpc/client_context_go1.4.go delete mode 100644 rpc/client_context_go1.5.go delete mode 100644 rpc/client_context_go1.6.go delete mode 100644 rpc/client_context_go1.7.go diff --git a/accounts/abi/bind/backend.go b/accounts/abi/bind/backend.go index 91e005f0a3..9c3da8e695 100644 --- a/accounts/abi/bind/backend.go +++ b/accounts/abi/bind/backend.go @@ -17,13 +17,13 @@ package bind import ( + "context" "errors" "math/big" "github.com/ubiq/go-ubiq" "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/core/types" - "golang.org/x/net/context" ) var ( diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 772c50cadf..9b47980845 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -17,6 +17,7 @@ package backends import ( + "context" "errors" "fmt" "math/big" @@ -32,7 +33,6 @@ import ( "github.com/ubiq/go-ubiq/ethdb" "github.com/ubiq/go-ubiq/event" "github.com/ubiq/go-ubiq/params" - "golang.org/x/net/context" ) // Default chain configuration which sets homestead phase at block 0 (i.e. no frontier) diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index 9fcee75f24..9fe2cf131c 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -17,6 +17,7 @@ package bind import ( + "context" "errors" "fmt" "math/big" @@ -26,7 +27,6 @@ import ( "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/crypto" - "golang.org/x/net/context" ) // SignerFn is a signer function callback when a contract requires a method to diff --git a/accounts/abi/bind/util.go b/accounts/abi/bind/util.go index 0e74c62f2c..4f9f7fdd8a 100644 --- a/accounts/abi/bind/util.go +++ b/accounts/abi/bind/util.go @@ -17,6 +17,7 @@ package bind import ( + "context" "fmt" "time" @@ -24,7 +25,6 @@ import ( "github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" ) // WaitMined waits for tx to be mined on the blockchain. diff --git a/accounts/abi/bind/util_test.go b/accounts/abi/bind/util_test.go index f304dcbc38..5789ec0473 100644 --- a/accounts/abi/bind/util_test.go +++ b/accounts/abi/bind/util_test.go @@ -17,6 +17,7 @@ package bind_test import ( + "context" "math/big" "testing" "time" @@ -27,7 +28,6 @@ import ( "github.com/ubiq/go-ubiq/core" "github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/crypto" - "golang.org/x/net/context" ) var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") diff --git a/accounts/usbwallet/ledger_wallet.go b/accounts/usbwallet/ledger_wallet.go index a91ef56405..01609f895d 100644 --- a/accounts/usbwallet/ledger_wallet.go +++ b/accounts/usbwallet/ledger_wallet.go @@ -21,6 +21,7 @@ package usbwallet import ( + "context" "encoding/binary" "encoding/hex" "errors" @@ -38,7 +39,6 @@ import ( "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" "github.com/ubiq/go-ubiq/rlp" - "golang.org/x/net/context" ) // Maximum time between wallet health checks to detect USB unplugs. diff --git a/build/_vendor/src/golang.org/x/net/LICENSE b/build/_vendor/src/golang.org/x/net/LICENSE deleted file mode 100644 index 6a66aea5ea..0000000000 --- a/build/_vendor/src/golang.org/x/net/LICENSE +++ /dev/null @@ -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. diff --git a/build/_vendor/src/golang.org/x/net/context/context.go b/build/_vendor/src/golang.org/x/net/context/context.go deleted file mode 100644 index 134654cf7e..0000000000 --- a/build/_vendor/src/golang.org/x/net/context/context.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package context defines the Context type, which carries deadlines, -// cancelation signals, and other request-scoped values across API boundaries -// and between processes. -// -// Incoming requests to a server should create a Context, and outgoing calls to -// servers should accept a Context. The chain of function calls between must -// propagate the Context, optionally replacing it with a modified copy created -// using WithDeadline, WithTimeout, WithCancel, or WithValue. -// -// Programs that use Contexts should follow these rules to keep interfaces -// consistent across packages and enable static analysis tools to check context -// propagation: -// -// Do not store Contexts inside a struct type; instead, pass a Context -// explicitly to each function that needs it. The Context should be the first -// parameter, typically named ctx: -// -// func DoSomething(ctx context.Context, arg Arg) error { -// // ... use ctx ... -// } -// -// Do not pass a nil Context, even if a function permits it. Pass context.TODO -// if you are unsure about which Context to use. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -// -// The same Context may be passed to functions running in different goroutines; -// Contexts are safe for simultaneous use by multiple goroutines. -// -// See http://blog.golang.org/context for example code for a server that uses -// Contexts. -package context // import "golang.org/x/net/context" - -import "time" - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context interface { - // Deadline returns the time when work done on behalf of this context - // should be canceled. Deadline returns ok==false when no deadline is - // set. Successive calls to Deadline return the same results. - Deadline() (deadline time.Time, ok bool) - - // Done returns a channel that's closed when work done on behalf of this - // context should be canceled. Done may return nil if this context can - // never be canceled. Successive calls to Done return the same value. - // - // WithCancel arranges for Done to be closed when cancel is called; - // WithDeadline arranges for Done to be closed when the deadline - // expires; WithTimeout arranges for Done to be closed when the timeout - // elapses. - // - // Done is provided for use in select statements: - // - // // Stream generates values with DoSomething and sends them to out - // // until DoSomething returns an error or ctx.Done is closed. - // func Stream(ctx context.Context, out chan<- Value) error { - // for { - // v, err := DoSomething(ctx) - // if err != nil { - // return err - // } - // select { - // case <-ctx.Done(): - // return ctx.Err() - // case out <- v: - // } - // } - // } - // - // See http://blog.golang.org/pipelines for more examples of how to use - // a Done channel for cancelation. - Done() <-chan struct{} - - // Err returns a non-nil error value after Done is closed. Err returns - // Canceled if the context was canceled or DeadlineExceeded if the - // context's deadline passed. No other values for Err are defined. - // After Done is closed, successive calls to Err return the same value. - Err() error - - // Value returns the value associated with this context for key, or nil - // if no value is associated with key. Successive calls to Value with - // the same key returns the same result. - // - // Use context values only for request-scoped data that transits - // processes and API boundaries, not for passing optional parameters to - // functions. - // - // A key identifies a specific value in a Context. Functions that wish - // to store values in Context typically allocate a key in a global - // variable then use that key as the argument to context.WithValue and - // Context.Value. A key can be any type that supports equality; - // packages should define keys as an unexported type to avoid - // collisions. - // - // Packages that define a Context key should provide type-safe accessors - // for the values stores using that key: - // - // // Package user defines a User type that's stored in Contexts. - // package user - // - // import "golang.org/x/net/context" - // - // // User is the type of value stored in the Contexts. - // type User struct {...} - // - // // key is an unexported type for keys defined in this package. - // // This prevents collisions with keys defined in other packages. - // type key int - // - // // userKey is the key for user.User values in Contexts. It is - // // unexported; clients use user.NewContext and user.FromContext - // // instead of using this key directly. - // var userKey key = 0 - // - // // NewContext returns a new Context that carries value u. - // func NewContext(ctx context.Context, u *User) context.Context { - // return context.WithValue(ctx, userKey, u) - // } - // - // // FromContext returns the User value stored in ctx, if any. - // func FromContext(ctx context.Context) (*User, bool) { - // u, ok := ctx.Value(userKey).(*User) - // return u, ok - // } - Value(key interface{}) interface{} -} - -// Background returns a non-nil, empty Context. It is never canceled, has no -// values, and has no deadline. It is typically used by the main function, -// initialization, and tests, and as the top-level Context for incoming -// requests. -func Background() Context { - return background -} - -// TODO returns a non-nil, empty Context. Code should use context.TODO when -// it's unclear which Context to use or it is not yet available (because the -// surrounding function has not yet been extended to accept a Context -// parameter). TODO is recognized by static analysis tools that determine -// whether Contexts are propagated correctly in a program. -func TODO() Context { - return todo -} - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc func() diff --git a/build/_vendor/src/golang.org/x/net/context/go17.go b/build/_vendor/src/golang.org/x/net/context/go17.go deleted file mode 100644 index f8cda19ada..0000000000 --- a/build/_vendor/src/golang.org/x/net/context/go17.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.7 - -package context - -import ( - "context" // standard library's context, as of Go 1.7 - "time" -) - -var ( - todo = context.TODO() - background = context.Background() -) - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = context.Canceled - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = context.DeadlineExceeded - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - ctx, f := context.WithCancel(parent) - return ctx, CancelFunc(f) -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - ctx, f := context.WithDeadline(parent, deadline) - return ctx, CancelFunc(f) -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return context.WithValue(parent, key, val) -} diff --git a/build/_vendor/src/golang.org/x/net/context/pre_go17.go b/build/_vendor/src/golang.org/x/net/context/pre_go17.go deleted file mode 100644 index 5a30acabd0..0000000000 --- a/build/_vendor/src/golang.org/x/net/context/pre_go17.go +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.7 - -package context - -import ( - "errors" - "fmt" - "sync" - "time" -) - -// An emptyCtx is never canceled, has no values, and has no deadline. It is not -// struct{}, since vars of this type must have distinct addresses. -type emptyCtx int - -func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { - return -} - -func (*emptyCtx) Done() <-chan struct{} { - return nil -} - -func (*emptyCtx) Err() error { - return nil -} - -func (*emptyCtx) Value(key interface{}) interface{} { - return nil -} - -func (e *emptyCtx) String() string { - switch e { - case background: - return "context.Background" - case todo: - return "context.TODO" - } - return "unknown empty Context" -} - -var ( - background = new(emptyCtx) - todo = new(emptyCtx) -) - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = errors.New("context canceled") - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = errors.New("context deadline exceeded") - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - c := newCancelCtx(parent) - propagateCancel(parent, c) - return c, func() { c.cancel(true, Canceled) } -} - -// newCancelCtx returns an initialized cancelCtx. -func newCancelCtx(parent Context) *cancelCtx { - return &cancelCtx{ - Context: parent, - done: make(chan struct{}), - } -} - -// propagateCancel arranges for child to be canceled when parent is. -func propagateCancel(parent Context, child canceler) { - if parent.Done() == nil { - return // parent is never canceled - } - if p, ok := parentCancelCtx(parent); ok { - p.mu.Lock() - if p.err != nil { - // parent has already been canceled - child.cancel(false, p.err) - } else { - if p.children == nil { - p.children = make(map[canceler]bool) - } - p.children[child] = true - } - p.mu.Unlock() - } else { - go func() { - select { - case <-parent.Done(): - child.cancel(false, parent.Err()) - case <-child.Done(): - } - }() - } -} - -// parentCancelCtx follows a chain of parent references until it finds a -// *cancelCtx. This function understands how each of the concrete types in this -// package represents its parent. -func parentCancelCtx(parent Context) (*cancelCtx, bool) { - for { - switch c := parent.(type) { - case *cancelCtx: - return c, true - case *timerCtx: - return c.cancelCtx, true - case *valueCtx: - parent = c.Context - default: - return nil, false - } - } -} - -// removeChild removes a context from its parent. -func removeChild(parent Context, child canceler) { - p, ok := parentCancelCtx(parent) - if !ok { - return - } - p.mu.Lock() - if p.children != nil { - delete(p.children, child) - } - p.mu.Unlock() -} - -// A canceler is a context type that can be canceled directly. The -// implementations are *cancelCtx and *timerCtx. -type canceler interface { - cancel(removeFromParent bool, err error) - Done() <-chan struct{} -} - -// A cancelCtx can be canceled. When canceled, it also cancels any children -// that implement canceler. -type cancelCtx struct { - Context - - done chan struct{} // closed by the first cancel call. - - mu sync.Mutex - children map[canceler]bool // set to nil by the first cancel call - err error // set to non-nil by the first cancel call -} - -func (c *cancelCtx) Done() <-chan struct{} { - return c.done -} - -func (c *cancelCtx) Err() error { - c.mu.Lock() - defer c.mu.Unlock() - return c.err -} - -func (c *cancelCtx) String() string { - return fmt.Sprintf("%v.WithCancel", c.Context) -} - -// cancel closes c.done, cancels each of c's children, and, if -// removeFromParent is true, removes c from its parent's children. -func (c *cancelCtx) cancel(removeFromParent bool, err error) { - if err == nil { - panic("context: internal error: missing cancel error") - } - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return // already canceled - } - c.err = err - close(c.done) - for child := range c.children { - // NOTE: acquiring the child's lock while holding parent's lock. - child.cancel(false, err) - } - c.children = nil - c.mu.Unlock() - - if removeFromParent { - removeChild(c.Context, c) - } -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { - // The current deadline is already sooner than the new one. - return WithCancel(parent) - } - c := &timerCtx{ - cancelCtx: newCancelCtx(parent), - deadline: deadline, - } - propagateCancel(parent, c) - d := deadline.Sub(time.Now()) - if d <= 0 { - c.cancel(true, DeadlineExceeded) // deadline has already passed - return c, func() { c.cancel(true, Canceled) } - } - c.mu.Lock() - defer c.mu.Unlock() - if c.err == nil { - c.timer = time.AfterFunc(d, func() { - c.cancel(true, DeadlineExceeded) - }) - } - return c, func() { c.cancel(true, Canceled) } -} - -// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to -// implement Done and Err. It implements cancel by stopping its timer then -// delegating to cancelCtx.cancel. -type timerCtx struct { - *cancelCtx - timer *time.Timer // Under cancelCtx.mu. - - deadline time.Time -} - -func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { - return c.deadline, true -} - -func (c *timerCtx) String() string { - return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) -} - -func (c *timerCtx) cancel(removeFromParent bool, err error) { - c.cancelCtx.cancel(false, err) - if removeFromParent { - // Remove this timerCtx from its parent cancelCtx's children. - removeChild(c.cancelCtx.Context, c) - } - c.mu.Lock() - if c.timer != nil { - c.timer.Stop() - c.timer = nil - } - c.mu.Unlock() -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return &valueCtx{parent, key, val} -} - -// A valueCtx carries a key-value pair. It implements Value for that key and -// delegates all other calls to the embedded Context. -type valueCtx struct { - Context - key, val interface{} -} - -func (c *valueCtx) String() string { - return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) -} - -func (c *valueCtx) Value(key interface{}) interface{} { - if c.key == key { - return c.val - } - return c.Context.Value(key) -} diff --git a/build/ci-notes.md b/build/ci-notes.md index 5546aea30a..26d2f5652d 100644 --- a/build/ci-notes.md +++ b/build/ci-notes.md @@ -1,18 +1,3 @@ -# Vendored Dependencies - -Dependencies are almost all vendored in at the standard Go `/vendor` path. This allows -people to build go-ubiq 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-ubiq 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 diff --git a/contracts/chequebook/cheque.go b/contracts/chequebook/cheque.go index 42ec391ca0..f0bcc52afd 100644 --- a/contracts/chequebook/cheque.go +++ b/contracts/chequebook/cheque.go @@ -26,6 +26,7 @@ package chequebook import ( "bytes" + "context" "crypto/ecdsa" "encoding/json" "fmt" @@ -43,7 +44,6 @@ import ( "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" "github.com/ubiq/go-ubiq/swarm/services/swap/swap" - "golang.org/x/net/context" ) // TODO(zelig): watch peer solvency and notify of bouncing cheques diff --git a/contracts/release/release.go b/contracts/release/release.go index 835c1d5343..49d0236661 100644 --- a/contracts/release/release.go +++ b/contracts/release/release.go @@ -20,6 +20,7 @@ package release //go:generate abigen --sol ./contract.sol --pkg release --out ./contract.go import ( + "context" "fmt" "strings" "time" @@ -34,7 +35,6 @@ import ( "github.com/ubiq/go-ubiq/node" "github.com/ubiq/go-ubiq/p2p" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) // Interval to check for new releases @@ -117,46 +117,48 @@ 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) - - // Retrieve the current version, and handle missing contracts gracefully - ctx, _ := context.WithTimeout(context.Background(), time.Second*5) - opts := &bind.CallOpts{Context: ctx} - version, err := r.oracle.CurrentVersion(opts) - if err != nil { - if err == bind.ErrNoCode { - glog.V(logger.Debug).Infof("Release oracle not found at %x", r.config.Oracle) - continue - } - glog.V(logger.Error).Infof("Failed to retrieve current release: %v", err) - continue - } - // Version was successfully retrieved, notify if newer than ours - if version.Major > r.config.Major || - (version.Major == r.config.Major && version.Minor > r.config.Minor) || - (version.Major == r.config.Major && version.Minor == r.config.Minor && version.Patch > r.config.Patch) { - - warning := fmt.Sprintf("Client v%d.%d.%d-%x seems older than the latest upstream release v%d.%d.%d-%x", - r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4]) - howtofix := fmt.Sprintf("Please check https://github.com/ubiq/go-ubiq/releases for new releases") - separator := strings.Repeat("-", len(warning)) - - glog.V(logger.Warn).Info(separator) - glog.V(logger.Warn).Info(warning) - glog.V(logger.Warn).Info(howtofix) - glog.V(logger.Warn).Info(separator) - } else { - glog.V(logger.Debug).Infof("Client v%d.%d.%d-%x seems up to date with upstream v%d.%d.%d-%x", - r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4]) - } - - // If termination was requested, return + r.checkVersion() case errc := <-r.quit: errc <- nil return } } } + +func (r *ReleaseService) checkVersion() { + // Retrieve the current version, and handle missing contracts gracefully + 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 { + glog.V(logger.Debug).Infof("Release oracle not found at %x", r.config.Oracle) + } else { + glog.V(logger.Error).Infof("Failed to retrieve current release: %v", err) + } + return + } + // Version was successfully retrieved, notify if newer than ours + if version.Major > r.config.Major || + (version.Major == r.config.Major && version.Minor > r.config.Minor) || + (version.Major == r.config.Major && version.Minor == r.config.Minor && version.Patch > r.config.Patch) { + + warning := fmt.Sprintf("Client v%d.%d.%d-%x seems older than the latest upstream release v%d.%d.%d-%x", + r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4]) + howtofix := fmt.Sprintf("Please check https://github.com/ethereum/go-ethereum/releases for new releases") + separator := strings.Repeat("-", len(warning)) + + glog.V(logger.Warn).Info(separator) + glog.V(logger.Warn).Info(warning) + glog.V(logger.Warn).Info(howtofix) + glog.V(logger.Warn).Info(separator) + } else { + glog.V(logger.Debug).Infof("Client v%d.%d.%d-%x seems up to date with upstream v%d.%d.%d-%x", + r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4]) + } +} diff --git a/eth/api.go b/eth/api.go index b239599a2f..2f7eaf5436 100644 --- a/eth/api.go +++ b/eth/api.go @@ -19,6 +19,7 @@ package eth import ( "bytes" "compress/gzip" + "context" "errors" "fmt" "io" @@ -43,7 +44,6 @@ import ( "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/rlp" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) const defaultTraceTimeout = 5 * time.Second diff --git a/eth/api_backend.go b/eth/api_backend.go index 89e9ce3019..005d8ea387 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -17,6 +17,7 @@ package eth import ( + "context" "math/big" "github.com/ubiq/go-ubiq/accounts" @@ -32,7 +33,6 @@ import ( "github.com/ubiq/go-ubiq/internal/ethapi" "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) // EthApiBackend implements ethapi.Backend for full nodes diff --git a/eth/bind.go b/eth/bind.go index 52b4b9f86a..4e1668f413 100644 --- a/eth/bind.go +++ b/eth/bind.go @@ -17,6 +17,7 @@ package eth import ( + "context" "math/big" "github.com/ubiq/go-ubiq" @@ -26,7 +27,6 @@ import ( "github.com/ubiq/go-ubiq/internal/ethapi" "github.com/ubiq/go-ubiq/rlp" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) // ContractBackend implements bind.ContractBackend with direct calls to Ethereum diff --git a/eth/downloader/api.go b/eth/downloader/api.go index a198ea60d9..f5d83297a6 100644 --- a/eth/downloader/api.go +++ b/eth/downloader/api.go @@ -17,12 +17,12 @@ package downloader import ( + "context" "sync" ethereum "github.com/ubiq/go-ubiq" "github.com/ubiq/go-ubiq/event" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) // PublicDownloaderAPI provides an API which gives information about the current synchronisation status. diff --git a/eth/filters/api.go b/eth/filters/api.go index 7d9eee6113..c9e495999c 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -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/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/common/hexutil" "github.com/ubiq/go-ubiq/core/types" diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 6d49b68490..3ee10578f2 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -17,6 +17,7 @@ package filters import ( + "context" "math" "time" "math/big" @@ -27,7 +28,6 @@ import ( "github.com/ubiq/go-ubiq/ethdb" "github.com/ubiq/go-ubiq/event" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) type Backend interface { diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index 5a9ac4a975..413bc91a3d 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -19,6 +19,7 @@ package filters import ( + "context" "errors" "fmt" "sync" @@ -29,7 +30,6 @@ import ( "github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/event" "github.com/ubiq/go-ubiq/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 diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index fd1460434b..17f0e11729 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -17,13 +17,12 @@ package filters import ( + "context" "math/big" "reflect" "testing" "time" - "golang.org/x/net/context" - "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/core" "github.com/ubiq/go-ubiq/core/types" diff --git a/eth/filters/filter_test.go b/eth/filters/filter_test.go index 478a43e060..4cbb0299b3 100644 --- a/eth/filters/filter_test.go +++ b/eth/filters/filter_test.go @@ -17,13 +17,12 @@ package filters import ( + "context" "io/ioutil" "math/big" "os" "testing" - "golang.org/x/net/context" - "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/core" "github.com/ubiq/go-ubiq/core/types" diff --git a/eth/gasprice/lightprice.go b/eth/gasprice/lightprice.go index 32ba0e8ee0..091d3f98a6 100644 --- a/eth/gasprice/lightprice.go +++ b/eth/gasprice/lightprice.go @@ -17,6 +17,7 @@ package gasprice import ( + "context" "math/big" "sort" "sync" @@ -24,7 +25,6 @@ import ( "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/internal/ethapi" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) const ( diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 06db3f458f..37da24bcc2 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -18,6 +18,7 @@ package ethclient import ( + "context" "encoding/json" "fmt" "math/big" @@ -28,7 +29,6 @@ import ( "github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/rlp" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) // Client defines typed wrappers for the Ethereum RPC API. diff --git a/event/subscription.go b/event/subscription.go index 3318319fdc..313a04976b 100644 --- a/event/subscription.go +++ b/event/subscription.go @@ -17,11 +17,11 @@ package event import ( + "context" "sync" "time" "github.com/ubiq/go-ubiq/common/mclock" - "golang.org/x/net/context" ) // Subscription represents a stream of events. The carrier of the events is typically a diff --git a/event/subscription_test.go b/event/subscription_test.go index a4fe30298c..aa6d98984d 100644 --- a/event/subscription_test.go +++ b/event/subscription_test.go @@ -17,11 +17,10 @@ package event import ( + "context" "errors" "testing" "time" - - "golang.org/x/net/context" ) var errInts = errors.New("error in subscribeInts") diff --git a/interfaces.go b/interfaces.go index fef95f60af..4ef6c16c49 100644 --- a/interfaces.go +++ b/interfaces.go @@ -18,12 +18,12 @@ package ethereum import ( + "context" "errors" "math/big" "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/core/types" - "golang.org/x/net/context" ) // NotFound is returned by API methods if the requested item does not exist. diff --git a/internal/build/util.go b/internal/build/util.go index 1523a067bc..4df7b91381 100644 --- a/internal/build/util.go +++ b/internal/build/util.go @@ -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. diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 220be13d78..cd2486cd25 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -17,6 +17,7 @@ package ethapi import ( + "context" "encoding/hex" "errors" "fmt" @@ -41,7 +42,6 @@ import ( "github.com/ubiq/go-ubiq/p2p" "github.com/ubiq/go-ubiq/rlp" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) const defaultGas = 90000 diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index eb0ca2a1f9..9e7be80836 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -18,6 +18,7 @@ package ethapi import ( + "context" "math/big" "github.com/ubiq/go-ubiq/accounts" @@ -30,7 +31,6 @@ import ( "github.com/ubiq/go-ubiq/event" "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) // Backend interface provides the common API services (that are provided by diff --git a/les/api_backend.go b/les/api_backend.go index 85bf0f6894..5988e9842e 100644 --- a/les/api_backend.go +++ b/les/api_backend.go @@ -17,6 +17,7 @@ package les import ( + "context" "math/big" "github.com/ubiq/go-ubiq/accounts" @@ -32,7 +33,6 @@ import ( "github.com/ubiq/go-ubiq/light" "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) type LesApiBackend struct { diff --git a/les/odr.go b/les/odr.go index 041cc9aee1..5014a623f1 100644 --- a/les/odr.go +++ b/les/odr.go @@ -17,6 +17,7 @@ package les import ( + "context" "crypto/rand" "encoding/binary" "sync" @@ -27,7 +28,6 @@ import ( "github.com/ubiq/go-ubiq/light" "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" ) var ( diff --git a/les/odr_test.go b/les/odr_test.go index 232ee39454..41a15101b8 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -18,6 +18,7 @@ package les import ( "bytes" + "context" "math/big" "testing" "time" @@ -31,7 +32,6 @@ import ( "github.com/ubiq/go-ubiq/light" "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/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 @@ -177,7 +177,8 @@ 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 diff --git a/les/request_test.go b/les/request_test.go index 0960bacc47..75d1da2168 100644 --- a/les/request_test.go +++ b/les/request_test.go @@ -17,6 +17,7 @@ package les import ( + "context" "testing" "time" @@ -25,7 +26,6 @@ import ( "github.com/ubiq/go-ubiq/crypto" "github.com/ubiq/go-ubiq/ethdb" "github.com/ubiq/go-ubiq/light" - "golang.org/x/net/context" ) var testBankSecureTrieKey = secAddr(testBankAddress) @@ -88,7 +88,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 diff --git a/les/sync.go b/les/sync.go index 5c09de8c1d..a4bbb150f7 100644 --- a/les/sync.go +++ b/les/sync.go @@ -17,12 +17,12 @@ package les import ( + "context" "time" "github.com/ubiq/go-ubiq/core" "github.com/ubiq/go-ubiq/eth/downloader" "github.com/ubiq/go-ubiq/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) } diff --git a/light/lightchain.go b/light/lightchain.go index 7e035d5e83..299e2d5975 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -17,6 +17,7 @@ package light import ( + "context" "math/big" "sync" "sync/atomic" @@ -33,7 +34,6 @@ import ( "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/pow" "github.com/ubiq/go-ubiq/rlp" - "golang.org/x/net/context" ) var ( diff --git a/light/lightchain_test.go b/light/lightchain_test.go index aa52385af2..053a92f75f 100644 --- a/light/lightchain_test.go +++ b/light/lightchain_test.go @@ -17,6 +17,7 @@ package light import ( + "context" "fmt" "math/big" "runtime" @@ -31,7 +32,6 @@ import ( "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/pow" "github.com/hashicorp/golang-lru" - "golang.org/x/net/context" ) // So we can deterministically seed different blockchains diff --git a/light/odr.go b/light/odr.go index 197ed152cd..6d86c80917 100644 --- a/light/odr.go +++ b/light/odr.go @@ -19,6 +19,7 @@ package light import ( + "context" "math/big" "github.com/ubiq/go-ubiq/common" @@ -27,7 +28,6 @@ import ( "github.com/ubiq/go-ubiq/crypto" "github.com/ubiq/go-ubiq/ethdb" "github.com/ubiq/go-ubiq/rlp" - "golang.org/x/net/context" ) // NoOdr is the default context passed to an ODR capable function when the ODR diff --git a/light/odr_test.go b/light/odr_test.go index 6b2b993635..18c31c1a08 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -18,6 +18,7 @@ package light import ( "bytes" + "context" "errors" "math/big" "testing" @@ -34,7 +35,6 @@ import ( "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/rlp" "github.com/ubiq/go-ubiq/trie" - "golang.org/x/net/context" ) var ( @@ -273,7 +273,8 @@ 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 diff --git a/light/odr_util.go b/light/odr_util.go index 1cb3605360..3131025912 100644 --- a/light/odr_util.go +++ b/light/odr_util.go @@ -18,6 +18,7 @@ package light import ( "bytes" + "context" "errors" "math/big" @@ -29,7 +30,6 @@ import ( "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" "github.com/ubiq/go-ubiq/rlp" - "golang.org/x/net/context" ) var sha3_nil = crypto.Keccak256Hash(nil) diff --git a/light/state.go b/light/state.go index cb51c1ac3d..a7e2a45ad6 100644 --- a/light/state.go +++ b/light/state.go @@ -17,13 +17,13 @@ package light import ( + "context" "math/big" "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/crypto" "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" ) // LightState is a memory representation of a state. diff --git a/light/state_object.go b/light/state_object.go index 17044df479..eb9d12b68e 100644 --- a/light/state_object.go +++ b/light/state_object.go @@ -18,6 +18,7 @@ package light import ( "bytes" + "context" "fmt" "math/big" @@ -26,7 +27,6 @@ import ( "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" "github.com/ubiq/go-ubiq/rlp" - "golang.org/x/net/context" ) var emptyCodeHash = crypto.Keccak256(nil) diff --git a/light/state_test.go b/light/state_test.go index 7b9ce4f618..be2f2cafea 100644 --- a/light/state_test.go +++ b/light/state_test.go @@ -18,6 +18,7 @@ package light import ( "bytes" + "context" "math/big" "testing" @@ -26,7 +27,6 @@ import ( "github.com/ubiq/go-ubiq/core/state" "github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/ethdb" - "golang.org/x/net/context" ) func makeTestState() (common.Hash, ethdb.Database) { diff --git a/light/trie.go b/light/trie.go index 81a68a2f00..01ac30d223 100644 --- a/light/trie.go +++ b/light/trie.go @@ -17,9 +17,9 @@ package light import ( + "context" "github.com/ubiq/go-ubiq/ethdb" "github.com/ubiq/go-ubiq/trie" - "golang.org/x/net/context" ) // LightTrie is an ODR-capable wrapper around trie.SecureTrie diff --git a/light/txpool.go b/light/txpool.go index 8dc67bd5bc..90ad99281a 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -17,6 +17,7 @@ package light import ( + "context" "fmt" "sync" "time" @@ -30,7 +31,6 @@ import ( "github.com/ubiq/go-ubiq/logger/glog" "github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/rlp" - "golang.org/x/net/context" ) // txPermanent is the number of mined blocks after a mined transaction is @@ -207,13 +207,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 @@ -253,15 +253,17 @@ func (pool *TxPool) setNewHead(ctx context.Context, newHeader *types.Header) (tx // clear old mined tx entries of old blocks if idx := newHeader.Number.Uint64(); idx > pool.clearIdx+txPermanent { idx2 := idx - txPermanent - for i := pool.clearIdx; i < idx2; i++ { - hash := core.GetCanonicalHash(pool.chainDb, i) - if list, ok := pool.mined[hash]; ok { - hashes := make([]common.Hash, len(list)) - for i, tx := range list { - hashes[i] = tx.Hash() + if len(pool.mined) > 0 { + for i := pool.clearIdx; i < idx2; i++ { + hash := core.GetCanonicalHash(pool.chainDb, i) + if list, ok := pool.mined[hash]; ok { + hashes := make([]common.Hash, len(list)) + for i, tx := range list { + hashes[i] = tx.Hash() + } + pool.relay.Discard(hashes) + delete(pool.mined, hash) } - pool.relay.Discard(hashes) - delete(pool.mined, hash) } } pool.clearIdx = idx2 @@ -280,19 +282,28 @@ func (pool *TxPool) eventLoop() { for ev := range pool.events.Chan() { switch ev.Data.(type) { case core.ChainHeadEvent: - pool.mu.Lock() - ctx, _ := context.WithTimeout(context.Background(), blockCheckTimeout) - head := pool.chain.CurrentHeader() - txc, _ := pool.setNewHead(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() + 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() + 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) +} + // Stop stops the light transaction pool func (pool *TxPool) Stop() { close(pool.quit) diff --git a/light/txpool_test.go b/light/txpool_test.go index 60d1256d41..0d091627af 100644 --- a/light/txpool_test.go +++ b/light/txpool_test.go @@ -17,6 +17,7 @@ package light import ( + "context" "math" "math/big" "testing" @@ -29,7 +30,6 @@ import ( "github.com/ubiq/go-ubiq/ethdb" "github.com/ubiq/go-ubiq/event" "github.com/ubiq/go-ubiq/params" - "golang.org/x/net/context" ) type testTxRelay struct { @@ -106,10 +106,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++ { diff --git a/light/vm_env.go b/light/vm_env.go index bc98c7788f..e1aed2eee8 100644 --- a/light/vm_env.go +++ b/light/vm_env.go @@ -17,13 +17,13 @@ package light import ( + "context" "math/big" "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/core/vm" "github.com/ubiq/go-ubiq/crypto" - "golang.org/x/net/context" ) // VMState is a wrapper for the light state that holds the actual context and diff --git a/mobile/context.go b/mobile/context.go index 281419905c..7f87f7e6e1 100644 --- a/mobile/context.go +++ b/mobile/context.go @@ -14,15 +14,11 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -// Contains all the wrappers from the golang.org/x/net/context package to support -// client side context management on mobile platforms. - package gubiq import ( + "context" "time" - - "golang.org/x/net/context" ) // Context carries a deadline, a cancelation signal, and other values across API diff --git a/rpc/client.go b/rpc/client.go index 0dce933e37..532d8eaf93 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -19,6 +19,7 @@ package rpc import ( "bytes" "container/list" + "context" "encoding/json" "errors" "fmt" @@ -32,7 +33,6 @@ import ( "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" ) var ( diff --git a/rpc/client_context_go1.4.go b/rpc/client_context_go1.4.go deleted file mode 100644 index ac956a17dd..0000000000 --- a/rpc/client_context_go1.4.go +++ /dev/null @@ -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 . - -// +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 -} diff --git a/rpc/client_context_go1.5.go b/rpc/client_context_go1.5.go deleted file mode 100644 index 4a007d9f8a..0000000000 --- a/rpc/client_context_go1.5.go +++ /dev/null @@ -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 . - -// +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 -} diff --git a/rpc/client_context_go1.6.go b/rpc/client_context_go1.6.go deleted file mode 100644 index 67777ddc6a..0000000000 --- a/rpc/client_context_go1.6.go +++ /dev/null @@ -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 . - -// +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 -} diff --git a/rpc/client_context_go1.7.go b/rpc/client_context_go1.7.go deleted file mode 100644 index 56ce12ab8e..0000000000 --- a/rpc/client_context_go1.7.go +++ /dev/null @@ -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 . - -// +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) -} diff --git a/rpc/client_example_test.go b/rpc/client_example_test.go index 3d72f5714a..b3a4711a3a 100644 --- a/rpc/client_example_test.go +++ b/rpc/client_example_test.go @@ -17,12 +17,12 @@ package rpc_test import ( + "context" "fmt" "math/big" "time" "github.com/ubiq/go-ubiq/rpc" - "golang.org/x/net/context" ) // In this example, our client whishes to track the latest 'block number' diff --git a/rpc/client_test.go b/rpc/client_test.go index 3b965245e9..777a1ab769 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -17,6 +17,7 @@ package rpc import ( + "context" "fmt" "math/rand" "net" @@ -32,7 +33,6 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" ) func TestClientRequest(t *testing.T) { diff --git a/rpc/http.go b/rpc/http.go index 7d4fe5d474..96ae942748 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -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 } diff --git a/rpc/inproc.go b/rpc/inproc.go index f72b974977..595a7ca651 100644 --- a/rpc/inproc.go +++ b/rpc/inproc.go @@ -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. diff --git a/rpc/ipc.go b/rpc/ipc.go index b0273105da..f7b5996565 100644 --- a/rpc/ipc.go +++ b/rpc/ipc.go @@ -17,11 +17,11 @@ package rpc import ( + "context" "net" "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" ) // CreateIPCListener creates an listener, on Unix platforms this is a unix socket, on diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go index a25b216277..0851ea61e1 100644 --- a/rpc/ipc_unix.go +++ b/rpc/ipc_unix.go @@ -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. diff --git a/rpc/ipc_windows.go b/rpc/ipc_windows.go index 68234d2151..ca56a3ce43 100644 --- a/rpc/ipc_windows.go +++ b/rpc/ipc_windows.go @@ -19,10 +19,10 @@ package rpc import ( + "context" "net" "time" - "golang.org/x/net/context" "gopkg.in/natefinch/npipe.v2" ) diff --git a/rpc/server.go b/rpc/server.go index e3ef3ef0fe..72a3f27202 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -17,6 +17,7 @@ package rpc import ( + "context" "fmt" "reflect" "runtime" @@ -24,7 +25,6 @@ import ( "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" "gopkg.in/fatih/set.v0" ) diff --git a/rpc/server_test.go b/rpc/server_test.go index c3c88fab75..90d62f26d8 100644 --- a/rpc/server_test.go +++ b/rpc/server_test.go @@ -17,13 +17,12 @@ package rpc import ( + "context" "encoding/json" "net" "reflect" "testing" "time" - - "golang.org/x/net/context" ) type Service struct{} diff --git a/rpc/subscription.go b/rpc/subscription.go index bcdc3cdfca..9ab6af9e14 100644 --- a/rpc/subscription.go +++ b/rpc/subscription.go @@ -17,10 +17,9 @@ package rpc import ( + "context" "errors" "sync" - - "golang.org/x/net/context" ) var ( diff --git a/rpc/subscription_test.go b/rpc/subscription_test.go index 00c4e0e354..345b4e5f29 100644 --- a/rpc/subscription_test.go +++ b/rpc/subscription_test.go @@ -17,13 +17,12 @@ package rpc import ( + "context" "encoding/json" "net" "sync" "testing" "time" - - "golang.org/x/net/context" ) type NotificationTestService struct { diff --git a/rpc/utils.go b/rpc/utils.go index c249e9b4a8..2506c48331 100644 --- a/rpc/utils.go +++ b/rpc/utils.go @@ -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 ( diff --git a/rpc/websocket.go b/rpc/websocket.go index 67e693f184..674d1a9826 100644 --- a/rpc/websocket.go +++ b/rpc/websocket.go @@ -17,6 +17,7 @@ package rpc import ( + "context" "crypto/tls" "fmt" "net" @@ -24,10 +25,10 @@ import ( "net/url" "os" "strings" + "time" "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" - "golang.org/x/net/context" "golang.org/x/net/websocket" "gopkg.in/fatih/set.v0" ) @@ -150,3 +151,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 +} diff --git a/swarm/services/swap/swap.go b/swarm/services/swap/swap.go index c87d707144..5ef8f3929b 100644 --- a/swarm/services/swap/swap.go +++ b/swarm/services/swap/swap.go @@ -17,6 +17,7 @@ package swap import ( + "context" "crypto/ecdsa" "fmt" "math/big" @@ -34,7 +35,6 @@ import ( "github.com/ubiq/go-ubiq/logger" "github.com/ubiq/go-ubiq/logger/glog" "github.com/ubiq/go-ubiq/swarm/services/swap/swap" - "golang.org/x/net/context" ) // SwAP Swarm Accounting Protocol with diff --git a/swarm/swarm.go b/swarm/swarm.go index 2fe0f67711..21bd1c88f8 100644 --- a/swarm/swarm.go +++ b/swarm/swarm.go @@ -18,6 +18,7 @@ package swarm import ( "bytes" + "context" "crypto/ecdsa" "fmt" @@ -36,7 +37,6 @@ import ( httpapi "github.com/ubiq/go-ubiq/swarm/api/http" "github.com/ubiq/go-ubiq/swarm/network" "github.com/ubiq/go-ubiq/swarm/storage" - "golang.org/x/net/context" ) // the swarm stack diff --git a/vendor.conf b/vendor.conf index 286d8121b7..e9ee32dcb8 100644 --- a/vendor.conf +++ b/vendor.conf @@ -40,5 +40,3 @@ gopkg.in/natefinch/npipe.v2 c1b8fa8 gopkg.in/sourcemap.v1 v1.0.3 gopkg.in/urfave/cli.v1 v1.19.1 -# exclude --golang.org/x/net/context diff --git a/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml b/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml index 6a134afebf..679d3167d2 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml +++ b/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml @@ -7,7 +7,6 @@ go: 1.7 install: - go get -u github.com/golang/lint/golint - go get -u github.com/Masterminds/glide - - go get -u golang.org/x/net/context - go get -u github.com/HewlettPackard/gas - go get -u gopkg.in/godo.v2/cmd/godo - export GO15VENDOREXPERIMENT=1 diff --git a/vendor/github.com/rs/cors/cors.go b/vendor/github.com/rs/cors/cors.go index 4bb22d8fce..849ab6e1f8 100644 --- a/vendor/github.com/rs/cors/cors.go +++ b/vendor/github.com/rs/cors/cors.go @@ -21,6 +21,7 @@ The resulting handler is a standard net/http handler. package cors import ( + "context" "log" "net/http" "os" @@ -28,7 +29,6 @@ import ( "strings" "github.com/rs/xhandler" - "golang.org/x/net/context" ) // Options is a configuration container to setup the CORS middleware. diff --git a/vendor/github.com/rs/xhandler/chain.go b/vendor/github.com/rs/xhandler/chain.go index 3e4bd359c5..80ce0e9dab 100644 --- a/vendor/github.com/rs/xhandler/chain.go +++ b/vendor/github.com/rs/xhandler/chain.go @@ -1,9 +1,8 @@ package xhandler import ( + "context" "net/http" - - "golang.org/x/net/context" ) // Chain is a helper for chaining middleware handlers together for easier diff --git a/vendor/github.com/rs/xhandler/middleware.go b/vendor/github.com/rs/xhandler/middleware.go index 7ad8fba625..11c7e6171a 100644 --- a/vendor/github.com/rs/xhandler/middleware.go +++ b/vendor/github.com/rs/xhandler/middleware.go @@ -1,10 +1,9 @@ package xhandler import ( + "context" "net/http" "time" - - "golang.org/x/net/context" ) // CloseHandler returns a Handler, cancelling the context when the client diff --git a/vendor/github.com/rs/xhandler/xhandler.go b/vendor/github.com/rs/xhandler/xhandler.go index bc832cb1fa..04faeef454 100644 --- a/vendor/github.com/rs/xhandler/xhandler.go +++ b/vendor/github.com/rs/xhandler/xhandler.go @@ -12,9 +12,8 @@ package xhandler // import "github.com/rs/xhandler" import ( + "context" "net/http" - - "golang.org/x/net/context" ) // HandlerC is a net/context aware http.Handler