Skip to content

Commit

Permalink
Fix duplicate block error
Browse files Browse the repository at this point in the history
  • Loading branch information
raduom committed Oct 12, 2021
1 parent 1f20481 commit b20be79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plutus-chain-index/src/Plutus/ChainIndex/Types.hs
Expand Up @@ -127,7 +127,7 @@ instance Monoid Tip where
instance Ord Tip where
TipAtGenesis <= _ = True
_ <= TipAtGenesis = False
(Tip ls _ _) <= (Tip rs _ _) = ls <= rs
(Tip _ _ lb) <= (Tip _ _ rb) = lb <= rb

instance Pretty Tip where
pretty TipAtGenesis = "TipAtGenesis"
Expand Down
4 changes: 3 additions & 1 deletion plutus-chain-index/src/Plutus/ChainIndex/UtxoState.hs
Expand Up @@ -49,6 +49,8 @@ import Plutus.ChainIndex.ChainIndexLog (InsertUtxoPosition (..))
import Plutus.ChainIndex.Types (Point (..), Tip (..), pointsToTip)
import Prettyprinter (Pretty (..))

import qualified Debug.Trace as Debug

-- | UTXO / ledger state, kept in memory. We are only interested in the UTXO set, everything else is stored
-- on disk. This is OK because we don't need to validate transactions when they come in.
data UtxoState a =
Expand Down Expand Up @@ -107,7 +109,7 @@ insert s@UtxoState{_usTip=thisTip} ix =
in case tip (utxoState after) of
TipAtGenesis -> Right $ InsertUtxoSuccess{newIndex = before FT.|> s, insertPosition = InsertAtEnd}
t | t > thisTip -> Right $ InsertUtxoSuccess{newIndex = (before FT.|> s) <> after, insertPosition = InsertBeforeEnd}
| otherwise -> Left $ DuplicateBlock t
| otherwise -> Debug.trace ("Our tip: " <> show thisTip <> " Ix tip: " <> show t) $ Left $ DuplicateBlock t

data RollbackResult a =
RollbackResult
Expand Down

0 comments on commit b20be79

Please sign in to comment.