The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/client/client.go

41 lines
974 B

package client
import (
"bytes"
"encoding/gob"
"harmony-benchmark/blockchain"
"harmony-benchmark/log"
)
// A client represent a entity/user which send transactions and receive responses from the harmony network
type Client struct {
pendingCrossTxs map[[32]byte]*blockchain.Transaction // map of TxId to pending cross shard txs
log log.Logger // Log utility
}
func (client *Client) TransactionMessageHandler(msgPayload []byte) {
messageType := TransactionMessageType(msgPayload[0])
switch messageType {
case CROSS_TX:
txDecoder := gob.NewDecoder(bytes.NewReader(msgPayload[1:])) // skip the CROSS_TX messge type
proofList := new([]blockchain.CrossShardTxProof)
err := txDecoder.Decode(&proofList)
if err != nil {
client.log.Error("Failed deserializing cross transaction proof list")
}
// TODO: process the proof list
}
}
// Create a new Node
func NewClient() *Client {
client := Client{}
// Logger
client.log = log.New()
return &client
}