forked from cerc-io/plugeth
289b30715d
This commit converts the dependency management from Godeps to the vendor folder, also switching the tool from godep to trash. Since the upstream tool lacks a few features proposed via a few PRs, until those PRs are merged in (if), use github.com/karalabe/trash. You can update dependencies via trash --update. All dependencies have been updated to their latest version. Parts of the build system are reworked to drop old notions of Godeps and invocation of the go vet command so that it doesn't run against the vendor folder, as that will just blow up during vetting. The conversion drops OpenCL (and hence GPU mining support) from ethash and our codebase. The short reasoning is that there's noone to maintain and having opencl libs in our deps messes up builds as go install ./... tries to build them, failing with unsatisfied link errors for the C OpenCL deps. golang.org/x/net/context is not vendored in. We expect it to be fetched by the user (i.e. using go get). To keep ci.go builds reproducible the package is "vendored" in build/_vendor.
68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com>
|
|
// All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
package leveldb
|
|
|
|
import (
|
|
"github.com/syndtr/goleveldb/leveldb/comparer"
|
|
)
|
|
|
|
type iComparer struct {
|
|
ucmp comparer.Comparer
|
|
}
|
|
|
|
func (icmp *iComparer) uName() string {
|
|
return icmp.ucmp.Name()
|
|
}
|
|
|
|
func (icmp *iComparer) uCompare(a, b []byte) int {
|
|
return icmp.ucmp.Compare(a, b)
|
|
}
|
|
|
|
func (icmp *iComparer) uSeparator(dst, a, b []byte) []byte {
|
|
return icmp.ucmp.Separator(dst, a, b)
|
|
}
|
|
|
|
func (icmp *iComparer) uSuccessor(dst, b []byte) []byte {
|
|
return icmp.ucmp.Successor(dst, b)
|
|
}
|
|
|
|
func (icmp *iComparer) Name() string {
|
|
return icmp.uName()
|
|
}
|
|
|
|
func (icmp *iComparer) Compare(a, b []byte) int {
|
|
x := icmp.uCompare(internalKey(a).ukey(), internalKey(b).ukey())
|
|
if x == 0 {
|
|
if m, n := internalKey(a).num(), internalKey(b).num(); m > n {
|
|
return -1
|
|
} else if m < n {
|
|
return 1
|
|
}
|
|
}
|
|
return x
|
|
}
|
|
|
|
func (icmp *iComparer) Separator(dst, a, b []byte) []byte {
|
|
ua, ub := internalKey(a).ukey(), internalKey(b).ukey()
|
|
dst = icmp.uSeparator(dst, ua, ub)
|
|
if dst != nil && len(dst) < len(ua) && icmp.uCompare(ua, dst) < 0 {
|
|
// Append earliest possible number.
|
|
return append(dst, keyMaxNumBytes...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (icmp *iComparer) Successor(dst, b []byte) []byte {
|
|
ub := internalKey(b).ukey()
|
|
dst = icmp.uSuccessor(dst, ub)
|
|
if dst != nil && len(dst) < len(ub) && icmp.uCompare(ub, dst) < 0 {
|
|
// Append earliest possible number.
|
|
return append(dst, keyMaxNumBytes...)
|
|
}
|
|
return nil
|
|
}
|