contract/ledger/LedgerStateManager.js
/**
     * Delete a state in the list.
     * 
     * https://stackoverflow.com/questions/43623517/how-does-delstate-work-in-fabric
     * 
     * There is a state database that stores keys and their values. This is different from 
     * the sequence of blocks that make up the blockchain. A key and its associated value 
     * can be removed from the state database using the DelState function. However, this 
     * does not mean that there is an alteration of blocks on the blockchain. 
     * The removal of a key and value would be stored as a transaction on the blockchain 
     * just as the prior addition and any modifications were stored as transactions on 
     * the blockchain.
     * @param {object} objState Object to be marked as deleted to the blockchain. 
     */
Delete a state in the list.



There is a state database that stores keys and their values. This is different from
the sequence of blocks that make up the blockchain. A key and its associated value
can be removed from the state database using the DelState function. However, this
does not mean that there is an alteration of blocks on the blockchain.
The removal of a key and value would be stored as a transaction on the blockchain
just as the prior addition and any modifications were stored as transactions on
the blockchain.
@param {object} objState Object to be marked as deleted to the blockchain.
Delete a state in the list . There is a state database that stores keys and their values . This is different from the sequence of blocks that make up the blockchain . A key and its associated value can be removed from the state database using the DelState function . However this does not mean that there is an alteration of blocks on the blockchain . The removal of a key and value would be stored as a transaction on the blockchain just as the prior addition and any modifications were stored as transactions on the blockchain . @param { object } objState Object to be marked as deleted to the blockchain .
async deleteState(objState) {
        try {
            if (objState == null || objState == undefined) {
                logWrite(`[deleteState] ${msgErrorManager1}`);
                throw msgErrorManager1;
            }
            let ledgerKey = objState.key;
            logWrite(`[deleteState] (ledgerKey) before -> ctx.stub.getState = ${ledgerKey} `);
            let dataState = await this.ctx.stub.getState(ledgerKey);
            if (dataState == null || dataState == undefined) {
                return null;
            }
            logWrite(`[deleteState] (dataState) after -> ctx.stub.getState = ${JSON.stringify(dataState)}`);
            await this.ctx.stub.deleteState(ledgerKey);
            logWrite(`[deleteState] (objState.key) before return to caller = ${objState.key}`);
            return objState;
        } catch (err) {
            console.log(err);
            console.log(err.stack);
            return err.toString();
        }
    }
async deleteState ( objState ) { try { if ( objState == null || objState == undefined ) { logWrite ( ` ${ msgErrorManager1 } ` ) ; throw msgErrorManager1 ; } let ledgerKey = objState . key ; logWrite ( ` ${ ledgerKey } ` ) ; let dataState = await this . ctx . stub . getState ( ledgerKey ) ; if ( dataState == null || dataState == undefined ) { return null ; } logWrite ( ` ${ JSON . stringify ( dataState ) } ` ) ; await this . ctx . stub . deleteState ( ledgerKey ) ; logWrite ( ` ${ objState . key } ` ) ; return objState ; } catch ( err ) { console . log ( err ) ; console . log ( err . stack ) ; return err . toString ( ) ; } }
Delete a state in the list.
Delete a state in the list .