Commit 20b66718 authored by Boris Nagaev's avatar Boris Nagaev

sort and regroup variables

parent c6c5ce2d
......@@ -15,10 +15,10 @@ import (
var (
errDoSBlock = errors.New("block is known to be invalid")
errNoBlockMap = errors.New("block map is not in database")
errInconsistentSet = errors.New("consensus set is not in a consistent state")
errOrphan = errors.New("block has no known parent")
errNoBlockMap = errors.New("block map is not in database")
errNonLinearChain = errors.New("block set is not a contiguous chain")
errOrphan = errors.New("block has no known parent")
)
// managedBroadcastBlock will broadcast a block to the consensus set's peers.
......
......@@ -18,7 +18,9 @@ import (
var (
prefixDSCO = []byte("dsco_")
prefixFCEX = []byte("fcex_")
)
var (
// BlockHeight is a bucket that stores the current block height.
//
// Generally we would just look at BlockPath.Stats(), but there is an error
......@@ -52,14 +54,14 @@ var (
// inconsistencies within the database have been detected.
Consistency = []byte("Consistency")
// SiacoinOutputs is a database bucket that contains all of the unspent
// siacoin outputs.
SiacoinOutputs = []byte("SiacoinOutputs")
// FileContracts is a database bucket that contains all of the open file
// contracts.
FileContracts = []byte("FileContracts")
// SiacoinOutputs is a database bucket that contains all of the unspent
// siacoin outputs.
SiacoinOutputs = []byte("SiacoinOutputs")
// SiafundOutputs is a database bucket that contains all of the unspent
// siafund outputs.
SiafundOutputs = []byte("SiafundOutputs")
......
......@@ -16,16 +16,16 @@ import (
)
var (
errRepeatInsert = errors.New("attempting to add an already existing item to the consensus set")
errNilBucket = errors.New("using a bucket that does not exist")
errNilItem = errors.New("requested item does not exist")
errDBInconsistent = errors.New("database guard indicates inconsistency within database")
errNonEmptyBucket = errors.New("cannot remove a map with objects still in it")
dbMetadata = persist.Metadata{
Header: "Consensus Set Database",
Version: "0.5.0",
}
errDBInconsistent = errors.New("database guard indicates inconsistency within database")
errNilBucket = errors.New("using a bucket that does not exist")
errNilItem = errors.New("requested item does not exist")
errNonEmptyBucket = errors.New("cannot remove a map with objects still in it")
errRepeatInsert = errors.New("attempting to add an already existing item to the consensus set")
)
type (
......
......@@ -22,6 +22,19 @@ const (
)
var (
errEarlyStop = errors.New("initial blockchain download did not complete by the time shutdown was issued")
errNilProcBlock = errors.New("nil processed block was fetched from the database")
errSendBlocksStalled = errors.New("SendBlocks RPC timed and never received any blocks")
// ibdLoopDelay is the time that threadedInitialBlockchainDownload waits
// between attempts to synchronize with the network if the last attempt
// failed.
ibdLoopDelay = build.Select(build.Var{
Standard: 10 * time.Second,
Dev: 1 * time.Second,
Testing: 100 * time.Millisecond,
}).(time.Duration)
// MaxCatchUpBlocks is the maxiumum number of blocks that can be given to
// the consensus set in a single iteration during the initial blockchain
// download.
......@@ -31,27 +44,6 @@ var (
Testing: types.BlockHeight(3),
}).(types.BlockHeight)
// sendBlocksTimeout is the timeout for the SendBlocks RPC.
sendBlocksTimeout = build.Select(build.Var{
Standard: 5 * time.Minute,
Dev: 40 * time.Second,
Testing: 5 * time.Second,
}).(time.Duration)
// sendBlkTimeout is the timeout for the SendBlocks RPC.
sendBlkTimeout = build.Select(build.Var{
Standard: 4 * time.Minute,
Dev: 30 * time.Second,
Testing: 4 * time.Second,
}).(time.Duration)
// relayHeaderTimeout is the timeout for the RelayHeader RPC.
relayHeaderTimeout = build.Select(build.Var{
Standard: 3 * time.Minute,
Dev: 20 * time.Second,
Testing: 3 * time.Second,
}).(time.Duration)
// minIBDWaitTime is the time threadedInitialBlockchainDownload waits before
// exiting if there are >= 1 and <= minNumOutbound peers synced. This timeout
// will primarily affect miners who have multiple nodes daisy chained off each
......@@ -63,18 +55,26 @@ var (
Testing: 10 * time.Second,
}).(time.Duration)
// ibdLoopDelay is the time that threadedInitialBlockchainDownload waits
// between attempts to synchronize with the network if the last attempt
// failed.
ibdLoopDelay = build.Select(build.Var{
Standard: 10 * time.Second,
Dev: 1 * time.Second,
Testing: 100 * time.Millisecond,
// relayHeaderTimeout is the timeout for the RelayHeader RPC.
relayHeaderTimeout = build.Select(build.Var{
Standard: 3 * time.Minute,
Dev: 20 * time.Second,
Testing: 3 * time.Second,
}).(time.Duration)
errEarlyStop = errors.New("initial blockchain download did not complete by the time shutdown was issued")
errNilProcBlock = errors.New("nil processed block was fetched from the database")
errSendBlocksStalled = errors.New("SendBlocks RPC timed and never received any blocks")
// sendBlkTimeout is the timeout for the SendBlocks RPC.
sendBlkTimeout = build.Select(build.Var{
Standard: 4 * time.Minute,
Dev: 30 * time.Second,
Testing: 4 * time.Second,
}).(time.Duration)
// sendBlocksTimeout is the timeout for the SendBlocks RPC.
sendBlocksTimeout = build.Select(build.Var{
Standard: 5 * time.Minute,
Dev: 40 * time.Second,
Testing: 5 * time.Second,
}).(time.Duration)
)
// isTimeoutErr is a helper function that returns true if err was caused by a
......
......@@ -10,8 +10,6 @@ import (
)
var (
errNotExist = errors.New("entry does not exist")
// database buckets
bucketBlockFacts = []byte("BlockFacts")
bucketBlockIDs = []byte("BlockIDs")
......@@ -19,15 +17,16 @@ var (
bucketBlockTargets = []byte("BlockTargets")
bucketFileContractHistories = []byte("FileContractHistories")
bucketFileContractIDs = []byte("FileContractIDs")
bucketSiacoinOutputIDs = []byte("SiacoinOutputIDs")
bucketSiacoinOutputs = []byte("SiacoinOutputs")
bucketSiafundOutputIDs = []byte("SiafundOutputIDs")
bucketSiafundOutputs = []byte("SiafundOutputs")
bucketTransactionIDs = []byte("TransactionIDs")
bucketUnlockHashes = []byte("UnlockHashes")
// bucketInternal is used to store values internal to the explorer
bucketInternal = []byte("Internal")
bucketInternal = []byte("Internal")
bucketSiacoinOutputIDs = []byte("SiacoinOutputIDs")
bucketSiacoinOutputs = []byte("SiacoinOutputs")
bucketSiafundOutputIDs = []byte("SiafundOutputIDs")
bucketSiafundOutputs = []byte("SiafundOutputs")
bucketTransactionIDs = []byte("TransactionIDs")
bucketUnlockHashes = []byte("UnlockHashes")
errNotExist = errors.New("entry does not exist")
// keys for bucketInternal
internalBlockHeight = []byte("BlockHeight")
......
......@@ -68,14 +68,6 @@ var (
Testing: uint64(3),
}).(uint64)
// nodePurgeDelay defines the amount of time that is waited between each
// iteration of the node purge loop.
nodePurgeDelay = build.Select(build.Var{
Standard: 10 * time.Minute,
Dev: 20 * time.Second,
Testing: 500 * time.Millisecond,
}).(time.Duration)
// nodeListDelay defines the amount of time that is waited between each
// iteration of the node list loop.
nodeListDelay = build.Select(build.Var{
......@@ -84,6 +76,14 @@ var (
Testing: 500 * time.Millisecond,
}).(time.Duration)
// nodePurgeDelay defines the amount of time that is waited between each
// iteration of the node purge loop.
nodePurgeDelay = build.Select(build.Var{
Standard: 10 * time.Minute,
Dev: 20 * time.Second,
Testing: 500 * time.Millisecond,
}).(time.Duration)
// peerRPCDelay defines the amount of time waited between each RPC accepted
// from a peer. Without this delay, a peer can force us to spin up thousands
// of goroutines per second.
......
......@@ -10,11 +10,25 @@ const (
)
var (
// BlockBytesPerMonthTerabyte is the conversion rate between block-bytes and month-TB.
BlockBytesPerMonthTerabyte = BytesPerTerabyte.Mul64(4320)
// BytesPerTerabyte is the conversion rate between bytes and terabytes.
BytesPerTerabyte = types.NewCurrency64(1e12)
// BlockBytesPerMonthTerabyte is the conversion rate between block-bytes and month-TB.
BlockBytesPerMonthTerabyte = BytesPerTerabyte.Mul64(4320)
// HostConnectabilityStatusChecking is returned from ConnectabilityStatus()
// if the host is still determining if it is connectable.
HostConnectabilityStatusChecking = HostConnectabilityStatus("checking")
// HostConnectabilityStatusConnectable is returned from
// ConnectabilityStatus() if the host is connectable at its configured
// netaddress.
HostConnectabilityStatusConnectable = HostConnectabilityStatus("connectable")
// HostConnectabilityStatusNotConnectable is returned from
// ConnectabilityStatus() if the host is not connectable at its configured
// netaddress.
HostConnectabilityStatusNotConnectable = HostConnectabilityStatus("not connectable")
// HostWorkingStatusChecking is returned from WorkingStatus() if the host is
// still determining if it is working, that is, if settings calls are
......@@ -30,20 +44,6 @@ var (
// received more than workingThreshold settings calls over the duration of
// workingStatusFrequency.
HostWorkingStatusWorking = HostWorkingStatus("working")
// HostConnectabilityStatusChecking is returned from ConnectabilityStatus()
// if the host is still determining if it is connectable.
HostConnectabilityStatusChecking = HostConnectabilityStatus("checking")
// HostConnectabilityStatusConnectable is returned from
// ConnectabilityStatus() if the host is connectable at its configured
// netaddress.
HostConnectabilityStatusConnectable = HostConnectabilityStatus("connectable")
// HostConnectabilityStatusNotConnectable is returned from
// ConnectabilityStatus() if the host is not connectable at its configured
// netaddress.
HostConnectabilityStatusNotConnectable = HostConnectabilityStatus("not connectable")
)
type (
......
......@@ -34,6 +34,30 @@ const (
)
var (
// connectablityCheckFirstWait defines how often the host's connectability
// check is run.
connectabilityCheckFirstWait = build.Select(build.Var{
Standard: time.Minute * 2,
Dev: time.Minute * 1,
Testing: time.Second * 3,
}).(time.Duration)
// connectablityCheckFrequency defines how often the host's connectability
// check is run.
connectabilityCheckFrequency = build.Select(build.Var{
Standard: time.Minute * 10,
Dev: time.Minute * 5,
Testing: time.Second * 10,
}).(time.Duration)
// connectabilityCheckTimeout defines how long a connectability check's dial
// will be allowed to block before it times out.
connectabilityCheckTimeout = build.Select(build.Var{
Standard: time.Minute * 2,
Dev: time.Minute * 5,
Testing: time.Second * 90,
}).(time.Duration)
// defaultCollateral defines the amount of money that the host puts up as
// collateral per-byte by default. The collateral should be considered as
// an absolute instead of as a percentage, because low prices result in
......@@ -64,6 +88,14 @@ var (
// download bandwidth is expected to be plentiful but also in-demand.
defaultDownloadBandwidthPrice = types.SiacoinPrecision.Mul64(25).Div(modules.BytesPerTerabyte) // 25 SC / TB
// defaultMaxCollateral defines the maximum amount of collateral that the
// host is comfortable putting into a single file contract. 10e3 is a
// relatively small file contract, but millions of siacoins could be locked
// away by only a few hundred file contracts. As the ecosystem matures, it
// is expected that the safe default for this value will increase quite a
// bit.
defaultMaxCollateral = types.SiacoinPrecision.Mul64(5e3)
// defaultMaxDownloadBatchSize defines the maximum number of bytes that the
// host will allow to be requested by a single download request. 17 MiB has
// been chosen because it's 4 full sectors plus some wiggle room. 17 MiB is
......@@ -83,14 +115,6 @@ var (
// with a number like 65 MiB.
defaultMaxReviseBatchSize = 17 * (1 << 20)
// defaultMaxCollateral defines the maximum amount of collateral that the
// host is comfortable putting into a single file contract. 10e3 is a
// relatively small file contract, but millions of siacoins could be locked
// away by only a few hundred file contracts. As the ecosystem matures, it
// is expected that the safe default for this value will increase quite a
// bit.
defaultMaxCollateral = types.SiacoinPrecision.Mul64(5e3)
// defaultStoragePrice defines the starting price for hosts selling
// storage. We try to match a number that is both reasonably profitable and
// reasonably competitive.
......@@ -104,54 +128,6 @@ var (
// data.
defaultUploadBandwidthPrice = types.SiacoinPrecision.Mul64(1).Div(modules.BytesPerTerabyte) // 1 SC / TB
// workingStatusFirstCheck defines how frequently the Host's working status
// check runs
workingStatusFirstCheck = build.Select(build.Var{
Standard: time.Minute * 3,
Dev: time.Minute * 1,
Testing: time.Second * 3,
}).(time.Duration)
// workingStatusFrequency defines how frequently the Host's working status
// check runs
workingStatusFrequency = build.Select(build.Var{
Standard: time.Minute * 10,
Dev: time.Minute * 5,
Testing: time.Second * 10,
}).(time.Duration)
// workingStatusThreshold defines how many settings calls must occur over the
// workingStatusFrequency for the host to be considered working.
workingStatusThreshold = build.Select(build.Var{
Standard: uint64(3),
Dev: uint64(1),
Testing: uint64(1),
}).(uint64)
// connectablityCheckFirstWait defines how often the host's connectability
// check is run.
connectabilityCheckFirstWait = build.Select(build.Var{
Standard: time.Minute * 2,
Dev: time.Minute * 1,
Testing: time.Second * 3,
}).(time.Duration)
// connectablityCheckFrequency defines how often the host's connectability
// check is run.
connectabilityCheckFrequency = build.Select(build.Var{
Standard: time.Minute * 10,
Dev: time.Minute * 5,
Testing: time.Second * 10,
}).(time.Duration)
// connectabilityCheckTimeout defines how long a connectability check's dial
// will be allowed to block before it times out.
connectabilityCheckTimeout = build.Select(build.Var{
Standard: time.Minute * 2,
Dev: time.Minute * 5,
Testing: time.Second * 90,
}).(time.Duration)
// defaultWindowSize is the size of the proof of storage window requested
// by the host. The host will not delete any obligations until the window
// has closed and buried under several confirmations. For release builds,
......@@ -220,6 +196,30 @@ var (
Standard: time.Millisecond * 50,
Testing: time.Millisecond,
}).(time.Duration)
// workingStatusFirstCheck defines how frequently the Host's working status
// check runs
workingStatusFirstCheck = build.Select(build.Var{
Standard: time.Minute * 3,
Dev: time.Minute * 1,
Testing: time.Second * 3,
}).(time.Duration)
// workingStatusFrequency defines how frequently the Host's working status
// check runs
workingStatusFrequency = build.Select(build.Var{
Standard: time.Minute * 10,
Dev: time.Minute * 5,
Testing: time.Second * 10,
}).(time.Duration)
// workingStatusThreshold defines how many settings calls must occur over the
// workingStatusFrequency for the host to be considered working.
workingStatusThreshold = build.Select(build.Var{
Standard: uint64(3),
Dev: uint64(1),
Testing: uint64(1),
}).(uint64)
)
// All of the following variables define the names of buckets used by the host
......
......@@ -83,14 +83,6 @@ var (
)
var (
// maximumStorageFolders defines the maximum number of storage folders that
// the host can support.
maximumStorageFolders = build.Select(build.Var{
Dev: uint64(1 << 5),
Standard: uint64(1 << 16),
Testing: uint64(1 << 3),
}).(uint64)
// MaximumSectorsPerStorageFolder sets an upper bound on how large storage
// folders in the host are allowed to be. There is a hard limit at 4
// billion sectors because the sector location map only uses 4 bytes to
......@@ -101,6 +93,14 @@ var (
Testing: uint64(1 << 12), // 16 MiB
}).(uint64)
// maximumStorageFolders defines the maximum number of storage folders that
// the host can support.
maximumStorageFolders = build.Select(build.Var{
Dev: uint64(1 << 5),
Standard: uint64(1 << 16),
Testing: uint64(1 << 3),
}).(uint64)
// MinimumSectorsPerStorageFolder defines the minimum number of sectors
// that a storage folder is allowed to have.
MinimumSectorsPerStorageFolder = build.Select(build.Var{
......
......@@ -52,6 +52,9 @@ var (
// that is the same as the current size of the storage folder.
ErrNoResize = errors.New("storage folder selected for resize, but new size is same as current size")
// errRelativePath is returned if a path must be absolute.
errRelativePath = errors.New("storage folder paths must be absolute")
// ErrRepeatFolder is returned if a storage folder is added which links to
// a path that is already in use by another storage folder. Only exact path
// matches will trigger the error.
......@@ -73,9 +76,6 @@ var (
// errStorageFolderNotFound is returned if a storage folder cannot be
// found.
errStorageFolderNotFound = errors.New("could not find storage folder with that id")
// errRelativePath is returned if a path must be absolute.
errRelativePath = errors.New("storage folder paths must be absolute")
)
// storageFolder contains the metadata for a storage folder, including where
......
......@@ -94,13 +94,6 @@ var (
Version: "0.5.2",
}
// persistMetadata is the header that gets written to the persist file, and is
// used to recognize other persist files.
persistMetadata = persist.Metadata{
Header: "Sia Host",
Version: "1.2.0",
}
// errHostClosed gets returned when a call is rejected due to the host
// having been closed.
errHostClosed = errors.New("call is disabled because the host is closed")
......@@ -109,6 +102,13 @@ var (
errNilCS = errors.New("host cannot use a nil state")
errNilTpool = errors.New("host cannot use a nil transaction pool")
errNilWallet = errors.New("host cannot use a nil wallet")
// persistMetadata is the header that gets written to the persist file, and is
// used to recognize other persist files.
persistMetadata = persist.Metadata{
Header: "Sia Host",
Version: "1.2.0",
}
)
// A Host contains all the fields necessary for storing files for clients and
......
......@@ -104,10 +104,6 @@ var (
// settings.
errLongDuration = ErrorCommunication("renter proposed a file contract with a too-long duration")
// errLowTransactionFees is returned if the renter provides a transaction
// that the host does not feel is able to make it onto the blockchain.
errLowTransactionFees = ErrorCommunication("rejected for including too few transaction fees")
// errLowHostMissedOutput is returned if the renter incorrectly updates the
// host missed proof output during a file contract revision.
errLowHostMissedOutput = ErrorCommunication("rejected for low paying host missed output")
......@@ -116,6 +112,10 @@ var (
// host valid proof output during a file contract revision.
errLowHostValidOutput = ErrorCommunication("rejected for low paying host valid output")
// errLowTransactionFees is returned if the renter provides a transaction
// that the host does not feel is able to make it onto the blockchain.
errLowTransactionFees = ErrorCommunication("rejected for including too few transaction fees")
// errLowVoidOutput is returned if the renter has not allocated enough
// funds to the void output.
errLowVoidOutput = ErrorCommunication("rejected for low value void output")
......
......@@ -89,10 +89,6 @@ var (
// inputs.
errInsaneStorageObligationRevisionData = errors.New("revision to storage obligation has insane data")
// errObligationUnlocked is returned when a storage obligation is being
// removed from lock, but is already unlocked.
errObligationUnlocked = errors.New("storage obligation is unlocked, and should not be getting unlocked")
// errNoBuffer is returned if there is an attempted storage obligation that
// needs to have the storage proof submitted in less than
// revisionSubmissionBuffer blocks.
......@@ -101,6 +97,10 @@ var (
// errNoStorageObligation is returned if the requested storage obligation
// is not found in the database.
errNoStorageObligation = errors.New("storage obligation not found in database")
// errObligationUnlocked is returned when a storage obligation is being
// removed from lock, but is already unlocked.
errObligationUnlocked = errors.New("storage obligation is unlocked, and should not be getting unlocked")
)
type storageObligationStatus uint64
......
......@@ -15,6 +15,15 @@ import (
)
var (
// BlockMemory is the maximum number of blocks the miner will store
// Blocks take up to 2 megabytes of memory, which is why this number is
// limited.
BlockMemory = build.Select(build.Var{
Standard: 50,
Dev: 10,
Testing: 5,
}).(int)
errNilCS = errors.New("miner cannot use a nil consensus set")
errNilTpool = errors.New("miner cannot use a nil transaction pool")
errNilWallet = errors.New("miner cannot use a nil wallet")
......@@ -30,15 +39,6 @@ var (
Testing: 50,
}).(int)
// BlockMemory is the maximum number of blocks the miner will store
// Blocks take up to 2 megabytes of memory, which is why this number is
// limited.
BlockMemory = build.Select(build.Var{
Standard: 50,
Dev: 10,
Testing: 5,
}).(int)
// MaxSourceBlockAge is the maximum amount of time that is allowed to
// elapse between generating source blocks.
MaxSourceBlockAge = build.Select(build.Var{
......
......@@ -9,9 +9,9 @@ import (
var (
errAllowanceNoHosts = errors.New("hosts must be non-zero")
errAllowanceZeroPeriod = errors.New("period must be non-zero")
errAllowanceWindowSize = errors.New("renew window must be less than period")
errAllowanceNotSynced = errors.New("you must be synced to set an allowance")
errAllowanceWindowSize = errors.New("renew window must be less than period")
errAllowanceZeroPeriod = errors.New("period must be non-zero")
// ErrAllowanceZeroWindow is returned when the caller requests a
// zero-length renewal window. This will happen if the caller sets the
......
......@@ -25,6 +25,11 @@ var (
Testing: 10 * time.Millisecond,
}).(time.Duration)
// minContractFundRenewalThreshold defines the ratio of remaining funds to
// total contract cost below which the contractor will prematurely renew a
// contract.
minContractFundRenewalThreshold = float64(0.03) // 3%
// minHostsForEstimations describes the minimum number of hosts that
// are needed to make broad estimations such as the number of sectors
// that you can store on the network for a given allowance.
......@@ -54,11 +59,6 @@ var (
Standard: 10,
Testing: 1,
}).(int)
// minContractFundRenewalThreshold defines the ratio of remaining funds to
// total contract cost below which the contractor will prematurely renew a
// contract.
minContractFundRenewalThreshold = float64(0.03) // 3%
)
// Constants related to the safety values for when the contractor is forming
......
......@@ -22,8 +22,8 @@ import (
var (
errNilCS = errors.New("cannot create contractor with nil consensus set")
errNilWallet = errors.New("cannot create contractor with nil wallet")
errNilTpool = errors.New("cannot create contractor with nil transaction pool")
errNilWallet = errors.New("cannot create contractor with nil wallet")
// COMPATv1.0.4-lts
// metricsContractID identifies a special contract that contains aggregate
......
......@@ -11,11 +11,11 @@ import (
"github.com/NebulousLabs/Sia/types"
)
var errInvalidEditor = errors.New("editor has been invalidated because its contract is being renewed")
// the contractor will cap host's MaxCollateral setting to this value
var maxUploadCollateral = types.SiacoinPrecision.Mul64(1e3).Div(modules.BlockBytesPerMonthTerabyte) // 1k SC / TB / Month
var errInvalidEditor = errors.New("editor has been invalidated because its contract is being renewed")
// An Editor modifies a Contract by communicating with a host. It uses the
// contract revision protocol to send modification requests to the host.
// Editors are the means by which the renter uploads data to hosts.
......
......@@ -25,9 +25,9 @@ const (
)
var (
errPrevErr = errors.New("download could not be completed due to a previous error")
errInsufficientHosts = errors.New("insufficient hosts to recover file")
errInsufficientPieces = errors.New("couldn't fetch enough pieces to recover data")
errPrevErr = errors.New("download could not be completed due to a previous error")
// maxActiveDownloadPieces determines the maximum number of pieces that are
// allowed to be concurrently downloading. More pieces means more
......
......@@ -15,8 +15,8 @@ import (
var (
ErrEmptyFilename = errors.New("filename must be a nonempty string")
ErrUnknownPath = errors.New("no file known with that path")
ErrPathOverload = errors.New("a file already exists at that location")
ErrUnknownPath = errors.New("no file known with that path")
)
// A file is a single file that has been uploaded to the network. Files are
......
......@@ -12,9 +12,9 @@ import (
)
var (
// errWeightTooHeavy is returned from a SelectRandom() call if a weight that exceeds
// the total weight of the tree is requested.
errWeightTooHeavy = errors.New("requested a too-heavy weight")
// errHostExists is returned if an Insert is called with a public key that
// already exists in the tree.
errHostExists = errors.New("host already exists in the tree")
// errNegativeWeight is returned from an Insert() call if an entry with a
// negative weight is added to the tree. Entries must always have a positive
......@@ -25,13 +25,13 @@ var (
// should always have a non-nil entry, unless they have been Delete()ed.
errNilEntry = errors.New("node has a nil entry")
// errHostExists is returned if an Insert is called with a public key that
// already exists in the tree.
errHostExists = errors.New("host already exists in the tree")
// errNoSuchHost is returned if Remove is called with a public key that does
// not exist in the tree.
errNoSuchHost = errors.New("no host with specified public key")
// errWeightTooHeavy is returned from a SelectRandom() call if a weight that exceeds
// the total weight of the tree is requested.
errWeightTooHeavy = errors.New("requested a too-heavy weight")
)
type (
......
......@@ -14,19 +14,10 @@ var (
// weight to be very large.
baseWeight = types.NewCurrency(new(big.Int).Exp(big.NewInt(10), big.NewInt(80), nil))
// tbMonth is the number of bytes in a terabyte times the number of blocks
// in a month.
tbMonth = uint64(4032) * uint64(1e12)
// collateralExponentiation is the number of times that the collateral is
// multiplied into the price.
collateralExponentiation = 1
// priceDiveNormalization reduces the raw value of the price so that not so
// many digits are needed when operating on the weight. This also allows the
// base weight to be a lot lower.
priceDivNormalization = types.SiacoinPrecision.Div64(10e3).Div64(tbMonth)
// minCollateral is the amount of collateral we weight all hosts as having,
// even if they do not have any collateral. This is to temporarily prop up
// weak / cheap hosts on the network while the network is bootstrapping.
......@@ -41,6 +32,11 @@ var (
// of storage changes, and as the price of the siacoin changes.
minTotalPrice = types.SiacoinPrecision.Mul64(25).Div64(tbMonth)
// priceDiveNormalization reduces the raw value of the price so that not so
// many digits are needed when operating on the weight. This also allows the
// base weight to be a lot lower.
priceDivNormalization = types.SiacoinPrecision.Div64(10e3).Div64(tbMonth)
// priceExponentiation is the number of times that the weight is divided by
// the price.
priceExponentiation = 5
......@@ -52,6 +48,10 @@ var (
Dev: uint64(1e6),
Testing: uint64(1e3),
}).(uint64)
// tbMonth is the number of bytes in a terabyte times the number of blocks