Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
general linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-hanna committed Jan 31, 2019
1 parent fc0fb5c commit 8f443ba
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 154 deletions.
4 changes: 2 additions & 2 deletions client/p2p/peers/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type DiscoveryNotifee struct {

// HandlePeerFound ...
func (d *DiscoveryNotifee) HandlePeerFound(pi peerstore.PeerInfo) {
kp, err := d.peers.Get(pi)
_, err := d.peers.Get(pi)
if err == ErrNoSuchPeer {
kp, err = d.peers.Add(pi)
kp, err := d.peers.Add(pi)
if err != nil {
logger.Errorf("[peers] err adding peer with info %v\n%v", pi, err)
return
Expand Down
2 changes: 1 addition & 1 deletion common/fileflatdb/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func writeUIntBE(buffer []byte, value, offset, byteLength int64) {
}

slice = buf.Bytes()
slice = slice[int64(len(slice))-byteLength : len(slice)]
slice = slice[int64(len(slice))-byteLength:]

copy(buffer[offset:], slice)
}
2 changes: 1 addition & 1 deletion common/hexutil/hexutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func HexFixLength(hexStr string, bitLength int, withPadding bool) string {

paddedHexStr := fmt.Sprintf("%s%s", strings.Repeat("0", strLen), strippedHexStr)
return AddPrefix(
paddedHexStr[len(paddedHexStr)-strLen : len(paddedHexStr)],
paddedHexStr[len(paddedHexStr)-strLen:],
)
}

Expand Down
2 changes: 1 addition & 1 deletion common/stringutil/stringutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func Shorten(value string, prefixLength int) string {
}

start := value[0:prefixLength]
end := value[len(value)-prefixLength : len(value)]
end := value[len(value)-prefixLength:]
return fmt.Sprintf("%s..%s", start, end)
}

Expand Down
12 changes: 6 additions & 6 deletions common/triecodec/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func TestDecode(t *testing.T) {
{
[]uint8{0x05, 0x48, 0x19, 0x04, 0xfe},
[][]uint8{
[]uint8{0x20, 0x48, 0x19},
[]uint8{0xfe},
{0x20, 0x48, 0x19},
{0xfe},
},
},
{
Expand All @@ -34,12 +34,12 @@ func TestDecode(t *testing.T) {
nil,
nil,
[][]uint8{
[]uint8{0x1A},
[]uint8{0xFF, 0x0, 0xC, 0x4, 0xA0, 0x10, 0x2, 0xA, 0x4, 0xAA, 0x10, 0x2, 0xB, 0x4, 0xAB},
{0x1A},
{0xFF, 0x0, 0xC, 0x4, 0xA0, 0x10, 0x2, 0xA, 0x4, 0xAA, 0x10, 0x2, 0xB, 0x4, 0xAB},
},
[][]uint8{
[]uint8{0x3B},
[]uint8{0xB0},
{0x3B},
{0xB0},
},
nil,
nil,
Expand Down
12 changes: 6 additions & 6 deletions common/triecodec/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestEncode(t *testing.T) {
NewNull(),
NewNull(),
[][]uint8{
[]uint8{0x3A},
[]uint8{0xAA},
{0x3A},
{0xAA},
},
NewNull(),
NewNull(),
Expand All @@ -45,12 +45,12 @@ func TestEncode(t *testing.T) {
NewNull(),
NewNull(),
[][]uint8{
[]uint8{0x3A},
[]uint8{0xAA},
{0x3A},
{0xAA},
},
[][]uint8{
[]uint8{0x3B},
[]uint8{0xAB},
{0x3B},
{0xAB},
},
NewNull(),
NewNull(),
Expand Down
12 changes: 6 additions & 6 deletions common/triedb/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestSnapshots(t *testing.T) {
back := newTrie(codec)

values := []*triehash.TriePair{
&triehash.TriePair{K: []uint8("test"), V: []uint8("one")},
{K: []uint8("test"), V: []uint8("one")},
}

root := triehash.TrieRoot(values)
Expand Down Expand Up @@ -49,11 +49,11 @@ func TestSnapshots(t *testing.T) {

// TODO: fix trie encoder to fix tests
values := []*triehash.TriePair{
&triehash.TriePair{K: []uint8("one"), V: []uint8("testing")},
&triehash.TriePair{K: []uint8("two"), V: []uint8("testing with a much longer value here")},
&triehash.TriePair{K: []uint8("twzei"), V: []uint8("und Deutch")},
&triehash.TriePair{K: []uint8("do"), V: []uint8("do it")},
&triehash.TriePair{K: []uint8("dog"), V: []uint8("doggie")},
{K: []uint8("one"), V: []uint8("testing")},
{K: []uint8("two"), V: []uint8("testing with a much longer value here")},
{K: []uint8("twzei"), V: []uint8("und Deutch")},
{K: []uint8("do"), V: []uint8("do it")},
{K: []uint8("dog"), V: []uint8("doggie")},
//&triehash.TriePair{K: []uint8("dogge"), V: []uint8("bigger doge")},
//&triehash.TriePair{K: []uint8("dodge"), V: []uint8("coin")},
}
Expand Down
56 changes: 28 additions & 28 deletions common/triehash/unhashedtrie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,63 @@ func TestUnhashedTrie(t *testing.T) {
{
// a simple branch
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: []uint8{0x10}},
&TriePair{K: []uint8{0xba}, V: []uint8{0x11}},
{K: []uint8{0xaa}, V: []uint8{0x10}},
{K: []uint8{0xba}, V: []uint8{0x11}},
},
[]uint8{0xfe, 0x00, 0x0c, 0x10, 0x02, 0x0a, 0x04, 0x10, 0x10, 0x02, 0x0a, 0x04, 0x11},
},
{
// an extension and branch
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: []uint8{0x10}},
&TriePair{K: []uint8{0xab}, V: []uint8{0x11}},
{K: []uint8{0xaa}, V: []uint8{0x10}},
{K: []uint8{0xab}, V: []uint8{0x11}},
},
hexToU8a("0x810a2cfe000c0c0104100c010411"),
},
{
// extension and branch with value
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: []uint8{0xa0}},
&TriePair{K: []uint8{0xaa, 0xaa}, V: []uint8{0xaa}},
&TriePair{K: []uint8{0xaa, 0xbb}, V: []uint8{0xab}},
{K: []uint8{0xaa}, V: []uint8{0xa0}},
{K: []uint8{0xaa, 0xaa}, V: []uint8{0xaa}},
{K: []uint8{0xaa, 0xbb}, V: []uint8{0xab}},
},
[]uint8{0x82, 0xaa, 0x3c, 0xff, 0x00, 0x0c, 0x04, 0xa0, 0x10, 0x02, 0x0a, 0x04, 0xaa, 0x10, 0x02, 0x0b, 0x04, 0xab},
},
{
// medium extension and branch with value
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: []uint8{0xa0}},
&TriePair{K: []uint8{0xaa, 0xaa}, V: []uint8{0xaa}},
&TriePair{K: []uint8{0xaa, 0xbb}, V: []uint8{0xab}},
&TriePair{K: []uint8{0xbb}, V: []uint8{0xb0}},
{K: []uint8{0xaa}, V: []uint8{0xa0}},
{K: []uint8{0xaa, 0xaa}, V: []uint8{0xaa}},
{K: []uint8{0xaa, 0xbb}, V: []uint8{0xab}},
{K: []uint8{0xbb}, V: []uint8{0xb0}},
},
[]uint8{0xfe, 0x00, 0x0c, 0x48, 0x81, 0x0a, 0x3c, 0xff, 0x00, 0x0c, 0x04, 0xa0, 0x10, 0x02, 0x0a, 0x04, 0xaa, 0x10, 0x02, 0x0b, 0x04, 0xab, 0x10, 0x02, 0x0b, 0x04, 0xb0},
},
{
// bigger extension and branch with value
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: []uint8{0xa0}},
&TriePair{K: []uint8{0xaa, 0xaa}, V: []uint8{0xaa}},
&TriePair{K: []uint8{0xaa, 0xbb}, V: []uint8{0xab}},
&TriePair{K: []uint8{0xbb}, V: []uint8{0xb0}},
&TriePair{K: []uint8{0xbb, 0xbb}, V: []uint8{0xbb}},
&TriePair{K: []uint8{0xbb, 0xcc}, V: []uint8{0xbc}},
{K: []uint8{0xaa}, V: []uint8{0xa0}},
{K: []uint8{0xaa, 0xaa}, V: []uint8{0xaa}},
{K: []uint8{0xaa, 0xbb}, V: []uint8{0xab}},
{K: []uint8{0xbb}, V: []uint8{0xb0}},
{K: []uint8{0xbb, 0xbb}, V: []uint8{0xbb}},
{K: []uint8{0xbb, 0xcc}, V: []uint8{0xbc}},
},
[]uint8{0xfe, 0x00, 0x0c, 0x48, 0x81, 0x0a, 0x3c, 0xff, 0x00, 0x0c, 0x04, 0xa0, 0x10, 0x02, 0x0a, 0x04, 0xaa, 0x10, 0x02, 0x0b, 0x04, 0xab, 0x48, 0x81, 0x0b, 0x3c, 0xff, 0x00, 0x18, 0x04, 0xb0, 0x10, 0x02, 0x0b, 0x04, 0xbb, 0x10, 0x02, 0x0c, 0x04, 0xbc},
},
{
// a single long leaf
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: stringutil.ToUint8Slice("ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABC")},
&TriePair{K: []uint8{0xba}, V: []uint8{0x11}},
{K: []uint8{0xaa}, V: stringutil.ToUint8Slice("ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABC")},
{K: []uint8{0xba}, V: []uint8{0x11}},
},
[]uint8{0xfe, 0x00, 0x0c, 0x80, 0x0e, 0x26, 0xe9, 0x80, 0x0a, 0xc2, 0x7f, 0x56, 0x5c, 0x7e, 0x7c, 0xa7, 0x95, 0x16, 0x24, 0x78, 0x35, 0xea, 0x07, 0x6c, 0x5b, 0x62, 0x5f, 0x2d, 0x61, 0x00, 0x1a, 0x7b, 0xab, 0xad, 0xbf, 0x11, 0x10, 0x02, 0x0a, 0x04, 0x11},
},
{
// two long leaves
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: stringutil.ToUint8Slice("ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABC")},
&TriePair{K: []uint8{0xba}, V: stringutil.ToUint8Slice("ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABC")},
{K: []uint8{0xaa}, V: stringutil.ToUint8Slice("ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABC")},
{K: []uint8{0xba}, V: stringutil.ToUint8Slice("ABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABC")},
},
[]uint8{0xfe, 0x00, 0x0c, 0x80, 0x0e, 0x26, 0xe9, 0x80, 0x0a, 0xc2, 0x7f, 0x56, 0x5c, 0x7e, 0x7c, 0xa7, 0x95, 0x16, 0x24, 0x78, 0x35, 0xea, 0x07, 0x6c, 0x5b, 0x62, 0x5f, 0x2d, 0x61, 0x00, 0x1a, 0x7b, 0xab, 0xad, 0xbf, 0x11, 0x80, 0x0e, 0x26, 0xe9, 0x80, 0x0a, 0xc2, 0x7f, 0x56, 0x5c, 0x7e, 0x7c, 0xa7, 0x95, 0x16, 0x24, 0x78, 0x35, 0xea, 0x07, 0x6c, 0x5b, 0x62, 0x5f, 0x2d, 0x61, 0x00, 0x1a, 0x7b, 0xab, 0xad, 0xbf, 0x11},
},
Expand All @@ -84,7 +84,7 @@ func TestUnhashedTrie(t *testing.T) {
{
// a single tuple
[]*TriePair{
&TriePair{K: []uint8{0xaa}, V: []uint8{0xbb}},
{K: []uint8{0xaa}, V: []uint8{0xbb}},
},
[]uint8{
0x03, // leaf (0x01) with (+) key of 2 nibbles (0x02)
Expand All @@ -96,15 +96,15 @@ func TestUnhashedTrie(t *testing.T) {
{
// a single tuple (prepare for next)
[]*TriePair{
&TriePair{K: []uint8{0x48, 0x19}, V: []uint8{0xfe}},
{K: []uint8{0x48, 0x19}, V: []uint8{0xfe}},
},
[]uint8{0x05, 0x48, 0x19, 0x04, 0xfe},
},
{
// two disjointed tuple keys
[]*TriePair{
&TriePair{K: []uint8{0x48, 0x19}, V: []uint8{0xfe}},
&TriePair{K: []uint8{0x13, 0x14}, V: []uint8{0xff}},
{K: []uint8{0x48, 0x19}, V: []uint8{0xfe}},
{K: []uint8{0x13, 0x14}, V: []uint8{0xff}},
},
[]uint8{
0xfe, // branch, no value
Expand All @@ -127,15 +127,15 @@ func TestUnhashedTrie(t *testing.T) {
{
// substrate (paritial 0)
[]*TriePair{
&TriePair{
{
K: hexToU8a("0x3a617574683a00000000"),
V: hexToU8a("0x82c39b31a2b79a90f8e66e7a77fdb85a4ed5517f2ae39f6a80565e8ecae85cf5"),
},
&TriePair{
{
K: hexToU8a("0x7935e46f94f24b82716c0142e2271de9"),
V: hexToU8a("0x0087000000000000"),
},
&TriePair{
{
K: hexToU8a("0x27b3872d47181b4a2dc15f0da43e7026"),
V: hexToU8a("0xe803000000000000"),
},
Expand Down
4 changes: 2 additions & 2 deletions common/u8util/u8util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func TestConcat(t *testing.T) {
}{
{
[][]uint8{
[]uint8{0x1, 0x2, 0x3},
[]uint8{0x4, 0x5},
{0x1, 0x2, 0x3},
{0x4, 0x5},
},
[]uint8{0x1, 0x2, 0x3, 0x4, 0x5},
},
Expand Down
108 changes: 54 additions & 54 deletions vendor/github.com/go-interpreter/wagon/wasm/index.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/ipfs/go-datastore/batch.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8f443ba

Please sign in to comment.