github.com/turingchain2020/turingchain@v1.1.21/system/dapp/manage/executor/exec_del_local.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 "fmt" 9 10 pty "github.com/turingchain2020/turingchain/system/dapp/manage/types" 11 "github.com/turingchain2020/turingchain/types" 12 ) 13 14 func localKey(key string) []byte { 15 return []byte(fmt.Sprintf("LODB-manage-%s", key)) 16 } 17 18 // ExecDelLocal_Modify defines execdellocal modify func 19 func (c *Manage) ExecDelLocal_Modify(transfer *types.ModifyConfig, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { 20 set := &types.LocalDBSet{} 21 22 for i := 0; i < len(receipt.Logs); i++ { 23 item := receipt.Logs[i] 24 if item.Ty == pty.ManageActionModifyConfig { 25 var receipt types.ReceiptConfig 26 err := types.Decode(item.Log, &receipt) 27 if err != nil { 28 panic(err) //数据错误了,已经被修改了 29 } 30 key := receipt.Current.Key 31 set.KV = append(set.KV, &types.KeyValue{Key: localKey(key), Value: types.Encode(receipt.Prev)}) 32 clog.Debug("ExecDelLocal to savelogs", "config ", key, "value", receipt.Prev) 33 } 34 } 35 return set, nil 36 }