Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
d5d2efba
Commit
d5d2efba
authored
Dec 27, 2013
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP new rlp implementation
parent
b40013ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
rlp.go
rlp.go
+52
-0
No files found.
rlp.go
0 → 100644
View file @
d5d2efba
package
main
import
(
_
"fmt"
"bytes"
"math"
)
func
EncodeSlice
(
slice
[]
interface
{})
[]
byte
{
var
buff
bytes
.
Buffer
for
_
,
val
:=
range
slice
{
switch
t
:=
val
.
(
type
)
{
case
[]
interface
{},
[]
string
:
buff
.
Write
(
Encode
(
t
))
}
}
return
buff
.
Bytes
()
}
func
Encode
(
object
interface
{})
[]
byte
{
var
buff
bytes
.
Buffer
switch
t
:=
object
.
(
type
)
{
case
string
:
if
len
(
t
)
<
56
{
buff
.
WriteString
(
string
(
len
(
t
)
+
64
)
+
t
)
}
else
{
}
case
uint32
,
uint64
:
var
num
uint64
if
_num
,
ok
:=
t
.
(
uint64
);
ok
{
num
=
_num
}
else
if
_num
,
ok
:=
t
.
(
uint32
);
ok
{
num
=
uint64
(
_num
)
}
if
num
>=
0
&&
num
<
24
{
buff
.
WriteString
(
string
(
num
))
}
else
if
num
<=
uint64
(
math
.
Pow
(
2
,
256
))
{
}
case
[]
byte
:
// Cast the byte slice to a string
buff
.
Write
(
Encode
(
string
(
t
)))
case
[]
interface
{}
:
buff
.
Write
(
EncodeSlice
(
t
))
}
return
buff
.
Bytes
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment