|
|
@ -28,6 +28,10 @@ func NumToVarInt(x int) string { |
|
|
|
func RlpEncode(object interface{}) string { |
|
|
|
func RlpEncode(object interface{}) string { |
|
|
|
if str, ok := object.(string); ok { |
|
|
|
if str, ok := object.(string); ok { |
|
|
|
return "\x00" + NumToVarInt(len(str)) + str |
|
|
|
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 { |
|
|
|
} else if slice, ok := object.([]interface{}); ok { |
|
|
|
var buffer bytes.Buffer |
|
|
|
var buffer bytes.Buffer |
|
|
|
for _, val := range slice { |
|
|
|
for _, val := range slice { |
|
|
@ -53,7 +57,7 @@ func RlpEncode(object interface{}) string { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type RlpSerializer interface { |
|
|
|
type RlpSerializer interface { |
|
|
|
MarshalRls() []byte |
|
|
|
MarshalRlp() []byte |
|
|
|
UnmarshalRls([]byte) |
|
|
|
UnmarshalRlp([]byte) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|