Documentation ¶
Index ¶
- Variables
- func GetStartMode() int
- func InitObserver() error
- type BlockView
- type BraftNode
- func (node *BraftNode) AddProposal(p *distribution.Proposal) bool
- func (node *BraftNode) AddSideTx(txID string, chain string) error
- func (node *BraftNode) AddWatchedTx(tx *pb.WatchedTxInfo) error
- func (node *BraftNode) ChainRegister(regInfo *ChainRegInfo)
- func (node *BraftNode) DeleteProposal(proposalID string) bool
- func (bn *BraftNode) Echo(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error)
- func (node *BraftNode) ExecuteProposal(proposalID string)
- func (node *BraftNode) FakeCommitBlock(blockPack *pb.BlockPack)
- func (node *BraftNode) GetAllProposal() []*distribution.DistributionInfo
- func (node *BraftNode) GetBlockByID(id string) (*BlockView, error)
- func (node *BraftNode) GetBlockBytHeight(height int64) *BlockView
- func (node *BraftNode) GetBlockCurrent() *BlockView
- func (node *BraftNode) GetBlockHeight() int64
- func (node *BraftNode) GetBlockInfo(height int64) *pb.BlockInfo
- func (node *BraftNode) GetBlocks(start, end int64) []*BlockView
- func (node *BraftNode) GetBurnFeeRate() int64
- func (node *BraftNode) GetChainRegisterID(newChain string, targetChain string) *ChainRegID
- func (bn *BraftNode) GetClusterNodes(ctx context.Context, msg *pb.Void) (*pb.NodeList, error)
- func (node *BraftNode) GetMinBCHMintAmount() int64
- func (node *BraftNode) GetMinBTCMintAmount() int64
- func (node *BraftNode) GetMinBurnAmount() int64
- func (node *BraftNode) GetMintFeeRate() int64
- func (bn *BraftNode) GetNodeRuntimeInfo(ctx context.Context, msg *pb.Void) (*pb.NodeRuntimeInfo, error)
- func (node *BraftNode) GetNodeTerm() int64
- func (node *BraftNode) GetNodes() []NodeView
- func (node *BraftNode) GetProposal(proposalID string) *distribution.DistributionInfo
- func (node *BraftNode) GetTokenRegisterID(chain string, contractAddr string) *TokenRegID
- func (node *BraftNode) GetTransacitonByTxID(txID string) *TxView
- func (node *BraftNode) GetTxBySidechainTxId(scTxId string) *primitives.TxQueryResult
- func (bn *BraftNode) IsCommited(ctx context.Context, msg *crypto.Digest256) (*pb.IsCommitedResponse, error)
- func (bn *BraftNode) LeaveCluster()
- func (node *BraftNode) ManualMint(mintInfo *ManualMintRequest)
- func (bn *BraftNode) NotifyCommitMsg(ctx context.Context, msg *pb.CommitMsg) (*pb.Void, error)
- func (bn *BraftNode) NotifyHeatbeat(ct context.Context, msg *pb.HeatbeatMsg) (*pb.Void, error)
- func (bn *BraftNode) NotifyInitMsg(ctx context.Context, msg *pb.InitMsg) (*pb.Void, error)
- func (bn *BraftNode) NotifyJoin(ctx context.Context, msg *pb.JoinRequest) (*pb.Void, error)
- func (bn *BraftNode) NotifyJoinCheckSynced(ctx context.Context, msg *pb.JoinRequest) (*pb.JoinResponse, error)
- func (bn *BraftNode) NotifyLeave(ctx context.Context, msg *pb.LeaveRequest) (*pb.Void, error)
- func (bn *BraftNode) NotifyPrepareMsg(ctx context.Context, msg *pb.PrepareMsg) (*pb.Void, error)
- func (bn *BraftNode) NotifySignTx(ctx context.Context, msg *pb.SignTxRequest) (*pb.Void, error)
- func (bn *BraftNode) NotifySignedResult(ctx context.Context, msg *pb.SignedResult) (*pb.Void, error)
- func (bn *BraftNode) NotifyStrongAccuse(ctx context.Context, msg *pb.StrongAccuse) (*pb.Void, error)
- func (bn *BraftNode) NotifyTxs(ctx context.Context, msg *pb.Transactions) (*pb.Void, error)
- func (bn *BraftNode) NotifyVote(ctx context.Context, msg *pb.Vote) (*pb.Void, error)
- func (bn *BraftNode) NotifyWeakAccuse(ctx context.Context, msg *pb.WeakAccuse) (*pb.Void, error)
- func (bn *BraftNode) Run()
- func (node *BraftNode) SaveSignedResult(msg *pb.SignedResult)
- func (bn *BraftNode) Stop()
- func (bn *BraftNode) SyncUp(ctx context.Context, msg *pb.SyncUpRequest) (*pb.SyncUpResponse, error)
- func (node *BraftNode) TokenRegister(regInfo *TokenRegInfo)
- func (bn *BraftNode) WatchSyncUp(ctx context.Context, msg *pb.SyncUpRequest) (*pb.SyncUpResponse, error)
- type ChainRegID
- type ChainRegInfo
- type CheckMode
- type JoinMsg
- type Leader
- func (ld *Leader) AddVote(vote *pb.Vote)
- func (ld *Leader) OnJoinCancel()
- func (ld *Leader) OnNewNodeJoin(host string)
- func (ld *Leader) OnNodeJoinedDone(vote *pb.Vote)
- func (ld *Leader) OnNodeLeave(nodeId int32)
- func (ld *Leader) OnNodeLeaveDone()
- func (ld *Leader) Run(ctx context.Context)
- func (ld *Leader) SetFeeRate(mintFeeRate int64, burnFeeRate int64)
- type ManualMintRequest
- type NodeView
- type SignedResultCache
- type SyncDaemon
- type TokenRegID
- type TokenRegInfo
- type TxView
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type BlockView ¶
type BlockView struct { Height int64 `json:"height"` ID string `json:"id"` PreID string `json:"pre_id"` TxCnt int `json:"tx_cnt"` Txs []*TxView `json:"txs"` Time int64 `json:"time"` //unix 时间戳 Size int `json:"size"` //块大小 CreatedUsed int64 `json:"created_used"` //块被创建花费的时间 Miner string `json:"miner"` //产生块的服务器 }
blcokView for api
type BraftNode ¶
type BraftNode struct {
// contains filtered or unexported fields
}
BraftNode node主结构, 也是程序启动的入口
func NewBraftNode ¶
NewBraftNode 生成&启动一个node对象并返回
func RunNew ¶
func RunNew(nodeInfo cluster.NodeInfo, multiSigInfos []cluster.MultiSigInfo) (*grpc.Server, *BraftNode)
RunNew 启动server
func (*BraftNode) AddProposal ¶ added in v1.1.0
func (node *BraftNode) AddProposal(p *distribution.Proposal) bool
AddProposal 新增一个分配提案
func (*BraftNode) AddWatchedTx ¶
func (node *BraftNode) AddWatchedTx(tx *pb.WatchedTxInfo) error
AddWatchedTx 手动添加交易
func (*BraftNode) ChainRegister ¶
func (node *BraftNode) ChainRegister(regInfo *ChainRegInfo)
ChainRegister 新链注册
func (*BraftNode) DeleteProposal ¶ added in v1.1.0
DeleteProposal 删除指定的提案,注意只有处于new或者执行失败的情况下,提案才会被删除
func (*BraftNode) Echo ¶
func (bn *BraftNode) Echo(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error)
Echo just for test echo
func (*BraftNode) ExecuteProposal ¶ added in v1.1.0
ExecuteProposal 执行指定的提案
func (*BraftNode) FakeCommitBlock ¶
FakeCommitBlock 人工写区块,仅做测试用
func (*BraftNode) GetAllProposal ¶ added in v1.1.0
func (node *BraftNode) GetAllProposal() []*distribution.DistributionInfo
GetAllProposal 获取所有的提案
func (*BraftNode) GetBlockBytHeight ¶
根据高度获取block
func (*BraftNode) GetBlockHeight ¶
func (*BraftNode) GetBurnFeeRate ¶
GetBurnFeeRate 返回熔币的手续费
func (*BraftNode) GetChainRegisterID ¶
func (node *BraftNode) GetChainRegisterID(newChain string, targetChain string) *ChainRegID
GetChainRegisterID 查询链注册结果,如果成功,返回chainID,否则返回0
func (*BraftNode) GetClusterNodes ¶
GetClusterNodes 处理获取集群节点列表的请求
func (*BraftNode) GetMinBCHMintAmount ¶
GetMinBCHMintAmount 返回BCH链铸币的最小金额
func (*BraftNode) GetMinBTCMintAmount ¶
GetMinBTCMintAmount 返回BCH链铸币的最小金额
func (*BraftNode) GetMinBurnAmount ¶
GetMinBurnAmount 返回熔币的最小金额
func (*BraftNode) GetMintFeeRate ¶
GetMintFeeRate 返回铸币的手续费
func (*BraftNode) GetNodeRuntimeInfo ¶
func (*BraftNode) GetNodeTerm ¶
func (*BraftNode) GetProposal ¶ added in v1.1.0
func (node *BraftNode) GetProposal(proposalID string) *distribution.DistributionInfo
GetProposal 获取指定的提案
func (*BraftNode) GetTokenRegisterID ¶
func (node *BraftNode) GetTokenRegisterID(chain string, contractAddr string) *TokenRegID
GetTokenRegisterID 查询token注册结果,如果成功,则返回tokenID, 否则返回0
func (*BraftNode) GetTransacitonByTxID ¶
根据tx_id查询 transaction 不同链的tx_id用相同的pre存储
func (*BraftNode) GetTxBySidechainTxId ¶
func (node *BraftNode) GetTxBySidechainTxId(scTxId string) *primitives.TxQueryResult
func (*BraftNode) IsCommited ¶
func (*BraftNode) LeaveCluster ¶
func (bn *BraftNode) LeaveCluster()
LeaveCluster 先广播LeaveRequest,然后再停止运行
func (*BraftNode) ManualMint ¶
func (node *BraftNode) ManualMint(mintInfo *ManualMintRequest)
ManualMint 手工铸币
func (*BraftNode) NotifyCommitMsg ¶
NotifyCommitMsg 处理收到的commitmsg请求,新区快达成共识
func (*BraftNode) NotifyHeatbeat ¶ added in v1.1.1
NotifyHeatbeat 处理心跳消息
func (*BraftNode) NotifyInitMsg ¶
NotifyInitMsg 处理收到的initmsg请求, 新区块开始共识
func (*BraftNode) NotifyJoin ¶
NotifyJoin 处理新节点加入的请求
func (*BraftNode) NotifyJoinCheckSynced ¶
func (bn *BraftNode) NotifyJoinCheckSynced(ctx context.Context, msg *pb.JoinRequest) (*pb.JoinResponse, error)
join check是否同步完成
func (*BraftNode) NotifyLeave ¶
NotifyLeave 处理节点的退出请求
func (*BraftNode) NotifyPrepareMsg ¶
NotifyPrepareMsg 处理收到的preparemsg请求,新区块准备好了共识
func (*BraftNode) NotifySignTx ¶
NotifySignTx 处理收到的加签请求
func (*BraftNode) NotifySignedResult ¶
func (*BraftNode) NotifyStrongAccuse ¶
func (bn *BraftNode) NotifyStrongAccuse(ctx context.Context, msg *pb.StrongAccuse) (*pb.Void, error)
NotifyStrongAccuse 处理收到的strongaccuse请求,更新term,重新选举leader
func (*BraftNode) NotifyVote ¶
NotifyVote 处理收到的投票请求,如果收到的票数超过阈值,自己会成为leader
func (*BraftNode) NotifyWeakAccuse ¶
NotifyWeakAccuse 处理收到的weakaccuse请求,记录accuse个数,超过阈值则发起strong accuse
func (*BraftNode) SaveSignedResult ¶
func (node *BraftNode) SaveSignedResult(msg *pb.SignedResult)
func (*BraftNode) SyncUp ¶
func (bn *BraftNode) SyncUp(ctx context.Context, msg *pb.SyncUpRequest) (*pb.SyncUpResponse, error)
SyncUp 处理收到的同步请求
func (*BraftNode) TokenRegister ¶
func (node *BraftNode) TokenRegister(regInfo *TokenRegInfo)
TokenRegister 新token合约注册
func (*BraftNode) WatchSyncUp ¶
func (bn *BraftNode) WatchSyncUp(ctx context.Context, msg *pb.SyncUpRequest) (*pb.SyncUpResponse, error)
type ChainRegID ¶
type ChainRegID struct {
ChainID uint32 `json:"chain_id"`
}
type ChainRegInfo ¶
type JoinMsg ¶
type JoinMsg struct { LocalID int32 MultiSigInfos []cluster.MultiSigInfo }
type Leader ¶
type Leader struct { BecomeLeaderEvent *util.Event NewInitEvent *util.Event RetireEvent *util.Event sync.Mutex // contains filtered or unexported fields }
Leader leader节点描述
func NewLeader ¶
func NewLeader(nodeInfo cluster.NodeInfo, bs *primitives.BlockStore, ts *primitives.TxStore, signer *crypto.SecureSigner, btcWatcher *btcwatcher.MortgageWatcher, bchWatcher *btcwatcher.MortgageWatcher, ethWatcher *ew.Client, xinWatcher *eoswatcher.EOSWatcher, eosWatcher *eoswatcher.EOSWatcherMain, tool *price.PriceTool, pm *cluster.PeerManager) *Leader
NewLeader 新生成一个leader对象,并启动后台任务,循环检查选举相关任务(创建块,投票等)
func (*Leader) OnJoinCancel ¶
func (ld *Leader) OnJoinCancel()
func (*Leader) OnNewNodeJoin ¶
func (*Leader) OnNodeJoinedDone ¶
func (*Leader) OnNodeLeave ¶
func (*Leader) OnNodeLeaveDone ¶
func (ld *Leader) OnNodeLeaveDone()
func (*Leader) SetFeeRate ¶
SetFeeRate 设置网关的交易手续费
type ManualMintRequest ¶
type ManualMintRequest struct { Amount int64 `json:"amount"` Address string `json:"address"` Proposal string `json:"proposal"` Chain uint32 `json:"chain"` Token uint32 `json:"token"` }
ManualMintRequest 手工铸币结构
type NodeView ¶
type NodeView struct { IP string `json:"ip"` HostName string `json:"host_name"` IsLeader bool `json:"is_leader"` IsOnline bool `json:"is_online"` FiredCnt int32 `json:"fired_cnt"` //被替换掉leader的次数 EthHeight int64 `json:"eth_height"` BchHeight int64 `json:"bch_height"` BtcHeight int64 `json:"btc_height"` // contains filtered or unexported fields }
节点数据
type SignedResultCache ¶
统计sign suc的节点数
type SyncDaemon ¶
type SyncDaemon struct {
// contains filtered or unexported fields
}
SyncDaemon 后台向其他节点同步的对象,单独goroutine运行
func NewSyncDaemon ¶
func NewSyncDaemon(db *dgwdb.LDBDatabase, bs *primitives.BlockStore, pm *cluster.PeerManager) *SyncDaemon
NewSyncDaemon 新建一个SyncDaemon对象并返回
func (*SyncDaemon) SignalSyncUp ¶
func (sd *SyncDaemon) SignalSyncUp(nodeId int32)
SignalSyncUp 通知syncdaemon发起同步请求
type TokenRegID ¶
type TokenRegID struct {
TokenID uint32 `json:"token_id"`
}
type TokenRegInfo ¶
type TxView ¶
type TxView struct { FromTxHash string `json:"from_tx_hash"` //转出txhash ToTxHash string `json:"to_tx_hash"` //转入txhash DGWTxHash string `json:"dgw_hash"` //dgwtxhash From string `json:"from"` //转出链 To string `json:"to"` //转入链 Time int64 `json:"time"` Block string `json:"block"` //所在区块blockID BlockHeight int64 `json:"block_height"` //所在区块高度 Amount int64 `json:"amount"` ToAddrs []string `json:"to_addrs"` FromFee int64 `json:"from_fee"` DGWFee int64 `json:"dgw_fee"` ToFee int64 `json:"to_fee"` TokenCode uint32 `json:"token_code"` AppCode uint32 `json:"app_code"` FinalAmount int64 `json:"final_amount"` //扣除手续费后的金额 }