github.com/turingchain2020/turingchain@v1.1.21/executor/plugin_kvmvcc.go (about)

     1  // Copyright Turing Corp. 2018 All Rights Reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package executor
     6  
     7  import (
     8  	"github.com/turingchain2020/turingchain/types"
     9  )
    10  
    11  func init() {
    12  	RegisterPlugin("mvcc", &mvccPlugin{})
    13  }
    14  
    15  type mvccPlugin struct {
    16  	pluginBase
    17  }
    18  
    19  func (p *mvccPlugin) CheckEnable(executor *executor, enable bool) (kvs []*types.KeyValue, ok bool, err error) {
    20  	kvs, ok, err = p.checkFlag(executor, types.FlagKeyMVCC, enable)
    21  	if err == types.ErrDBFlag {
    22  		panic("mvcc config is enable, it must be synchronized from 0 height ")
    23  	}
    24  	return kvs, ok, err
    25  }
    26  
    27  func (p *mvccPlugin) ExecLocal(executor *executor, data *types.BlockDetail) (kvs []*types.KeyValue, err error) {
    28  	kvs = AddMVCC(executor.localDB, data)
    29  	return kvs, nil
    30  }
    31  
    32  func (p *mvccPlugin) ExecDelLocal(executor *executor, data *types.BlockDetail) ([]*types.KeyValue, error) {
    33  	kvs := DelMVCC(executor.localDB, data)
    34  	return kvs, nil
    35  }