Skip to content

Commit

Permalink
Fix: TransactionLiked did not consider monotonicity (#1148)
Browse files Browse the repository at this point in the history
Co-authored-by: Hans Moog <hm@mkjc.net>
  • Loading branch information
hmoog and Hans Moog authored Mar 29, 2021
1 parent dc8b79f commit abe0e69
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/consensus/fcob/consensusmechanism.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@ func (f *ConsensusMechanism) Setup() {

// TransactionLiked returns a boolean value indicating whether the given Transaction is liked.
func (f *ConsensusMechanism) TransactionLiked(transactionID ledgerstate.TransactionID) (liked bool) {
f.storage.Opinion(transactionID).Consume(func(opinion *Opinion) {
liked = opinion.OpinionEssence.liked
f.tangle.LedgerState.TransactionMetadata(transactionID).Consume(func(transactionMetadata *ledgerstate.TransactionMetadata) {
f.tangle.LedgerState.BranchDAG.Branch(transactionMetadata.BranchID()).Consume(func(branch ledgerstate.Branch) {
if !branch.MonotonicallyLiked() {
return
}

f.storage.Opinion(transactionID).Consume(func(opinion *Opinion) {
liked = opinion.OpinionEssence.liked
})
})
})

return
Expand Down

0 comments on commit abe0e69

Please sign in to comment.