OSDN Git Service

add spv message struct (#1251)
authormuscle_boy <shenao.78@163.com>
Mon, 13 Aug 2018 11:57:19 +0000 (19:57 +0800)
committerPaladz <yzhu101@uottawa.ca>
Mon, 13 Aug 2018 11:57:19 +0000 (19:57 +0800)
* the transaction output amout prohibit set zero

* add network access control api

* format import code style

* refactor

* code refactor

* bug fix

* the struct node_info add json field

* estimate gas support multi-sign

* add testcase of estimate gas

* add testcase

* bug fix

* add test case

* test case refactor

* list-tx,list-address,list-utxo support partition

* list-addresses list-tx list-utxo support pagging

* refactor pagging

* fix save asset

* fix save external assets

* remove blank

* remove useless context

* remove redudant web address config

* fix bug

* remove useless ctx

* add spv message struct

* remove redundant

* refactor message struct

* refactor message struct

netsync/message.go

index b413651..420c634 100644 (file)
@@ -26,6 +26,10 @@ const (
        StatusResponseByte  = byte(0x21)
        NewTransactionByte  = byte(0x30)
        NewMineBlockByte    = byte(0x40)
+       FilterLoadByte      = byte(0x50)
+       FilterClearByte     = byte(0x51)
+       MerkleRequestByte   = byte(0x60)
+       MerkleResponseByte  = byte(0x61) 
 
        maxBlockchainResponseSize = 22020096 + 2
 )
@@ -45,6 +49,10 @@ var _ = wire.RegisterInterface(
        wire.ConcreteType{&StatusResponseMessage{}, StatusResponseByte},
        wire.ConcreteType{&TransactionMessage{}, NewTransactionByte},
        wire.ConcreteType{&MineBlockMessage{}, NewMineBlockByte},
+       wire.ConcreteType{&FilterLoadMessage{}, FilterLoadByte},
+       wire.ConcreteType{&FilterClearMessage{}, FilterClearByte},
+       wire.ConcreteType{&GetMerkleBlockMessage{}, MerkleRequestByte},
+       wire.ConcreteType{&MerkleBlockMessage{}, MerkleResponseByte},
 )
 
 //DecodeMessage decode msg
@@ -339,3 +347,29 @@ func (m *MineBlockMessage) GetMineBlock() (*types.Block, error) {
 func (m *MineBlockMessage) String() string {
        return fmt.Sprintf("NewMineBlockMessage{Size: %d}", len(m.RawBlock))
 }
+
+//FilterLoadMessage tells the receiving peer to filter the transactions according to address.
+type FilterLoadMessage struct {
+       Addresses [][]byte
+}
+
+//FilterClearMessage tells the receiving peer to remove a previously-set filter. 
+type FilterClearMessage struct {}
+
+//GetMerkleBlockMessage request merkle blocks from remote peers by height/hash
+type GetMerkleBlockMessage struct {
+       Height  uint64
+       RawHash [32]byte 
+}
+
+//MerkleBlockMessage return the merkle block to client
+type MerkleBlockMessage struct {
+       RawBlockHeader []byte
+       TransactionCount uint64
+       TxHashes [][32]byte
+       TxFlags []byte
+       RawTxDatas [][]byte
+       StatusHashes [][32]byte
+       StatusFlags []byte
+       RawTxStatuses [][]byte
+}
\ No newline at end of file