OSDN Git Service

modify import path (#1805)
[bytom/bytom.git] / netsync / message.go
index 30e8b38..da8d0b0 100644 (file)
@@ -9,8 +9,8 @@ import (
 
        "github.com/tendermint/go-wire"
 
-       "github.com/bytom/protocol/bc"
-       "github.com/bytom/protocol/bc/types"
+       "github.com/bytom/bytom/protocol/bc"
+       "github.com/bytom/bytom/protocol/bc/types"
 )
 
 //protocol msg byte
@@ -118,7 +118,12 @@ func (m *BlockMessage) GetBlock() (*types.Block, error) {
 }
 
 func (m *BlockMessage) String() string {
-       return fmt.Sprintf("{block_size: %d}", len(m.RawBlock))
+       block, err := m.GetBlock()
+       if err != nil {
+               return "{err: wrong message}"
+       }
+       blockHash := block.Hash()
+       return fmt.Sprintf("{block_height: %d, block_hash: %s}", block.Height, blockHash.String())
 }
 
 //GetHeadersMessage is one of the bytom msg type
@@ -332,7 +337,11 @@ func (m *TransactionMessage) GetTransaction() (*types.Tx, error) {
 }
 
 func (m *TransactionMessage) String() string {
-       return fmt.Sprintf("{tx_size: %d}", len(m.RawTx))
+       tx, err := m.GetTransaction()
+       if err != nil {
+               return "{err: wrong message}"
+       }
+       return fmt.Sprintf("{tx_size: %d, tx_hash: %s}", len(m.RawTx), tx.ID.String())
 }
 
 //MineBlockMessage new mined block msg
@@ -359,7 +368,12 @@ func (m *MineBlockMessage) GetMineBlock() (*types.Block, error) {
 }
 
 func (m *MineBlockMessage) String() string {
-       return fmt.Sprintf("{block_size: %d}", len(m.RawBlock))
+       block, err := m.GetMineBlock()
+       if err != nil {
+               return "{err: wrong message}"
+       }
+       blockHash := block.Hash()
+       return fmt.Sprintf("{block_height: %d, block_hash: %s}", block.Height, blockHash.String())
 }
 
 //FilterLoadMessage tells the receiving peer to filter the transactions according to address.