Ori Newman aeb4b96560
[NOD-1451] Implement Validators (#966)
* [NOD-1451] Implement block validator

* [NOD-1451] Implement block validator

* [NOD-1451] Fix merge errors

* [NOD-1451] Implement block validator

* [NOD-1451] Implement checkTransactionInIsolation

* [NOD-1451] Copy txscript to validator

* [NOD-1451] Change txscript to new design

* [NOD-1451] Add checkTransactionInContext

* [NOD-1451] Add checkBlockSize

* [NOD-1451] Add error handling

* [NOD-1451] Implement checkTransactionInContext

* [NOD-1451] Add checkTransactionMass placeholder

* [NOD-1451] Finish validators

* [NOD-1451] Add comments and stringers

* [NOD-1451] Return model.TransactionValidator interface

* [NOD-1451] Premake rule errors for each "code"

* [NOD-1451] Populate transaction mass

* [NOD-1451] Renmae functions

* [NOD-1451] Always use skipPow=false

* [NOD-1451] Renames

* [NOD-1451] Remove redundant types from WriteElement

* [NOD-1451] Fix error message

* [NOD-1451] Add checkTransactionPayload

* [NOD-1451] Add ValidateProofOfWorkAndDifficulty to block validator interface

* [NOD-1451] Move stringers to model

* [NOD-1451] Fix error message
2020-10-26 17:33:39 +02:00

28 lines
1.1 KiB
Go

package subnetworks
import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
var (
// SubnetworkIDNative is the default subnetwork ID which is used for transactions without related payload data
SubnetworkIDNative = externalapi.DomainSubnetworkID{}
// SubnetworkIDCoinbase is the subnetwork ID which is used for the coinbase transaction
SubnetworkIDCoinbase = externalapi.DomainSubnetworkID{1}
// SubnetworkIDRegistry is the subnetwork ID which is used for adding new sub networks to the registry
SubnetworkIDRegistry = externalapi.DomainSubnetworkID{2}
)
// IsBuiltIn returns true if the subnetwork is a built in subnetwork, which
// means all nodes, including partial nodes, must validate it, and its transactions
// always use 0 gas.
func IsBuiltIn(id externalapi.DomainSubnetworkID) bool {
return id == SubnetworkIDCoinbase || id == SubnetworkIDRegistry
}
// IsBuiltInOrNative returns true if the subnetwork is the native or a built in subnetwork,
// see IsBuiltIn for further details
func IsBuiltInOrNative(id externalapi.DomainSubnetworkID) bool {
return id == SubnetworkIDNative || IsBuiltIn(id)
}