clean up unused code

pull/1425/head
Minh Doan 5 years ago
parent 201a50f642
commit 89deda3ed0
  1. 12
      api/proto/node/node.go
  2. 13
      api/proto/node/node_test.go
  3. 22
      node/node_handler.go

@ -51,7 +51,6 @@ type TransactionMessageType int
// Constant of transaction message subtype
const (
Send TransactionMessageType = iota
Request
Unlock
)
@ -137,17 +136,6 @@ func ConstructTransactionListMessageAccount(transactions types.Transactions) []b
return byteBuffer.Bytes()
}
// ConstructRequestTransactionsMessage constructs serialized transactions
func ConstructRequestTransactionsMessage(transactionIds [][]byte) []byte {
byteBuffer := bytes.NewBuffer([]byte{byte(proto.Node)})
byteBuffer.WriteByte(byte(Transaction))
byteBuffer.WriteByte(byte(Request))
for _, txID := range transactionIds {
byteBuffer.Write(txID)
}
return byteBuffer.Bytes()
}
// ConstructBlocksSyncMessage constructs blocks sync message to send blocks to other nodes
func ConstructBlocksSyncMessage(blocks []*types.Block) []byte {
byteBuffer := bytes.NewBuffer([]byte{byte(proto.Node)})

@ -53,19 +53,6 @@ func TestConstructTransactionListMessageAccount(t *testing.T) {
}
}
func TestConstructRequestTransactionsMessage(t *testing.T) {
txIDs := [][]byte{
{1, 2},
{3, 4},
}
buf := ConstructRequestTransactionsMessage(txIDs)
if len(buf) == 0 {
t.Error("Failed to contruct request transaction message")
}
}
func TestConstructBlocksSyncMessage(t *testing.T) {
db := ethdb.NewMemDatabase()

@ -248,28 +248,6 @@ func (node *Node) transactionMessageHandler(msgPayload []byte) {
Msg("Failed to deserialize transaction list")
}
node.addPendingTransactions(txs)
case proto_node.Request:
reader := bytes.NewBuffer(msgPayload[1:])
txIDs := make(map[[32]byte]bool)
buf := make([]byte, 32) // 32 byte hash Id
for {
_, err := reader.Read(buf)
if err != nil {
break
}
var txID [32]byte
copy(txID[:], buf)
txIDs[txID] = true
}
var txToReturn []*types.Transaction
for _, tx := range node.pendingTransactions {
if txIDs[tx.Hash()] {
txToReturn = append(txToReturn, tx)
}
}
}
}

Loading…
Cancel
Save