UNPKG

leap-node

Version:

[![codecov](https://codecov.io/gh/leapdao/leap-node/branch/master/graph/badge.svg)](https://codecov.io/gh/leapdao/leap-node) [![Docker Repository on Quay](https://quay.io/repository/leapdao/leap-node/status "Docker Repository on Quay")](https://quay.io/re

30 lines (24 loc) 903 B
/** * Copyright (c) 2018-present, Leap DAO (leapdao.org) * * This source code is licensed under the Mozilla Public License Version 2.0 * found in the LICENSE file in the root directory of this source tree. */ const { Type } = require('leap-core'); module.exports = (state, tx) => { if (tx.type !== Type.VALIDATOR_LOGOUT) { throw new Error('validatorJoin tx expected'); } if ( state.slots[tx.options.slotId] && tx.options.eventsCount !== state.slots[tx.options.slotId].eventsCount + 1 ) { throw new Error('eventsCount expected to be x + 1'); } if (!state.slots[tx.options.slotId]) { throw new Error(`Slot ${tx.options.slotId} is empty`); } state.slots[tx.options.slotId].activationEpoch = tx.options.activationEpoch; state.slots[tx.options.slotId].eventsCount = tx.options.eventsCount; state.slots[tx.options.slotId].newSigner = tx.options.newSigner; };