瀏覽代碼

common: drop accessors for Value.Val

I don't see why we would need two different accessors for a public field.
Felix Lange 10 年之前
父節點
當前提交
c161d73d42
共有 4 個文件被更改,包括 3 次插入11 次删除
  1. 1 1
      common/rlp.go
  2. 0 8
      common/value.go
  3. 1 1
      common/value_test.go
  4. 1 1
      ethdb/memory_database.go

+ 1 - 1
common/rlp.go

@@ -112,7 +112,7 @@ func Encode(object interface{}) []byte {
 	if object != nil {
 		switch t := object.(type) {
 		case *Value:
-			buff.Write(Encode(t.Raw()))
+			buff.Write(Encode(t.Val))
 		case RlpEncodable:
 			buff.Write(Encode(t.RlpData()))
 		// Code dup :-/

+ 0 - 8
common/value.go

@@ -57,14 +57,6 @@ func (val *Value) Len() int {
 	return len(val.Bytes())
 }
 
-func (val *Value) Raw() interface{} {
-	return val.Val
-}
-
-func (val *Value) Interface() interface{} {
-	return val.Val
-}
-
 func (val *Value) Uint() uint64 {
 	if Val, ok := val.Val.(uint8); ok {
 		return uint64(Val)

+ 1 - 1
common/value_test.go

@@ -35,7 +35,7 @@ func (s *ValueSuite) TestValueTypes(c *checker.C) {
 
 	c.Assert(str.Str(), checker.Equals, strExp)
 	c.Assert(num.Uint(), checker.Equals, numExp)
-	c.Assert(NewValue(inter.Interface()).Cmp(NewValue(interExp)), checker.Equals, true)
+	c.Assert(NewValue(inter.Val).Cmp(NewValue(interExp)), checker.Equals, true)
 	c.Assert(byt.Bytes(), checker.DeepEquals, bytExp)
 	c.Assert(bigInt.BigInt(), checker.DeepEquals, bigExp)
 }

+ 1 - 1
ethdb/memory_database.go

@@ -49,7 +49,7 @@ func (db *MemDatabase) Print() {
 	for key, val := range db.db {
 		fmt.Printf("%x(%d): ", key, len(key))
 		node := common.NewValueFromBytes(val)
-		fmt.Printf("%q\n", node.Interface())
+		fmt.Printf("%q\n", node.Val)
 	}
 }