Documentation
¶
Overview ¶
package txn deals with tx data
Index ¶
- Constants
- Variables
- func GenerateAutoTxWithRWSets(inputs []*protos.TxInputExt, outputs []*protos.TxOutputExt) (*pb.Transaction, error)
- func GenerateAwardTx(address, awardAmount string, desc []byte) (*pb.Transaction, error)
- func GenerateEmptyTx(desc []byte) (*pb.Transaction, error)
- func GenerateRootTx(js []byte) (*pb.Transaction, error)
- func GenerateVoteAwardTx(address []byte, awardAmount string, desc []byte) (*pb.Transaction, error)
- func ParseContractTransferRequest(requests []*protos.InvokeRequest) (string, *big.Int, error)
- func SplitToDags(block *pb.InternalBlock) [][]*pb.Transaction
- func TopSortDFS(g TxGraph) (order []string, cyclic bool, childDAGSize []int)
- type RootJSON
- type Tx
- func (t *Tx) GetUnconfirmedTx(dedup bool) ([]*pb.Transaction, error)
- func (t *Tx) LoadUnconfirmedTxFromDisk() error
- func (t *Tx) QueryTx(txid []byte) (*pb.Transaction, error)
- func (t *Tx) SetMaxConfirmedDelay(seconds uint32)
- func (t *Tx) SortUnconfirmedTx() (map[string]*pb.Transaction, TxGraph, map[string]bool, error)
- type TxGraph
Constants ¶
View Source
const ( TxVersion = 1 RootTxVersion = 0 DefaultMaxConfirmedDelay = 300 )
Variables ¶
Functions ¶
func GenerateAutoTxWithRWSets ¶
func GenerateAutoTxWithRWSets(inputs []*protos.TxInputExt, outputs []*protos.TxOutputExt) (*pb.Transaction, error)
生成只有读写集的空交易
func GenerateAwardTx ¶
func GenerateAwardTx(address, awardAmount string, desc []byte) (*pb.Transaction, error)
生成奖励TX
func GenerateVoteAwardTx ¶
生成投票奖励的交易
func SplitToDags ¶
func SplitToDags(block *pb.InternalBlock) [][]*pb.Transaction
func TopSortDFS ¶
TopSortDFS 对依赖关系图进行拓扑排序 输入:依赖关系图,就是个map 输出: order: 排序后的有序数组,依赖者排在前面,被依赖的排在后面
cyclic: 如果发现有环形依赖关系则输出这个数组
实现参考: https://rosettacode.org/wiki/Topological_sort#Go 在我们映射中,RefTx是边的源点
Types ¶
type RootJSON ¶
type RootJSON struct {
Version string `json:"version"`
Consensus struct {
Miner string `json:"miner"`
} `json:"consensus"`
Predistribution []struct {
Address string `json:"address"`
Quota string `json:"quota"`
} `json:"predistribution"`
}
RootJSON xuper.json对应的struct,目前先只写了utxovm关注的字段
type Tx ¶
type Tx struct {
UnconfirmTxAmount int64
UnconfirmTxInMem *sync.Map
AvgDelay int64
// contains filtered or unexported fields
}
func (*Tx) GetUnconfirmedTx ¶
func (t *Tx) GetUnconfirmedTx(dedup bool) ([]*pb.Transaction, error)
GetUnconfirmedTx 挖掘一批unconfirmed的交易打包,返回的结果要保证是按照交易执行的先后顺序 maxSize: 打包交易最大的长度(in byte), -1 表示不限制
func (*Tx) LoadUnconfirmedTxFromDisk ¶
从disk还原unconfirm表到内存, 初始化的时候
func (*Tx) QueryTx ¶
func (t *Tx) QueryTx(txid []byte) (*pb.Transaction, error)
QueryTx 查询一笔交易,从unconfirm表中查询
func (*Tx) SetMaxConfirmedDelay ¶
func (*Tx) SortUnconfirmedTx ¶
加载所有未确认的订单表到内存 参数: dedup : true-删除已经确认tx, false-保留已经确认tx 返回: txMap : txid -> Transaction
txGraph: txid -> [依赖此txid的tx]
Click to show internal directories.
Click to hide internal directories.