-
Notifications
You must be signed in to change notification settings - Fork 34
/
consensus.go
50 lines (38 loc) · 1.57 KB
/
consensus.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package consensus
import "errors"
const (
//OneMegaByte 1MB
OneMegaByte = 1000000
//MaxTxSize The maximum allowed size for a transaction, in bytes
MaxTxSize = OneMegaByte
//LegacyMaxBlockSize The maximum allowed size for a block, before the UAHF
LegacyMaxBlockSize = OneMegaByte
//DefaultMaxBlockSize Default setting for maximum allowed size for a block, in bytes
DefaultMaxBlockSize = 32 * OneMegaByte
/*MaxBlockSigopsPerMb The maximum allowed number of signature check operations per MB in a block
* (network rule) */
MaxBlockSigopsPerMb = 20000
/*MaxTxSigOpsCount allowed number of signature check operations per transaction. */
MaxTxSigOpsCount = 20000
// CoinbaseMaturity means Coinbase transaction outputs can only be spent after this number of new
// blocks (network rule)
CoinbaseMaturity = 100
MinTxSize = 100
)
const (
// LocktimeVerifySequence , Interpret sequence numbers as relative lock-time constraints.
LocktimeVerifySequence = 1 << iota
// LocktimeMedianTimePast , Use GetMedianTimePast() instead of nTime for end point timestamp.
LocktimeMedianTimePast
)
// GetMaxBlockSigOpsCount Compute the maximum number of sigops operation that can contained in a block
// given the block size as parameter. It is computed by multiplying
// MAX_BLOCK_SIGOPS_PER_MB by the size of the block in MB rounded up to the
// closest integer.
func GetMaxBlockSigOpsCount(blockSize uint64) (uint64, error) {
if blockSize < 1 {
return 0, errors.New("block size is wrong")
}
roundedUp := 1 + ((blockSize - 1) / OneMegaByte)
return roundedUp * MaxBlockSigopsPerMb, nil
}