Changed Tx serialization to return bytes instead of a string

This commit is contained in:
obscuren
2013-12-27 21:23:40 +01:00
parent 8301d154ae
commit dca9ee79b3
2 changed files with 13 additions and 11 deletions

View File

@@ -28,6 +28,10 @@ func NumToVarInt(x int) string {
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 {
@@ -53,7 +57,7 @@ func RlpEncode(object interface{}) string {
}
type RlpSerializer interface {
MarshalRls() []byte
UnmarshalRls([]byte)
MarshalRlp() []byte
UnmarshalRlp([]byte)
}