Merge pull request #171 from StephenButtolph/atomic-block-cleanup

Clean up the acceptance of atomic blocks
This commit is contained in:
Stephen Buttolph 2020-05-23 13:36:17 -04:00 committed by GitHub
commit c3f9a50228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 10 deletions

View File

@ -36,7 +36,7 @@ type AtomicTx interface {
// AtomicBlock being accepted results in the transaction contained in the
// block to be accepted and committed to the chain.
type AtomicBlock struct {
SingleDecisionBlock `serialize:"true"`
CommonDecisionBlock `serialize:"true"`
Tx AtomicTx `serialize:"true"`
@ -45,7 +45,7 @@ type AtomicBlock struct {
// initialize this block
func (ab *AtomicBlock) initialize(vm *VM, bytes []byte) error {
if err := ab.SingleDecisionBlock.initialize(vm, bytes); err != nil {
if err := ab.CommonDecisionBlock.initialize(vm, bytes); err != nil {
return err
}
return ab.Tx.initialize(vm)
@ -123,9 +123,6 @@ func (ab *AtomicBlock) Accept() {
ab.onAcceptFunc()
}
parent := ab.parentBlock()
// remove this block and its parent from memory
parent.free()
ab.free()
}
@ -133,11 +130,9 @@ func (ab *AtomicBlock) Accept() {
// decision block, has ID [parentID].
func (vm *VM) newAtomicBlock(parentID ids.ID, tx AtomicTx) (*AtomicBlock, error) {
ab := &AtomicBlock{
SingleDecisionBlock: SingleDecisionBlock{CommonDecisionBlock: CommonDecisionBlock{
CommonBlock: CommonBlock{
Block: core.NewBlock(parentID),
vm: vm,
},
CommonDecisionBlock: CommonDecisionBlock{CommonBlock: CommonBlock{
Block: core.NewBlock(parentID),
vm: vm,
}},
Tx: tx,
}