update = (state, message) => {
  switch (message.type) {
    case ACTIONS.IPFS_INIT: {
      const { task } = message
      switch (task.status) {
        case 'Init': {
          return { ...state, ready: false }
        }
        case 'Exit': {
          const { result } = task
          if (result.ok) {
            const { provider, apiAddress, ipfs: service } = result.value
            ipfs = service
            return {
              ...state,
              ready: true,
              failed: false,
              provider,
              apiAddress: apiAddress || state.apiAddress
            }
          } else {
            return {
              ...state,
              ready: false,
              failed: true
            }
          }
        }
        default: {
          return state
        }
      }
    }
    case ACTIONS.IPFS_STOPPED: {
      return { ...state, ready: false, failed: false }
    }
    case ACTIONS.IPFS_API_ADDRESS_UPDATED: {
      return { ...state, apiAddress: message.payload, invalidAddress: false }
    }
    case ACTIONS.IPFS_API_ADDRESS_INVALID: {
      return { ...state, invalidAddress: true }
    }
    case ACTIONS.IPFS_API_ADDRESS_INVALID_DISMISS: {
      return { ...state, invalidAddress: true }
    }
    case ACTIONS.IPFS_API_ADDRESS_PENDING_FIRST_CONNECTION: {
      const { pending } = message
      return { ...state, pendingFirstConnection: pending }
    }
    case ACTIONS.IPFS_CONNECT_SUCCEED: {
      return { ...state, failed: false }
    }
    case ACTIONS.IPFS_CONNECT_FAILED: {
      return { ...state, failed: true }
    }
    default: {
      return state
    }
  }
}
@param {Model} state
@param {Message} message
@returns {Model}