public override Empty RecordCrossChainData(RecordCrossChainDataInput input) { Context.LogDebug(() => "Start RecordCrossChainData."); AssertCrossChainIndexingControllerAuthority(Context.Sender); AssertIsCrossChainBlockDataToBeReleased(input); var indexedParentChainBlockData = IndexParentChainBlockData(input.ProposedCrossChainData.ParentChainBlockDataList); if (indexedParentChainBlockData.ParentChainBlockDataList.Count > 0) { State.LastIndexedParentChainBlockData.Value = indexedParentChainBlockData; Context.LogDebug(() => $"Last indexed parent chain height {indexedParentChainBlockData.ParentChainBlockDataList.Last().Height}"); } var indexedSideChainBlockData = IndexSideChainBlockData( input.ProposedCrossChainData.SideChainBlockDataList, input.Proposer); if (indexedSideChainBlockData.SideChainBlockDataList.Count > 0) { State.IndexedSideChainBlockData.Set(Context.CurrentHeight, indexedSideChainBlockData); Context.LogDebug(() => $"Last indexed side chain height {indexedSideChainBlockData.SideChainBlockDataList.Last().Height}"); Context.Fire(new SideChainBlockDataIndexedEvent()); } ResetCrossChainIndexingProposal(); Context.LogDebug(() => "Finished RecordCrossChainData."); return(new Empty()); }
private void AssertIsCrossChainBlockDataToBeReleased(RecordCrossChainDataInput recordCrossChainDataInput) { var pendingProposalExists = TryGetProposalWithStatus(CrossChainIndexingProposalStatus.ToBeReleased, out var pendingCrossChainIndexingProposal); Assert( pendingProposalExists && pendingCrossChainIndexingProposal.ProposedCrossChainBlockData.Equals(recordCrossChainDataInput .ProposedCrossChainData) && pendingCrossChainIndexingProposal.Proposer == recordCrossChainDataInput.Proposer, "Incorrect cross chain indexing proposal status."); State.CrossChainIndexingProposal.Value = new CrossChainIndexingProposal(); }