Exemple #1
0
        protected override void ConfirmedPrimeElected(BlockElectionDistillate blockElectionDistillate, FinalElectionResultDistillate finalElectionResultDistillate)
        {
            base.ConfirmedPrimeElected(blockElectionDistillate, finalElectionResultDistillate);

            NeuraliumBlockElectionDistillate neuraliumBlockElectionDistillate = (NeuraliumBlockElectionDistillate)blockElectionDistillate;

            NeuraliumFinalElectionResultDistillate neuraliumFinalElectionContext = (NeuraliumFinalElectionResultDistillate)finalElectionResultDistillate;

            this.centralCoordinator.PostSystemEvent(NeuraliumSystemEventGenerator.NeuraliumMiningPrimeElected(blockElectionDistillate.currentBlockId, neuraliumFinalElectionContext.BountyShare, neuraliumFinalElectionContext.TransactionTips, AccountId.FromString(neuraliumFinalElectionContext.DelegateAccountId)));

            Log.Information($"We were officially announced as a prime elected in Block {blockElectionDistillate.currentBlockId} for the election that was announced in block {blockElectionDistillate.currentBlockId - neuraliumFinalElectionContext.BlockOffset}");
        }
Exemple #2
0
        protected override MiningHistoryEntry PrepareMiningHistoryEntry(BlockElectionDistillate blockElectionDistillate, FinalElectionResultDistillate finalElectionResultDistillate)
        {
            MiningHistoryEntry entry = base.PrepareMiningHistoryEntry(blockElectionDistillate, finalElectionResultDistillate);

            if (entry is NeuraliumMiningHistoryEntry neuraliumMiningHistoryEntry && finalElectionResultDistillate is NeuraliumFinalElectionResultDistillate neuraliumFinalElectionContext)
            {
                neuraliumMiningHistoryEntry.BountyShare     = neuraliumFinalElectionContext.BountyShare;
                neuraliumMiningHistoryEntry.TransactionTips = neuraliumFinalElectionContext.TransactionTips;
            }

            return(entry);
        }
        public override ITransactionSelectionMethod CreateTransactionSelectionMethod(TransactionSelectionMethodType type, long blockId, BlockElectionDistillate blockElectionDistillate, IWalletProvider walletProvider, BlockChainConfigurations blockChainConfigurations, BlockchainServiceSet serviceSet)
        {
            if (blockElectionDistillate.electionContext is INeuraliumElectionContext neuraliumElectionContext)
            {
                if (type == TransactionSelectionMethodTypes.Instance.Automatic)
                {
                    // ok, this one is meant to be automatic. we wlil try to find the best method
                    //TODO: make this more elaborate. Try to response to the various cues we can use like the declared bounty allocator
                    if (neuraliumElectionContext.BountyAllocationMethod.Version.Type.Value == BountyAllocationMethodTypes.Instance.EqualSplit)
                    {
                        type = NeuraliumTransactionSelectionMethodTypes.Instance.HighestTips;
                    }

                    // the default automatic best choice
                    type = NeuraliumTransactionSelectionMethodTypes.Instance.HighestTips;
                }

                if (type == NeuraliumTransactionSelectionMethodTypes.Instance.HighestTips)
                {
                    // ok, nothing special here, lets just maximize profits by choosing the highest paying transactions
                    return(new NeuraliumHighestTipTransactionSelectionMethod(blockId, neuraliumElectionContext.TransactionTipsAllocationMethod, (INeuraliumWalletProviderProxy)walletProvider, blockElectionDistillate.electionContext.MaximumElectedTransactionCount, ((NeuraliumBlockChainConfigurations)blockChainConfigurations).HighestTipTransactionSelectionStrategySettings, serviceSet.BlockchainTimeService));
                }
            }

            return(base.CreateTransactionSelectionMethod(type, blockId, blockElectionDistillate, walletProvider, blockChainConfigurations, serviceSet));
        }