OSDN Git Service

fix(bcrp): don't allow overwrite attachEntries map when apply block (#1993)
authorDeKaiju <longjinglv@163.com>
Mon, 28 Jun 2021 02:33:06 +0000 (10:33 +0800)
committerGitHub <noreply@github.com>
Mon, 28 Jun 2021 02:33:06 +0000 (10:33 +0800)
protocol/state/contract_view.go

index e4314c7..28e4e14 100644 (file)
@@ -27,7 +27,9 @@ func (view *ContractViewpoint) ApplyBlock(block *types.Block) {
                        if program := output.ControlProgram; bcrp.IsBCRPScript(program) {
                                var hash [32]byte
                                sha3pool.Sum256(hash[:], program)
-                               view.AttachEntries[hash] = append(tx.ID.Bytes(), program...)
+                               if _, ok := view.AttachEntries[hash]; !ok {
+                                       view.AttachEntries[hash] = append(tx.ID.Bytes(), program...)
+                               }
                        }
                }
        }