MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / makeArena

Method makeArena

blockproducer/branch.go:100–120  ·  view source on GitHub ↗

makeArena creates an arena branch from the receiver (origin) branch for tx/block applying test. It copies head node and transaction pools, but references the read-only preview index of the origin branch. This branch is typically used to attempt a block producing or applying base on the origin branc

()

Source from the content-addressed store, hash-verified

98// in the new block should be written to its dirty index first, and committed to the read-only
99// index later when the origin branch is being replaced by this new branch.
100func (b *branch) makeArena() *branch {
101 var (
102 p = make(map[hash.Hash]pi.Transaction)
103 u = make(map[hash.Hash]pi.Transaction)
104 )
105 for k, v := range b.packed {
106 p[k] = v
107 }
108 for k, v := range b.unpacked {
109 u[k] = v
110 }
111 return &branch{
112 head: b.head,
113 preview: &metaState{
114 dirty: newMetaIndex(),
115 readonly: b.preview.readonly,
116 },
117 packed: p,
118 unpacked: u,
119 }
120}
121
122func (b *branch) addTx(tx pi.Transaction) {
123 var k = tx.Hash()

Callers 3

applyBlockMethod · 0.95
produceBlockMethod · 0.95
TestChainFunction · 0.80

Calls 1

newMetaIndexFunction · 0.85

Tested by 1

TestChainFunction · 0.64