MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / AddEvidence

Method AddEvidence

evidence/pool.go:134–168  ·  view source on GitHub ↗

AddEvidence checks the evidence is valid and adds it to the pool.

(ev types.Evidence)

Source from the content-addressed store, hash-verified

132
133// AddEvidence checks the evidence is valid and adds it to the pool.
134func (evpool *Pool) AddEvidence(ev types.Evidence) error {
135 evpool.logger.Debug("Attempting to add evidence", "ev", ev)
136
137 // We have already verified this piece of evidence - no need to do it again
138 if evpool.isPending(ev) {
139 evpool.logger.Debug("Evidence already pending, ignoring this one", "ev", ev)
140 return nil
141 }
142
143 // check that the evidence isn't already committed
144 if evpool.isCommitted(ev) {
145 // this can happen if the peer that sent us the evidence is behind so we shouldn't
146 // punish the peer.
147 evpool.logger.Debug("Evidence was already committed, ignoring this one", "ev", ev)
148 return nil
149 }
150
151 // 1) Verify against state.
152 err := evpool.verify(ev)
153 if err != nil {
154 return types.NewErrInvalidEvidence(ev, err)
155 }
156
157 // 2) Save to store.
158 if err := evpool.addPendingEvidence(ev); err != nil {
159 return fmt.Errorf("can't add evidence to pending list: %w", err)
160 }
161
162 // 3) Add evidence to clist.
163 evpool.evidenceList.PushBack(ev)
164
165 evpool.logger.Info("Verified new evidence of byzantine behavior", "evidence", ev)
166
167 return nil
168}
169
170// ReportConflictingVotes takes two conflicting votes and forms duplicate vote evidence,
171// adding it eventually to the evidence pool.

Calls 8

isPendingMethod · 0.95
isCommittedMethod · 0.95
verifyMethod · 0.95
addPendingEvidenceMethod · 0.95
NewErrInvalidEvidenceFunction · 0.92
PushBackMethod · 0.80
DebugMethod · 0.65
InfoMethod · 0.65