From 9579a653c7a93f94fdf23ec8c0e87aa579c83441 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 27 May 2014 23:40:21 -0700 Subject: [PATCH] . --- merkle/README.md | 2 +- merkle/binary.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/merkle/README.md b/merkle/README.md index c15d323e5..eb5678001 100644 --- a/merkle/README.md +++ b/merkle/README.md @@ -1 +1 @@ -Immutable AVL Tree code heavily modified from https://github.com/timtadh/data-structures +An immutable, persistable, merkle-ized self balancing AVL+ tree. diff --git a/merkle/binary.go b/merkle/binary.go index 97a951024..730e6cb91 100644 --- a/merkle/binary.go +++ b/merkle/binary.go @@ -11,6 +11,7 @@ const ( TYPE_UINT32 = byte(0x07) TYPE_INT64 = byte(0x08) TYPE_UINT64 = byte(0x09) + TYPE_STRING = byte(0x10) TYPE_BYTESLICE = byte(0x11) ) @@ -29,8 +30,10 @@ func GetBinaryType(o Binary) byte { case UInt64: return TYPE_UINT64 case Int: panic("Int not supported") case UInt: panic("UInt not supported") + case String: return TYPE_STRING case ByteSlice: return TYPE_BYTESLICE + default: panic("Unsupported type") } } @@ -48,8 +51,10 @@ func LoadBinary(buf []byte, start int) (Binary, int) { case TYPE_UINT32: return LoadUInt32(buf[start+1:]), start+5 case TYPE_INT64: return LoadInt64(buf[start+1:]), start+9 case TYPE_UINT64: return LoadUInt64(buf[start+1:]), start+9 + case TYPE_STRING: return LoadString(buf, start+1) case TYPE_BYTESLICE:return LoadByteSlice(buf, start+1) + default: panic("Unsupported type") } }