Add options to control block creation settings.
This commit adds three new options which are intended to to be used by the upcoming mining-related block template creation code.
This commit is contained in:
parent
5e517a9116
commit
ed45b717e0
2 changed files with 54 additions and 31 deletions
28
config.go
28
config.go
|
@ -38,6 +38,11 @@ const (
|
||||||
defaultVerifyEnabled = false
|
defaultVerifyEnabled = false
|
||||||
defaultDbType = "leveldb"
|
defaultDbType = "leveldb"
|
||||||
defaultFreeTxRelayLimit = 15.0
|
defaultFreeTxRelayLimit = 15.0
|
||||||
|
defaultBlockMinSize = 0
|
||||||
|
defaultBlockMaxSize = 750000
|
||||||
|
blockMaxSizeMin = 1000
|
||||||
|
blockMaxSizeMax = btcwire.MaxBlockPayload - 1000
|
||||||
|
defaultBlockPrioritySize = 50000
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -95,6 +100,9 @@ type config struct {
|
||||||
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
||||||
Upnp bool `long:"upnp" description:"Use UPnP to map our listening port outside of NAT"`
|
Upnp bool `long:"upnp" description:"Use UPnP to map our listening port outside of NAT"`
|
||||||
FreeTxRelayLimit float64 `long:"limitfreerelay" description:"Limit relay of transactions with no transaction fee to the given amount in thousands of bytes per minute"`
|
FreeTxRelayLimit float64 `long:"limitfreerelay" description:"Limit relay of transactions with no transaction fee to the given amount in thousands of bytes per minute"`
|
||||||
|
BlockMinSize uint32 `long:"blockminsize" description:"Mininum block size in bytes to be used when creating a block"`
|
||||||
|
BlockMaxSize uint32 `long:"blockmaxsize" description:"Maximum block size in bytes to be used when creating a block"`
|
||||||
|
BlockPrioritySize uint32 `long:"blockprioritysize" description:"Size in bytes for high-priority/low-fee transactions when creating a block"`
|
||||||
onionlookup func(string) ([]net.IP, error)
|
onionlookup func(string) ([]net.IP, error)
|
||||||
lookup func(string) ([]net.IP, error)
|
lookup func(string) ([]net.IP, error)
|
||||||
oniondial func(string, string) (net.Conn, error)
|
oniondial func(string, string) (net.Conn, error)
|
||||||
|
@ -296,6 +304,9 @@ func loadConfig() (*config, []string, error) {
|
||||||
RPCKey: defaultRPCKeyFile,
|
RPCKey: defaultRPCKeyFile,
|
||||||
RPCCert: defaultRPCCertFile,
|
RPCCert: defaultRPCCertFile,
|
||||||
FreeTxRelayLimit: defaultFreeTxRelayLimit,
|
FreeTxRelayLimit: defaultFreeTxRelayLimit,
|
||||||
|
BlockMinSize: defaultBlockMinSize,
|
||||||
|
BlockMaxSize: defaultBlockMaxSize,
|
||||||
|
BlockPrioritySize: defaultBlockPrioritySize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Service options which are only added on Windows.
|
// Service options which are only added on Windows.
|
||||||
|
@ -493,6 +504,23 @@ func loadConfig() (*config, []string, error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Limit the max block size to a sane value.
|
||||||
|
if cfg.BlockMaxSize < blockMaxSizeMin || cfg.BlockMaxSize >
|
||||||
|
blockMaxSizeMax {
|
||||||
|
|
||||||
|
str := "%s: The blockmaxsize option must be in between %d " +
|
||||||
|
"and %d -- parsed [%d]"
|
||||||
|
err := fmt.Errorf(str, "loadConfig", blockMaxSizeMin,
|
||||||
|
blockMaxSizeMax, cfg.BlockMaxSize)
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
parser.WriteHelp(os.Stderr)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the block priority and minimum block sizes to max block size.
|
||||||
|
cfg.BlockPrioritySize = minUint32(cfg.BlockPrioritySize, cfg.BlockMaxSize)
|
||||||
|
cfg.BlockMinSize = minUint32(cfg.BlockMinSize, cfg.BlockMaxSize)
|
||||||
|
|
||||||
// Add default port to all listener addresses if needed and remove
|
// Add default port to all listener addresses if needed and remove
|
||||||
// duplicate addresses.
|
// duplicate addresses.
|
||||||
cfg.Listeners = normalizeAddresses(cfg.Listeners,
|
cfg.Listeners = normalizeAddresses(cfg.Listeners,
|
||||||
|
|
|
@ -71,11 +71,6 @@ const (
|
||||||
// base for calculating minimum required fees for larger transactions.
|
// base for calculating minimum required fees for larger transactions.
|
||||||
// This value is in Satoshi/KB (kilobyte, not kibibyte).
|
// This value is in Satoshi/KB (kilobyte, not kibibyte).
|
||||||
minTxRelayFee = 1000
|
minTxRelayFee = 1000
|
||||||
|
|
||||||
// blockPrioritySize is the number of bytes reserved in a block for
|
|
||||||
// high-priority transactions. It is mainly used to help determine the
|
|
||||||
// minimum required fee for a transaction.
|
|
||||||
blockPrioritySize = 50000
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TxDesc is a descriptor containing a transaction in the mempool and the
|
// TxDesc is a descriptor containing a transaction in the mempool and the
|
||||||
|
@ -378,7 +373,7 @@ func calcMinRelayFee(tx *btcutil.Tx) int64 {
|
||||||
// transaction does not exceeed 1000 less than the reserved space for
|
// transaction does not exceeed 1000 less than the reserved space for
|
||||||
// high-priority transactions, don't require a fee for it.
|
// high-priority transactions, don't require a fee for it.
|
||||||
serializedLen := int64(tx.MsgTx().SerializeSize())
|
serializedLen := int64(tx.MsgTx().SerializeSize())
|
||||||
if serializedLen < (blockPrioritySize - 1000) {
|
if serializedLen < (defaultBlockPrioritySize - 1000) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue