Skip to content

Smart storage values based on assumed chain and chainstate values #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/qml/chainmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BITCOIN_QML_CHAINMODEL_H
#define BITCOIN_QML_CHAINMODEL_H

#include <chainparams.h>
#include <interfaces/chain.h>

#include <QObject>
Expand All @@ -23,13 +24,17 @@ class ChainModel : public QObject
{
Q_OBJECT
Q_PROPERTY(QString currentNetworkName READ currentNetworkName WRITE setCurrentNetworkName NOTIFY currentNetworkNameChanged)
Q_PROPERTY(quint64 assumedBlockchainSize READ assumedBlockchainSize CONSTANT)
Q_PROPERTY(quint64 assumedChainstateSize READ assumedChainstateSize CONSTANT)
Q_PROPERTY(QVariantList timeRatioList READ timeRatioList NOTIFY timeRatioListChanged)

public:
explicit ChainModel(interfaces::Chain& chain);

QString currentNetworkName() const { return m_current_network_name; };
void setCurrentNetworkName(QString network_name);
quint64 assumedBlockchainSize() const { return m_assumed_blockchain_size; };
quint64 assumedChainstateSize() const { return m_assumed_chainstate_size; };
QVariantList timeRatioList() const { return m_time_ratio_list; };

int timestampAtMeridian();
Expand All @@ -46,6 +51,8 @@ public Q_SLOTS:

private:
QString m_current_network_name;
quint64 m_assumed_blockchain_size{ Params().AssumedBlockchainSize() };
quint64 m_assumed_chainstate_size{ Params().AssumedChainStateSize() };
/* time_ratio: Ratio between the time at which an event
* happened and 12 hours. So, for example, if a block is
* found at 4 am or pm, the time_ratio would be 0.3.
Expand Down
10 changes: 7 additions & 3 deletions src/qml/components/StorageOptions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import org.bitcoincore.qt 1.0

import "../controls"

ColumnLayout {
Expand All @@ -19,7 +22,7 @@ ColumnLayout {
Layout.fillWidth: true
ButtonGroup.group: group
text: qsTr("Reduce storage")
description: qsTr("Uses about 2GB. For simple wallet use.")
description: qsTr("Uses about %1GB. For simple wallet use.").arg(chainModel.assumedChainstateSize + 2)
recommended: true
checked: !root.customStorage && optionsModel.prune
onClicked: {
Expand All @@ -36,7 +39,8 @@ ColumnLayout {
ButtonGroup.group: group
text: qsTr("Store all data")
checked: !optionsModel.prune
description: qsTr("Uses about 550GB. Support the network.")
description: qsTr("Uses about %1GB. Support the network.").arg(
chainModel.assumedBlockchainSize + chainModel.assumedChainstateSize)
onClicked: {
optionsModel.prune = false
}
Expand All @@ -49,7 +53,7 @@ ColumnLayout {
ButtonGroup.group: group
checked: root.customStorage && optionsModel.prune
text: qsTr("Custom")
description: qsTr("Storing recent blocks up to %1GB").arg(root.customStorageAmount)
description: qsTr("Storing about %1GB of data.").arg(root.customStorageAmount + chainModel.assumedChainstateSize)
onClicked: {
optionsModel.prune = true
optionsModel.pruneSizeGB = root.customStorageAmount
Expand Down
2 changes: 1 addition & 1 deletion src/qml/components/StorageSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ColumnLayout {
Setting {
id: pruneTargetSetting
Layout.fillWidth: true
header: qsTr("Storage limit (GB)")
header: qsTr("Block Storage limit (GB)")
errorText: qsTr("This is not a valid prune target. Please choose a value that is equal to or larger than 1GB")
showErrorText: false
actionItem: ValueInput {
Expand Down
2 changes: 1 addition & 1 deletion src/qml/pages/onboarding/OnboardingStorageLocation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ InformationPage {
bold: true
headerText: qsTr("Storage location")
headerMargin: 0
description: qsTr("Where do you want to store the downloaded block data?\nYou need a minimum of 1GB of storage.")
description: qsTr("Where do you want to store the downloaded block data?\nYou need a minimum of %1GB of storage.").arg(chainModel.assumedChainstateSize + 1)
descriptionMargin: 20
detailActive: true
detailItem: StorageLocations {}
Expand Down