Quiero eliminar el aspecto cronometrado de este contrato de crowdsale y hacerlo finalizable manualmente [cerrado]

¿Qué líneas elimino y con qué las reemplazo para cambiar esto de un contrato de crowdsale cronometrado a uno que puedo finalizar manualmente?

pragma solidity ^0.4.18;

interface token {
    function transfer(address receiver, uint amount) external;
}

contract Crowdsale {
    address public beneficiary;
    uint public fundingGoal;
    uint public amountRaised;
    uint public deadline;
    uint public price;
    token public tokenReward;
    mapping(address => uint256) public balanceOf;
    bool fundingGoalReached = false;
    bool crowdsaleClosed = false;

    event GoalReached(address recipient, uint totalAmountRaised);
    event FundTransfer(address backer, uint amount, bool isContribution);

    /**
     * Constructor function
     *
     * Setup the owner
     */
    function Crowdsale(
        address ifSuccessfulSendTo,
        uint fundingGoalInEthers,
        uint durationInMinutes,
        uint etherCostOfEachToken,
        address addressOfTokenUsedAsReward
    ) public {
        beneficiary = ifSuccessfulSendTo;
        fundingGoal = fundingGoalInEthers * 1 ether;
        deadline = now + durationInMinutes * 1 minutes;
        price = etherCostOfEachToken * 1 ether;
        tokenReward = token(addressOfTokenUsedAsReward);
    }

    /**
     * Fallback function
     *
     * The function without name is the default function that is called whenever anyone sends funds to a contract
     */
    function () payable public {
        require(!crowdsaleClosed);
        uint amount = msg.value;
        balanceOf[msg.sender] += amount;
        amountRaised += amount;
        tokenReward.transfer(msg.sender, amount / price);
       emit FundTransfer(msg.sender, amount, true);
    }

    modifier afterDeadline() { if (now >= deadline) _; }

    /**
     * Check if goal was reached
     *
     * Checks if the goal or time limit has been reached and ends the campaign
     */
    function checkGoalReached() public afterDeadline {
        if (amountRaised >= fundingGoal){
            fundingGoalReached = true;
            emit GoalReached(beneficiary, amountRaised);
        }
        crowdsaleClosed = true;
    }


    /**
     * Withdraw the funds
     *
     * Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
     * sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
     * the amount they contributed.
     */
    function safeWithdrawal() public afterDeadline {
        if (!fundingGoalReached) {
            uint amount = balanceOf[msg.sender];
            balanceOf[msg.sender] = 0;
            if (amount > 0) {
                if (msg.sender.send(amount)) {
                   emit FundTransfer(msg.sender, amount, false);
                } else {
                    balanceOf[msg.sender] = amount;
                }
            }
        }

        if (fundingGoalReached && beneficiary == msg.sender) {
            if (beneficiary.send(amountRaised)) {
               emit FundTransfer(beneficiary, amountRaised, false);
            } else {
                //If we fail to send the funds to beneficiary, unlock funders balance
                fundingGoalReached = false;
            }
        }
    }
}
¿Qué has probado? ¿Qué hay del contrato que entiendes/te confunde?
Intenté eliminar todo lo relacionado con los objetivos de financiación, los inicios de tiempo, etc., pero luego no funcionó, así que obviamente estoy eliminando demasiado o no lo suficiente y ahí es donde me pierdo.
Entonces, ¿qué agregó para habilitar la "finalización manual"? ¿ Ha examinado los contratos de venta colectiva de código abierto como openzeppelin ?
No lo hice porque después de eliminar las cosas mencionadas anteriormente no funcionaría, así que ni siquiera lo intenté. He mirado los contratos de Openzeppelin pero, de nuevo, no he encontrado uno que tenga una función de finalización manual, al menos no que yo pueda ver. Gracias por tu ayuda y si tienes alguna otra sugerencia te lo agradecería.
Creo que tu pregunta no es muy específica. Su contrato inteligente no es trivial y su solicitud para eliminar una función es complicada. Una buena respuesta implicará una reescritura casi total de su contrato.

Respuestas (1)

Simplemente puede eliminar todas las instancias del afterDeadlinemodificador y el contrato ya no dependerá de ninguna función de tiempo.

Le aconsejo que aprenda más sobre el contrato y tal vez lo reescriba para seguir las mejores prácticas. Echa un vistazo a los contratos de crowdsale de OpenZeppelin .