OSDN Git Service

change BTMAssetID to human readable (#1216)
authorDerek <shanhu5739@gmail.com>
Fri, 3 Aug 2018 09:28:09 +0000 (17:28 +0800)
committerPaladz <yzhu101@uottawa.ca>
Fri, 3 Aug 2018 09:28:09 +0000 (17:28 +0800)
* fix the coinbase generate bug (#1136)

* change BTMAssetID to human readable

* fix txfedd syntax

* change BTMAssetID to human readable again

* revert fix txfedd syntax

* adjust import

consensus/general.go
protocol/bc/asset.go

index ba8814d..3c5453d 100644 (file)
@@ -1,6 +1,7 @@
 package consensus
 
 import (
+       "encoding/binary"
        "strings"
 
        "github.com/bytom/protocol/bc"
@@ -39,10 +40,10 @@ const (
 
 // BTMAssetID is BTM's asset id, the soul asset of Bytom
 var BTMAssetID = &bc.AssetID{
-       V0: uint64(18446744073709551615),
-       V1: uint64(18446744073709551615),
-       V2: uint64(18446744073709551615),
-       V3: uint64(18446744073709551615),
+       V0: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
+       V1: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
+       V2: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
+       V3: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
 }
 
 // InitialSeed is SHA3-256 of Byte[0^32]
index a842445..880df75 100644 (file)
@@ -1,6 +1,7 @@
 package bc
 
 import (
+       "encoding/binary"
        "errors"
        "io"
 
@@ -10,7 +11,12 @@ import (
 
 // NewAssetID convert byte array to aseet id
 func NewAssetID(b [32]byte) (a AssetID) {
-       return AssetID(NewHash(b))
+       return AssetID{
+               V0: binary.BigEndian.Uint64(b[0:8]),
+               V1: binary.BigEndian.Uint64(b[8:16]),
+               V2: binary.BigEndian.Uint64(b[16:24]),
+               V3: binary.BigEndian.Uint64(b[24:32]),
+       }
 }
 
 // Byte32 return the byte array representation