contract/ledger/LedgerStateManager.js
/**
     * Update a state in the list. 
     * Puts the new state in world state with appropriate composite key.
     * Note that state defines its own key.
     * A state is serialized before writing. 
     * Logic is very similar to addState() but kept separate becuase it is semantically distinct.
     * @param {object} objState Object to be updated to the blockchain.
     */
Update a state in the list.
Puts the new state in world state with appropriate composite key.
Note that state defines its own key.
A state is serialized before writing.
Logic is very similar to addState() but kept separate becuase it is semantically distinct.
@param {object} objState Object to be updated to the blockchain.
Update a state in the list . Puts the new state in world state with appropriate composite key . Note that state defines its own key . A state is serialized before writing . Logic is very similar to addState () but kept separate becuase it is semantically distinct . @param { object } objState Object to be updated to the blockchain .
async updateState(objState) {
        try {
            if (objState == null || objState == undefined) {
                logWrite(`[updateState] ${msgErrorManager1}`);
                throw msgErrorManager1;
            }
            let ledgerKey = objState.key;
            let ledgerData = JSON.stringify(objState);
            logWrite(`[updateState] (ledgerData) before -> ctx.stub.putState = ${ledgerData}`);
            await this.ctx.stub.putState(ledgerKey, ledgerData);
            logWrite(`[updateState] (objState.key) before return to caller = ${objState.key}`);
            return objState;
        } catch (err) {
            console.log(err);
            console.log(err.stack);
            return err.toString();
        }
    }
async updateState ( objState ) { try { if ( objState == null || objState == undefined ) { logWrite ( ` ${ msgErrorManager1 } ` ) ; throw msgErrorManager1 ; } let ledgerKey = objState . key ; let ledgerData = JSON . stringify ( objState ) ; logWrite ( ` ${ ledgerData } ` ) ; await this . ctx . stub . putState ( ledgerKey , ledgerData ) ; logWrite ( ` ${ objState . key } ` ) ; return objState ; } catch ( err ) { console . log ( err ) ; console . log ( err . stack ) ; return err . toString ( ) ; } }
Update a state in the list.
Update a state in the list .