Merge conflicts

This commit is contained in:
Maran
2014-04-01 14:20:55 +02:00
14 changed files with 234 additions and 182 deletions

View File

@ -36,6 +36,7 @@ func CurrencyToString(num *big.Int) string {
var (
Big1 = big.NewInt(1)
Big2 = big.NewInt(1)
Big0 = big.NewInt(0)
Big256 = big.NewInt(0xff)
)

View File

@ -131,7 +131,7 @@ func Instr(instr string) (int, []string, error) {
// Script compilation functions
// Compiles strings to machine code
func Compile(instructions ...interface{}) (script []string) {
func Assemble(instructions ...interface{}) (script []string) {
script = make([]string, len(instructions))
for i, val := range instructions {

View File

@ -57,7 +57,7 @@ func DecodeWithReader(reader *bytes.Buffer) interface{} {
switch {
case char == 0:
return nil
case char <= 0x7c:
case char <= 0x7f:
return char
case char <= 0xb7:

View File

@ -129,6 +129,11 @@ func TestEncodeDecodeBytes(t *testing.T) {
}
}
func TestEncodeZero(t *testing.T) {
b := NewValue(0).Encode()
fmt.Println(b)
}
func BenchmarkEncodeDecode(b *testing.B) {
for i := 0; i < b.N; i++ {
bytes := Encode([]interface{}{"dog", "god", "cat"})

View File

@ -149,6 +149,15 @@ func (val *Value) IsStr() bool {
return val.Type() == reflect.String
}
// Special list checking function. Something is considered
// a list if it's of type []interface{}. The list is usually
// used in conjunction with rlp decoded streams.
func (val *Value) IsList() bool {
_, ok := val.Val.([]interface{})
return ok
}
func (val *Value) IsEmpty() bool {
return val.Val == nil || ((val.IsSlice() || val.IsStr()) && val.Len() == 0)
}