Skip to content

Commit

Permalink
sort and regroup constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Nagaev committed Oct 3, 2017
1 parent f7b7757 commit c6c5ce2
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 74 deletions.
6 changes: 3 additions & 3 deletions build/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions modules/gateway/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions modules/gateway/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions modules/host/contractmanager/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion modules/host/persist_compat_1.2.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
5 changes: 2 additions & 3 deletions modules/miner/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
52 changes: 27 additions & 25 deletions modules/negotiate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion modules/renter/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
)

const (
logFile = modules.RenterDir + ".log"
PersistFilename = "renter.json"
ShareExtension = ".sia"
logFile = modules.RenterDir + ".log"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions modules/transactionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 4 additions & 4 deletions modules/transactionpool/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions modules/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 4 additions & 4 deletions modules/wallet/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions modules/wallet/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 5 additions & 3 deletions modules/wallet/unseeded.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
5 changes: 2 additions & 3 deletions sync/tryrwmutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c6c5ce2

Please sign in to comment.