diff --git a/build/version.go b/build/version.go index 64bff39622..0251efabff 100644 --- a/build/version.go +++ b/build/version.go @@ -6,15 +6,15 @@ import ( ) const ( - // Version is the current version of siad. - Version = "1.3.1" - // MaxEncodedVersionLength is the maximum length of a version string encoded // with the encode package. 100 is much larger than any version number we send // now, but it allows us to send additional information in the version string // later if we choose. For example appending the version string with the HEAD // commit hash. MaxEncodedVersionLength = 100 + + // Version is the current version of siad. + Version = "1.3.1" ) // IsVersion returns whether str is a valid version number. diff --git a/modules/gateway/consts.go b/modules/gateway/consts.go index e729443241..1470cbcd90 100644 --- a/modules/gateway/consts.go +++ b/modules/gateway/consts.go @@ -12,11 +12,9 @@ const ( // was altered to include additional information transfer. handshakeUpgradeVersion = "1.0.0" - // sessionUpgradeVersion is the version where the gateway handshake RPC - // was altered to include the ID of the genesis block, the gateway's - // unique ID, and whether a connection is desired. This version also uses - // smux instead of muxado for stream multiplexing. - sessionUpgradeVersion = "1.3.0" + // maxEncodedSessionHeaderSize is the maximum allowed size of an encoded + // sessionHeader object. + maxEncodedSessionHeaderSize = 40 + modules.MaxEncodedNetAddressLength // maxLocalOutbound is currently set to 3, meaning the gateway will not // consider a local node to be an outbound peer if the gateway already has @@ -34,12 +32,14 @@ const ( // pre-hardfork. minAcceptableVersion = "0.4.0" - // maxEncodedSessionHeaderSize is the maximum allowed size of an encoded - // sessionHeader object. - maxEncodedSessionHeaderSize = 40 + modules.MaxEncodedNetAddressLength - // saveFrequency defines how often the gateway saves its persistence. saveFrequency = time.Minute * 2 + + // sessionUpgradeVersion is the version where the gateway handshake RPC + // was altered to include the ID of the genesis block, the gateway's + // unique ID, and whether a connection is desired. This version also uses + // smux instead of muxado for stream multiplexing. + sessionUpgradeVersion = "1.3.0" ) var ( diff --git a/modules/gateway/persist.go b/modules/gateway/persist.go index b017212371..850674c512 100644 --- a/modules/gateway/persist.go +++ b/modules/gateway/persist.go @@ -9,11 +9,11 @@ import ( ) const ( - // nodesFile is the name of the file that contains all seen nodes. - nodesFile = "nodes.json" - // logFile is the name of the log file. logFile = modules.GatewayDir + ".log" + + // nodesFile is the name of the file that contains all seen nodes. + nodesFile = "nodes.json" ) // persistMetadata contains the header and version strings that identify the diff --git a/modules/host/contractmanager/consts.go b/modules/host/contractmanager/consts.go index 5a1299afd2..7ca3f69355 100644 --- a/modules/host/contractmanager/consts.go +++ b/modules/host/contractmanager/consts.go @@ -16,6 +16,10 @@ const ( // metadata associated with a storage folder. metadataFile = "siahostmetadata.dat" + // sectorFile is the file that is placed inside of a storage folder to + // house all of the sectors associated with a storage folder. + sectorFile = "siahostdata.dat" + // settingsFile is the name of the file that is used to save the contract // manager's settings. settingsFile = "contractmanager.json" @@ -26,10 +30,6 @@ const ( // manager's persistent settings are updated atomically. settingsFileTmp = "contractmanager.json_temp" - // sectorFile is the file that is placed inside of a storage folder to - // house all of the sectors associated with a storage folder. - sectorFile = "siahostdata.dat" - // walFile is the name of the file that is used to save the write ahead log // for the contract manager. walFile = "contractmanager.wal" diff --git a/modules/host/persist_compat_1.2.0.go b/modules/host/persist_compat_1.2.0.go index ca8d74e919..4d1d451a61 100644 --- a/modules/host/persist_compat_1.2.0.go +++ b/modules/host/persist_compat_1.2.0.go @@ -26,8 +26,8 @@ const ( contractManagerStorageFolderGranularity = 64 // The directory names and filenames of legacy storage manager files. - v112StorageManagerDir = "storagemanager" v112StorageManagerDBFilename = "storagemanager.db" + v112StorageManagerDir = "storagemanager" v112StorageManagerPersistFilename = "storagemanager.json" ) diff --git a/modules/miner/persist.go b/modules/miner/persist.go index 7d4ba44740..cb45db152e 100644 --- a/modules/miner/persist.go +++ b/modules/miner/persist.go @@ -11,10 +11,9 @@ import ( ) const ( - logFile = modules.MinerDir + ".log" - settingsFile = modules.MinerDir + ".json" - + logFile = modules.MinerDir + ".log" saveLoopPeriod = time.Minute * 2 + settingsFile = modules.MinerDir + ".json" ) var ( diff --git a/modules/negotiate.go b/modules/negotiate.go index 1f2701cdb1..43819016d9 100644 --- a/modules/negotiate.go +++ b/modules/negotiate.go @@ -21,44 +21,26 @@ const ( // termination, i.e. that the sender wishes to cease communication, but // not due to an error. StopResponse = "stop" +) +const ( // NegotiateDownloadTime defines the amount of time that the renter and // host have to negotiate a download request batch. The time is set high // enough that two nodes behind Tor have a reasonable chance of completing // the negotiation. NegotiateDownloadTime = 600 * time.Second - // NegotiateFileContractTime defines the amount of time that the renter and - // host have to negotiate a file contract. The time is set high enough that - // a node behind Tor has a reasonable chance at making the multiple - // required round trips to complete the negotiation. - NegotiateFileContractTime = 360 * time.Second - // NegotiateFileContractRevisionTime defines the minimum amount of time // that the renter and host have to negotiate a file contract revision. The // time is set high enough that a full 4MB can be piped through a // connection that is running over Tor. NegotiateFileContractRevisionTime = 600 * time.Second - // NegotiateRecentRevisionTime establishes the minimum amount of time that - // the connection deadline is expected to be set to when a recent file - // contract revision is being requested from the host. The deadline is long - // enough that the connection should be successful even if both parties are - // running Tor. - NegotiateRecentRevisionTime = 120 * time.Second - - // NegotiateRenewContractTime defines the minimum amount of time that the - // renter and host have to negotiate a final contract renewal. The time is - // high enough that the negotiation can occur over a Tor connection, and - // that both the host and the renter can have time to process large Merkle - // tree calculations that may be involved with renewing a file contract. - NegotiateRenewContractTime = 600 * time.Second - - // NegotiateSettingsTime establishes the minimum amount of time that the - // connection deadline is expected to be set to when settings are being - // requested from the host. The deadline is long enough that the connection - // should be successful even if both parties are on Tor. - NegotiateSettingsTime = 120 * time.Second + // NegotiateFileContractTime defines the amount of time that the renter and + // host have to negotiate a file contract. The time is set high enough that + // a node behind Tor has a reasonable chance at making the multiple + // required round trips to complete the negotiation. + NegotiateFileContractTime = 360 * time.Second // NegotiateMaxDownloadActionRequestSize defines the maximum size that a // download request can be. Note, this is not a max size for the data that @@ -100,6 +82,26 @@ const ( // transaction signature slice is allowed to be when being sent over the // wire during negotiation. NegotiateMaxTransactionSignaturesSize = 5e3 + + // NegotiateRecentRevisionTime establishes the minimum amount of time that + // the connection deadline is expected to be set to when a recent file + // contract revision is being requested from the host. The deadline is long + // enough that the connection should be successful even if both parties are + // running Tor. + NegotiateRecentRevisionTime = 120 * time.Second + + // NegotiateRenewContractTime defines the minimum amount of time that the + // renter and host have to negotiate a final contract renewal. The time is + // high enough that the negotiation can occur over a Tor connection, and + // that both the host and the renter can have time to process large Merkle + // tree calculations that may be involved with renewing a file contract. + NegotiateRenewContractTime = 600 * time.Second + + // NegotiateSettingsTime establishes the minimum amount of time that the + // connection deadline is expected to be set to when settings are being + // requested from the host. The deadline is long enough that the connection + // should be successful even if both parties are on Tor. + NegotiateSettingsTime = 120 * time.Second ) var ( diff --git a/modules/renter/persist.go b/modules/renter/persist.go index f5b52ecc91..87ff062653 100644 --- a/modules/renter/persist.go +++ b/modules/renter/persist.go @@ -18,9 +18,9 @@ import ( ) const ( + logFile = modules.RenterDir + ".log" PersistFilename = "renter.json" ShareExtension = ".sia" - logFile = modules.RenterDir + ".log" ) var ( diff --git a/modules/transactionpool.go b/modules/transactionpool.go index 52b68b43e3..358718ffc5 100644 --- a/modules/transactionpool.go +++ b/modules/transactionpool.go @@ -9,14 +9,14 @@ import ( ) const ( + // TransactionSetSizeLimit defines the largest set of dependent unconfirmed + // transactions that will be accepted by the transaction pool. + TransactionSetSizeLimit = 250e3 + // TransactionSizeLimit defines the size of the largest transaction that // will be accepted by the transaction pool according to the IsStandard // rules. TransactionSizeLimit = 32e3 - - // TransactionSetSizeLimit defines the largest set of dependent unconfirmed - // transactions that will be accepted by the transaction pool. - TransactionSetSizeLimit = 250e3 ) var ( diff --git a/modules/transactionpool/consts.go b/modules/transactionpool/consts.go index d16bebb472..4c36f0143d 100644 --- a/modules/transactionpool/consts.go +++ b/modules/transactionpool/consts.go @@ -28,15 +28,15 @@ const ( // default size during times of congestion. TransactionPoolExponentiation = 3 - // TransactionPoolSizeTarget defines the target size of the pool when the - // transactions are paying 1 SC / kb in fees. - TransactionPoolSizeTarget = 3e6 - // TransactionPoolSizeForFee defines how large the transaction pool needs to // be before it starts expecting fees to be on the transaction. This initial // limit is to help the network grow and provide some wiggle room for // wallets that are not yet able to operate via a fee market. TransactionPoolSizeForFee = 500e3 + + // TransactionPoolSizeTarget defines the target size of the pool when the + // transactions are paying 1 SC / kb in fees. + TransactionPoolSizeTarget = 3e6 ) // Constants related to fee estimation. diff --git a/modules/wallet.go b/modules/wallet.go index 9ae6f27b26..c1f059e379 100644 --- a/modules/wallet.go +++ b/modules/wallet.go @@ -11,16 +11,16 @@ import ( ) const ( - // WalletDir is the directory that contains the wallet persistence. - WalletDir = "wallet" + // PublicKeysPerSeed define the number of public keys that get pregenerated + // for a seed at startup when searching for balances in the blockchain. + PublicKeysPerSeed = 2500 // SeedChecksumSize is the number of bytes that are used to checksum // addresses to prevent accidental spending. SeedChecksumSize = 6 - // PublicKeysPerSeed define the number of public keys that get pregenerated - // for a seed at startup when searching for balances in the blockchain. - PublicKeysPerSeed = 2500 + // WalletDir is the directory that contains the wallet persistence. + WalletDir = "wallet" ) var ( diff --git a/modules/wallet/consts.go b/modules/wallet/consts.go index 4bc9053d2c..61ec35202e 100644 --- a/modules/wallet/consts.go +++ b/modules/wallet/consts.go @@ -5,16 +5,16 @@ import ( ) const ( - // defragThreshold is the number of outputs a wallet is allowed before it is - // defragmented. - defragThreshold = 50 - // defragBatchSize defines how many outputs are combined during one defrag. defragBatchSize = 35 // defragStartIndex is the number of outputs to skip over when performing a // defrag. defragStartIndex = 10 + + // defragThreshold is the number of outputs a wallet is allowed before it is + // defragmented. + defragThreshold = 50 ) var ( diff --git a/modules/wallet/persist.go b/modules/wallet/persist.go index 7cd929a936..2c6d303990 100644 --- a/modules/wallet/persist.go +++ b/modules/wallet/persist.go @@ -17,9 +17,9 @@ import ( ) const ( - logFile = modules.WalletDir + ".log" - dbFile = modules.WalletDir + ".db" compatFile = modules.WalletDir + ".json" + dbFile = modules.WalletDir + ".db" + logFile = modules.WalletDir + ".log" ) var ( diff --git a/modules/wallet/unseeded.go b/modules/wallet/unseeded.go index 4a61b678ba..c061ca98e1 100644 --- a/modules/wallet/unseeded.go +++ b/modules/wallet/unseeded.go @@ -11,12 +11,14 @@ import ( ) const ( + SiagFileExtension = ".siakey" + // The header for all siag files. Do not change. Because siag was created // early in development, compatibility with siag requires manually handling // the headers and version instead of using the persist package. - SiagFileHeader = "siag" - SiagFileExtension = ".siakey" - SiagFileVersion = "1.0" + SiagFileHeader = "siag" + + SiagFileVersion = "1.0" ) var ( diff --git a/sync/tryrwmutex.go b/sync/tryrwmutex.go index 14cd0f6b9d..4deeae6dd4 100644 --- a/sync/tryrwmutex.go +++ b/sync/tryrwmutex.go @@ -8,10 +8,9 @@ import ( const ( readOffset = uint64(1) - writeOffset = uint64(1 << 20) + tryMask = uint64(1099511627775) // equivalent to setting the first 39 bits to '1'. tryOffset = uint64(1 << 40) - - tryMask = uint64(1099511627775) // equivalent to setting the first 39 bits to '1'. + writeOffset = uint64(1 << 20) ) // TryRWMutex allows you to try to grab a RWMutex, failing if the mutex is