Documentation ¶
Index ¶
- Constants
- Variables
- func ValidatorFromAddress(a module.Address) (module.Validator, error)
- func ValidatorFromPublicKey(pk []byte) (module.Validator, error)
- type AccountSnapshot
- type AccountState
- type BlockInfo
- type Contract
- type ContractInfo
- type ContractSnapshot
- type ContractState
- type EEType
- type ExtensionSnapshot
- type ExtensionState
- type LockRequest
- type Platform
- type StepType
- type TransactionInfo
- type ValidatorSnapshot
- type ValidatorState
- type WorldContext
- type WorldSnapshot
- func NewWorldSnapshot(dbase db.Database, stateHash []byte, vs ValidatorSnapshot, ...) WorldSnapshot
- func NewWorldSnapshotWithBuilder(builder merkle.Builder, sh []byte, vh []byte, ess ExtensionSnapshot) (WorldSnapshot, error)
- func NewWorldSnapshotWithNewValidators(dbase db.Database, snapshot WorldSnapshot, vss ValidatorSnapshot) WorldSnapshot
- type WorldState
- type WorldVirtualState
Constants ¶
View Source
const ( AccountVersion1 = iota + 1 AccountVersion2 AccountVersion = AccountVersion1 )
View Source
const ( GIGA = 1000 * 1000 * 1000 TERA = 1000 * GIGA PETA = 1000 * TERA EXA = 1000 * PETA )
TODO Check if everything here is adequate for state package.
View Source
const ( StepTypeDefault = "default" StepTypeContractCall = "contractCall" StepTypeContractCreate = "contractCreate" StepTypeContractUpdate = "contractUpdate" StepTypeContractDestruct = "contractDestruct" StepTypeContractSet = "contractSet" StepTypeGet = "get" StepTypeSet = "set" StepTypeReplace = "replace" StepTypeDelete = "delete" StepTypeInput = "input" StepTypeEventLog = "eventLog" StepTypeApiCall = "apiCall" StepTypeDefaultGet = "defaultGet" StepTypeDefaultSet = "defaultSet" StepTypeReplaceBase = "replaceBase" StepTypeDefaultDelete = "defaultDelete" StepTypeEventLogBase = "eventLogBase" )
View Source
const ( StepLimitTypeInvoke = "invoke" StepLimitTypeQuery = "query" )
View Source
const ( ASDisabled = 1 << iota ASBlocked )
View Source
const ( CTAppZip = "application/zip" CTAppJava = "application/java" CTAppSystem = "application/x.score.system" )
View Source
const ( VarStepPrice = "step_price" VarStepCosts = "step_costs" VarStepTypes = "step_types" VarTreasury = "treasury" VarGovernance = "governance" VarNetwork = "network" VarChainID = "chain_id" VarStepLimitTypes = "step_limit_types" VarStepLimit = "step_limit" VarServiceConfig = "serviceConfig" VarRevision = "revision" VarMembers = "members" VarDeployers = "deployers" VarLicenses = "licenses" VarTotalSupply = "total_supply" VarTimestampThreshold = "timestamp_threshold" VarBlockInterval = "block_interval" VarCommitTimeout = "commit_timeout" VarRoundLimitFactor = "round_limit_factor" VarMinimizeBlockGen = "minimize_block_gen" VarTxHashToAddress = "tx_to_address" )
View Source
const ( SysConfigFee = 1 << iota SysConfigAudit SysConfigDeployerWhiteList SysConfigScorePackageValidator SysConfigMembership SysConfigMax )
View Source
const ( InfoBlockTimestamp = "B.timestamp" InfoBlockHeight = "B.height" InfoTxHash = "T.hash" InfoTxIndex = "T.index" InfoTxTimestamp = "T.timestamp" InfoTxNonce = "T.nonce" InfoTxFrom = "T.from" InfoRevision = "Revision" InfoStepCosts = "StepCosts" InfoContractOwner = "C.owner" )
View Source
const ( AccountNoLock = 0 AccountReadLock = 1 AccountWriteLock = 2 AccountWriteUnlock = 3 )
View Source
const ASActive = 0
View Source
const (
DefaultNID = 1
)
View Source
const (
SystemIDStr = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
)
View Source
const (
WorldIDStr = ""
)
Variables ¶
View Source
var ( SystemID = []byte(SystemIDStr) SystemAddress = common.NewContractAddress(SystemID) )
View Source
var AllStepLimitTypes = []string{ StepLimitTypeInvoke, StepLimitTypeQuery, }
View Source
var AllStepTypes = []string{ StepTypeDefault, StepTypeContractCall, StepTypeContractCreate, StepTypeContractUpdate, StepTypeContractDestruct, StepTypeContractSet, StepTypeGet, StepTypeSet, StepTypeReplace, StepTypeDelete, StepTypeInput, StepTypeEventLog, StepTypeApiCall, StepTypeDefaultGet, StepTypeDefaultSet, StepTypeReplaceBase, StepTypeDefaultDelete, StepTypeEventLogBase, }
Functions ¶
Types ¶
type AccountSnapshot ¶
type AccountSnapshot interface { trie.Object Version() int GetBalance() *big.Int IsContract() bool IsEmpty() bool GetValue(k []byte) ([]byte, error) StorageChangedAfter(snapshot AccountSnapshot) bool IsContractOwner(owner module.Address) bool APIInfo() (*scoreapi.Info, error) Contract() ContractSnapshot ActiveContract() ContractSnapshot NextContract() ContractSnapshot IsDisabled() bool IsBlocked() bool ContractOwner() module.Address GetObjGraph(flags bool) (int, []byte, []byte, error) }
AccountSnapshot represents immutable account state It can be get from AccountState or WorldSnapshot.
type AccountState ¶
type AccountState interface { Version() int MigrateForRevision(rev module.Revision) error GetBalance() *big.Int IsContract() bool GetValue(k []byte) ([]byte, error) SetBalance(v *big.Int) SetValue(k, v []byte) ([]byte, error) DeleteValue(k []byte) ([]byte, error) GetSnapshot() AccountSnapshot Reset(snapshot AccountSnapshot) error Clear() IsContractOwner(owner module.Address) bool InitContractAccount(address module.Address) bool DeployContract(code []byte, eeType EEType, contentType string, params []byte, txHash []byte) ([]byte, error) APIInfo() (*scoreapi.Info, error) SetAPIInfo(*scoreapi.Info) AcceptContract(txHash []byte, auditTxHash []byte) error RejectContract(txHash []byte, auditTxHash []byte) error Contract() Contract ActiveContract() Contract NextContract() Contract SetDisable(b bool) IsDisabled() bool SetBlock(b bool) IsBlocked() bool ContractOwner() module.Address GetObjGraph(flags bool) (int, []byte, []byte, error) SetObjGraph(flags bool, nextHash int, objGraph []byte) error }
AccountState represents mutable account state. You may change account state with this object. It can be get from WorldState. Changes in this object will be retrieved by WorldState. Of course, it also can be changed by WorldState.
type Contract ¶
type Contract interface { ContractSnapshot SetStatus(state ContractState) }
type ContractInfo ¶
type ContractSnapshot ¶
type ContractState ¶
type ContractState int
const ( CSInactive ContractState = 1 << iota CSActive CSPending CSRejected )
func (ContractState) String ¶
func (cs ContractState) String() string
type EEType ¶
type EEType string
func EETypeFromContentType ¶
Only "application/zip" and "application/java" are allowed as contentType by server validator.
func (EEType) InstallMethod ¶
func (EEType) IsInternalMethod ¶
type ExtensionSnapshot ¶ added in v0.9.1
type ExtensionSnapshot interface { Bytes() []byte Flush() error NewState(readonly bool) ExtensionState }
type ExtensionState ¶ added in v0.9.1
type ExtensionState interface { GetSnapshot() ExtensionSnapshot Reset(snapshot ExtensionSnapshot) }
type LockRequest ¶
type TransactionInfo ¶
type ValidatorSnapshot ¶
type ValidatorSnapshot module.ValidatorList
func NewValidatorSnapshotWithBuilder ¶
func NewValidatorSnapshotWithBuilder(builder merkle.Builder, h []byte) (ValidatorSnapshot, error)
func ValidatorSnapshotFromHash ¶
func ValidatorSnapshotFromHash(database db.Database, h []byte) (ValidatorSnapshot, error)
type ValidatorState ¶
type ValidatorState interface { IndexOf(module.Address) int Len() int Get(i int) (module.Validator, bool) Set([]module.Validator) error Add(v module.Validator) error Remove(v module.Validator) bool GetSnapshot() ValidatorSnapshot Reset(ValidatorSnapshot) }
func ValidatorStateFromHash ¶
func ValidatorStateFromHash(database db.Database, h []byte) (ValidatorState, error)
func ValidatorStateFromSnapshot ¶
func ValidatorStateFromSnapshot(vss ValidatorSnapshot) ValidatorState
type WorldContext ¶
type WorldContext interface { WorldState Revision() module.Revision ToRevision(v int) module.Revision StepsFor(t StepType, n int) int64 StepPrice() *big.Int BlockTimeStamp() int64 GetStepLimit(t string) *big.Int BlockHeight() int64 Treasury() module.Address Governance() module.Address GetInfo() map[string]interface{} WorldStateChanged(ws WorldState) WorldContext WorldVirtualState() WorldVirtualState GetFuture(lq []LockRequest) WorldContext SetTransactionInfo(ti *TransactionInfo) GetTransactionInfo(ti *TransactionInfo) bool SetContractInfo(si *ContractInfo) UpdateSystemInfo() IsDeployer(addr string) bool FeeEnabled() bool AuditEnabled() bool DeployerWhiteListEnabled() bool PackageValidatorEnabled() bool MembershipEnabled() bool TransactionTimestampThreshold() int64 EnableSkipTransaction() SkipTransactionEnabled() bool }
func NewWorldContext ¶
func NewWorldContext(ws WorldState, bi module.BlockInfo, plt Platform) WorldContext
type WorldSnapshot ¶
type WorldSnapshot interface { GetAccountSnapshot(id []byte) AccountSnapshot GetValidatorSnapshot() ValidatorSnapshot GetExtensionSnapshot() ExtensionSnapshot Flush() error StateHash() []byte ExtensionData() []byte Database() db.Database }
WorldSnapshot represents snapshot of WorldState. It can be use to WorldState recover state of WorldState to at some point.
func NewWorldSnapshot ¶
func NewWorldSnapshot(dbase db.Database, stateHash []byte, vs ValidatorSnapshot, es ExtensionSnapshot) WorldSnapshot
func NewWorldSnapshotWithBuilder ¶
func NewWorldSnapshotWithBuilder(builder merkle.Builder, sh []byte, vh []byte, ess ExtensionSnapshot) (WorldSnapshot, error)
func NewWorldSnapshotWithNewValidators ¶
func NewWorldSnapshotWithNewValidators(dbase db.Database, snapshot WorldSnapshot, vss ValidatorSnapshot) WorldSnapshot
type WorldState ¶
type WorldState interface { GetAccountState(id []byte) AccountState GetAccountSnapshot(id []byte) AccountSnapshot GetSnapshot() WorldSnapshot GetValidatorState() ValidatorState GetExtensionState() ExtensionState Reset(snapshot WorldSnapshot) error ClearCache() EnableNodeCache() NodeCacheEnabled() bool Database() db.Database }
WorldState represents world state. You may change
func NewReadOnlyWorldState ¶
func NewReadOnlyWorldState(wss WorldSnapshot) WorldState
func NewWorldState ¶
func NewWorldState(database db.Database, stateHash []byte, vs ValidatorSnapshot, es ExtensionSnapshot) WorldState
func WorldStateFromSnapshot ¶
func WorldStateFromSnapshot(wss WorldSnapshot) (WorldState, error)
type WorldVirtualState ¶
type WorldVirtualState interface { WorldState GetFuture(reqs []LockRequest) WorldVirtualState Ensure() Commit() Realize() }
func NewWorldVirtualState ¶
func NewWorldVirtualState(ws WorldState, reqs []LockRequest) WorldVirtualState
Click to show internal directories.
Click to hide internal directories.