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
()
| 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. |
| 100 | func (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 | |
| 122 | func (b *branch) addTx(tx pi.Transaction) { |
| 123 | var k = tx.Hash() |