good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
a42be3b7
Commit
a42be3b7
authored
May 8, 2018
by
kiel barry
Committed by
Felix Lange
May 8, 2018
Browse files
Options
Downloads
Patches
Plain Diff
rlp: fix some golint warnings (#16659)
parent
6cf0ab38
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rlp/decode.go
+18
-25
18 additions, 25 deletions
rlp/decode.go
rlp/encode.go
+9
-12
9 additions, 12 deletions
rlp/encode.go
with
27 additions
and
37 deletions
rlp/decode.go
+
18
−
25
View file @
a42be3b7
...
...
@@ -29,6 +29,23 @@ import (
)
var
(
// EOL is returned when the end of the current list
// has been reached during streaming.
EOL
=
errors
.
New
(
"rlp: end of list"
)
// Actual Errors
ErrExpectedString
=
errors
.
New
(
"rlp: expected String or Byte"
)
ErrExpectedList
=
errors
.
New
(
"rlp: expected List"
)
ErrCanonInt
=
errors
.
New
(
"rlp: non-canonical integer format"
)
ErrCanonSize
=
errors
.
New
(
"rlp: non-canonical size information"
)
ErrElemTooLarge
=
errors
.
New
(
"rlp: element is larger than containing list"
)
ErrValueTooLarge
=
errors
.
New
(
"rlp: value size exceeds available input length"
)
ErrMoreThanOneValue
=
errors
.
New
(
"rlp: input contains more than one value"
)
// internal errors
errNotInList
=
errors
.
New
(
"rlp: call of ListEnd outside of any list"
)
errNotAtEOL
=
errors
.
New
(
"rlp: call of ListEnd not positioned at EOL"
)
errUintOverflow
=
errors
.
New
(
"rlp: uint overflow"
)
errNoPointer
=
errors
.
New
(
"rlp: interface given to Decode must be a pointer"
)
errDecodeIntoNil
=
errors
.
New
(
"rlp: pointer given to Decode must not be nil"
)
)
...
...
@@ -274,9 +291,8 @@ func makeListDecoder(typ reflect.Type, tag tags) (decoder, error) {
if
etype
.
Kind
()
==
reflect
.
Uint8
&&
!
reflect
.
PtrTo
(
etype
)
.
Implements
(
decoderInterface
)
{
if
typ
.
Kind
()
==
reflect
.
Array
{
return
decodeByteArray
,
nil
}
else
{
return
decodeByteSlice
,
nil
}
return
decodeByteSlice
,
nil
}
etypeinfo
,
err
:=
cachedTypeInfo1
(
etype
,
tags
{})
if
err
!=
nil
{
...
...
@@ -555,29 +571,6 @@ func (k Kind) String() string {
}
}
var
(
// EOL is returned when the end of the current list
// has been reached during streaming.
EOL
=
errors
.
New
(
"rlp: end of list"
)
// Actual Errors
ErrExpectedString
=
errors
.
New
(
"rlp: expected String or Byte"
)
ErrExpectedList
=
errors
.
New
(
"rlp: expected List"
)
ErrCanonInt
=
errors
.
New
(
"rlp: non-canonical integer format"
)
ErrCanonSize
=
errors
.
New
(
"rlp: non-canonical size information"
)
ErrElemTooLarge
=
errors
.
New
(
"rlp: element is larger than containing list"
)
ErrValueTooLarge
=
errors
.
New
(
"rlp: value size exceeds available input length"
)
// This error is reported by DecodeBytes if the slice contains
// additional data after the first RLP value.
ErrMoreThanOneValue
=
errors
.
New
(
"rlp: input contains more than one value"
)
// internal errors
errNotInList
=
errors
.
New
(
"rlp: call of ListEnd outside of any list"
)
errNotAtEOL
=
errors
.
New
(
"rlp: call of ListEnd not positioned at EOL"
)
errUintOverflow
=
errors
.
New
(
"rlp: uint overflow"
)
)
// ByteReader must be implemented by any input reader for a Stream. It
// is implemented by e.g. bufio.Reader and bytes.Reader.
type
ByteReader
interface
{
...
...
This diff is collapsed.
Click to expand it.
rlp/encode.go
+
9
−
12
View file @
a42be3b7
...
...
@@ -92,7 +92,7 @@ func Encode(w io.Writer, val interface{}) error {
return
eb
.
toWriter
(
w
)
}
// EncodeBytes returns the RLP encoding of val.
// Encode
To
Bytes returns the RLP encoding of val.
// Please see the documentation of Encode for the encoding rules.
func
EncodeToBytes
(
val
interface
{})
([]
byte
,
error
)
{
eb
:=
encbufPool
.
Get
()
.
(
*
encbuf
)
...
...
@@ -104,7 +104,7 @@ func EncodeToBytes(val interface{}) ([]byte, error) {
return
eb
.
toBytes
(),
nil
}
// EncodeReader returns a reader from which the RLP encoding of val
// Encode
To
Reader returns a reader from which the RLP encoding of val
// can be read. The returned size is the total size of the encoded
// data.
//
...
...
@@ -151,12 +151,11 @@ func puthead(buf []byte, smalltag, largetag byte, size uint64) int {
if
size
<
56
{
buf
[
0
]
=
smalltag
+
byte
(
size
)
return
1
}
else
{
}
sizesize
:=
putint
(
buf
[
1
:
],
size
)
buf
[
0
]
=
largetag
+
byte
(
sizesize
)
return
sizesize
+
1
}
}
// encbufs are pooled.
var
encbufPool
=
sync
.
Pool
{
...
...
@@ -218,7 +217,7 @@ func (w *encbuf) list() *listhead {
func
(
w
*
encbuf
)
listEnd
(
lh
*
listhead
)
{
lh
.
size
=
w
.
size
()
-
lh
.
offset
-
lh
.
size
if
lh
.
size
<
56
{
w
.
lhsize
+=
1
// length encoded into kind tag
w
.
lhsize
++
// length encoded into kind tag
}
else
{
w
.
lhsize
+=
1
+
intsize
(
uint64
(
lh
.
size
))
}
...
...
@@ -322,10 +321,9 @@ func (r *encReader) next() []byte {
p
:=
r
.
buf
.
str
[
r
.
strpos
:
head
.
offset
]
r
.
strpos
+=
sizebefore
return
p
}
else
{
}
r
.
lhpos
++
return
head
.
encode
(
r
.
buf
.
sizebuf
)
}
case
r
.
strpos
<
len
(
r
.
buf
.
str
)
:
// String data at the end, after all list headers.
...
...
@@ -576,9 +574,8 @@ func makePtrWriter(typ reflect.Type) (writer, error) {
writer
:=
func
(
val
reflect
.
Value
,
w
*
encbuf
)
error
{
if
val
.
IsNil
()
{
return
nilfunc
(
w
)
}
else
{
return
etypeinfo
.
writer
(
val
.
Elem
(),
w
)
}
return
etypeinfo
.
writer
(
val
.
Elem
(),
w
)
}
return
writer
,
err
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment