aboutsummaryrefslogtreecommitdiffstats
path: root/serialization.go
diff options
context:
space:
mode:
authorobscuren <obscuren@obscura.com>2014-01-01 10:07:04 +0800
committerobscuren <obscuren@obscura.com>2014-01-01 10:07:04 +0800
commit79eaa6f2bae8c8354807a9b32b889295b0de4b6a (patch)
treec45fc7e9a96e386e6d4bdcbfc04d230a5c5a35eb /serialization.go
parent34d62c380ef6327c170639af6221a82610efa25c (diff)
downloaddexon-79eaa6f2bae8c8354807a9b32b889295b0de4b6a.tar
dexon-79eaa6f2bae8c8354807a9b32b889295b0de4b6a.tar.gz
dexon-79eaa6f2bae8c8354807a9b32b889295b0de4b6a.tar.bz2
dexon-79eaa6f2bae8c8354807a9b32b889295b0de4b6a.tar.lz
dexon-79eaa6f2bae8c8354807a9b32b889295b0de4b6a.tar.xz
dexon-79eaa6f2bae8c8354807a9b32b889295b0de4b6a.tar.zst
dexon-79eaa6f2bae8c8354807a9b32b889295b0de4b6a.zip
Removed old serialization
Diffstat (limited to 'serialization.go')
-rw-r--r--serialization.go63
1 files changed, 0 insertions, 63 deletions
diff --git a/serialization.go b/serialization.go
deleted file mode 100644
index 5a92a434f..000000000
--- a/serialization.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package main
-
-import (
- "math"
- "bytes"
-)
-
-func ToBinary(x int, bytes int) string {
- if bytes == 0 {
- return ""
- } else {
- return ToBinary(int(x / 256), bytes - 1) + string(x % 256)
- }
-}
-
-func NumToVarInt(x int) string {
- if x < 253 {
- return string(x)
- } else if x < int(math.Pow(2,16)) {
- return string(253) + ToBinary(x, 2)
- } else if x < int(math.Pow(2,32)) {
- return string(253) + ToBinary(x, 4)
- } else {
- return string(253) + ToBinary(x, 8)
- }
-}
-
-func RlpEncode(object interface{}) string {
- if str, ok := object.(string); ok {
- return "\x00" + NumToVarInt(len(str)) + str
- } else if num, ok := object.(uint32); ok {
- return RlpEncode(Uitoa(num))
- } else if byt, ok := object.([]byte); ok {
- return RlpEncode(string(byt))
- } else if slice, ok := object.([]interface{}); ok {
- var buffer bytes.Buffer
- for _, val := range slice {
- if v, ok := val.(string); ok {
- buffer.WriteString(RlpEncode(v))
- } else {
- buffer.WriteString(RlpEncode(val))
- }
- }
-
- return "\x01" + RlpEncode(len(buffer.String())) + buffer.String()
- } else if slice, ok := object.([]string); ok {
-
- // FIXME this isn't dry. Fix this
- var buffer bytes.Buffer
- for _, val := range slice {
- buffer.WriteString(RlpEncode(val))
- }
- return "\x01" + RlpEncode(len(buffer.String())) + buffer.String()
- }
-
- return ""
-}
-
-type RlpSerializer interface {
- MarshalRlp() []byte
- UnmarshalRlp([]byte)
-}
-