Documentation ¶
Index ¶
- Constants
- Variables
- type JoinData
- type JoinResp
- type Leader
- type Node
- func (node *Node) CheckTxId(txId string) (exist bool)
- func (node *Node) CreateChannel(balance int) (err error)
- func (node *Node) JoinChannel(balance int) (isLeader bool, err error)
- func (node *Node) LeaderID() (leaderID string)
- func (node *Node) Phase() (phase Phase)
- func (node *Node) PrintStatus()
- func (node *Node) SendExitRequest() (err error)
- func (node *Node) SendJoinRequest()
- func (node *Node) SendPing(receiverId string) (err error)
- func (node *Node) SendTradePhaseNotify()
- func (node *Node) SendTxRequest(amount int, receiverId string) (txId string, err error)
- func (node *Node) SetPhase(phase Phase)
- type NodeEntity
- type Phase
- type State
- type TradeMsg
- type Tx
Constants ¶
View Source
const TradeTimeout int64 = 30
TradeTimeout of the transaction phase (in seconds)
Variables ¶
View Source
var TradeMsgChan tradeMsgChan
TradeMsgChan 交易信息通道
Functions ¶
This section is empty.
Types ¶
type JoinData ¶
type JoinData struct { KeyType cmCrypto.KeyType PubKey []byte // user public key Seed string // user p2p net seed }
JoinData join channel data
type JoinResp ¶
JoinResp join channel resp
type Leader ¶
type Leader struct {
// contains filtered or unexported fields
}
Leader off chain epoch leader
type Node ¶
type Node struct { Id string // node id ChannelName string // channel net name NodeName string // node name TODO: 有没有用,待最终确认 NetAddr string // node network address Balance int // node balance Joined bool // node joined channel Exited bool // node exited channel JoinFailReason string // node exited channel Once sync.Once // once send trade phase notify NodeLibp2pNet *libp2pnet.LibP2pNet //node network sync.RWMutex // contains filtered or unexported fields }
Node off chain node
func CreateNode ¶
CreateNode create channel node
func (*Node) CheckTxId ¶
CheckTxId check tx id
func (*Node) CreateChannel ¶
CreateChannel create channel
func (*Node) JoinChannel ¶
JoinChannel join channel
func (*Node) SendExitRequest ¶
SendExitRequest send exit request
func (*Node) SendJoinRequest ¶
func (node *Node) SendJoinRequest()
SendJoinRequest send join request
func (*Node) SendPing ¶
SendPing send heart beat ping
func (*Node) SendTradePhaseNotify ¶
func (node *Node) SendTradePhaseNotify()
SendTradePhaseNotify Notifies all nodes to enter the transaction phase (leader)
func (*Node) SendTxRequest ¶
SendTxRequest the transaction is constructed, signed and sent to the receiver (sender)
type NodeEntity ¶
type NodeEntity struct { PubKey *crypto.PubKeyEntity Seed string }
NodeEntity node entity
type Phase ¶
type Phase int
Phase phase
const ( // InitPhase init phase, no operation can be performed InitPhase Phase = iota // TradePhase Trades can be made at this stage TradePhase // ConsensusPhase The trading phase timeout triggers entering the consensus phase ConsensusPhase // ArbitrationPhase Unable to reach a consensus, all nodes enter the challenge phase ArbitrationPhase // ExitPhase exit phase ExitPhase )
type State ¶
type State struct { Epoch int LeaderId string BalanceSet map[string]int WithdrawSet map[string]int // node exit set SigSet map[string][]byte }
State state
type Tx ¶
type Tx struct { Id string // tx id Epoch int // epoch of tx Sender string // sender id Receiver string // receiver id Amount int // tx amount LeaderSig []byte // leader sig SenderSig []byte // sender sig ReceiverSig []byte // receiver sig StartTime time.Time // tx start time Duration time.Duration // tx duration time }
Tx transaction struct
Click to show internal directories.
Click to hide internal directories.