Skip to content

6 Transaction Reorderer

Senthilnathan Natarajan edited this page May 27, 2020 · 3 revisions

Transaction Reorderer

type transactionReorderer struct {
     txQueue          TransactionQueue
     dependencyGraph  DependencyGraph
     treeBuilder      TxMerkelTreeBuilder
     nextTxBatchQueue NextTxBatchQueue
}

type dependencyGraph struct {
     txWithNoInEdges []*transactionNode
     reads           map[string][]*transactionNode
     writes          map[string][]*transactionNode
}

type transactionNode struct {
     txID   string
     inEdges  []*transactionNode
     outEdges []*transactionNode
}

type DependencyGraph interface {
     AddTransaction(txs []*pb.Transaction) error
     RemoveTransactions(txs []*pb.Transaction) error
     TopologicalSort() []*pb.Transaction
     GetTransactionsFromLevel(level int) []*pb.Transaction
}

type reorderedTransactionQueue struct {
     queue      [][]*pb.Transaction
     merkleRoot []*pb.MerkleRoot
     mu         sync.RWMutex
}

type ReorderedTransactionQueue interface {
     Enqueue(txs []*pb.Transaction, merkleRoot *pb.MerkleRoot) error
     Dequeue() (txs []*pb.Transaction, *pb.MerkleRoot, error)
     Size() uint64
}
Clone this wiki locally