Documentation ¶
Overview ¶
copy from Package sjson, provides setting json values.
Index ¶
- Constants
- Variables
- func AbsolutePath(dataDir string, filename string) string
- func BillableSizeV(kind string) uint64
- func CheckParseInt64(s string)
- func CompareAccountDelta(first interface{}, second interface{}) int
- func CompareName(first interface{}, second interface{}) int
- func CompareNamePair(a, b interface{}) int
- func ComparePermissionLevel(first interface{}, second interface{}) int
- func CompareString(a, b Compare) int
- func DecodeIdTypeByte(b []byte) (id [4]uint64, err error)
- func DecodeIdTypeString(str string) (id [4]uint64, err error)
- func Empty(i interface{}) bool
- func EndianReverseU32(x uint32) uint32
- func EndianReverseU64(x uint64) uint64
- func EosPercent(value uint64, percentage uint32) uint64
- func FileExist(filePath string) bool
- func FromVariant(variant Variant, T interface{})
- func Max(x, y uint64) uint64
- func Min(x, y uint64) uint64
- func NameSuffix(n uint64) uint64
- func ReadUvarint64(in []byte) (uint64, int, error)
- func ReadVarint64(in []byte) (int64, int, error)
- func S(in uint64) string
- func Set(json, path string, value interface{}) (string, error)
- func SetBytes(json []byte, path string, value interface{}) ([]byte, error)
- func SetBytesOptions(json []byte, path string, value interface{}, opts *Options) ([]byte, error)
- func SetOptions(json, path string, value interface{}, opts *Options) (string, error)
- func SetRaw(json, path, value string) (string, error)
- func SetRawBytes(json []byte, path string, value []byte) ([]byte, error)
- func SetRawBytesOptions(json []byte, path string, value []byte, opts *Options) ([]byte, error)
- func SetRawOptions(json, path, value string, opts *Options) (string, error)
- func StringToSymbol(precision uint8, str string) (result uint64)
- func ToVariant(T interface{}, variant Variant)
- func WriteInt16(i int16) []byte
- func WriteInt32(i int32) []byte
- func WriteInt64(i int64) []byte
- func WriteInt8(i int8) []byte
- func WriteUVarInt(v int) []byte
- func WriteUint16(i uint16) []byte
- func WriteUint32(i uint32) []byte
- func WriteUint64(i uint64) []byte
- func WriteUint8(i uint8) []byte
- func WriteVarInt(v int) []byte
- type AccountDelta
- type AccountName
- type ActionName
- type Asset
- func (a Asset) Add(b Asset) Asset
- func (a Asset) FromString(from *string) Asset
- func (a Asset) MarshalJSON() (data []byte, err error)
- func (s Asset) Pack() (re []byte, err error)
- func (a Asset) String() string
- func (a Asset) Sub(b Asset) Asset
- func (a *Asset) UnmarshalJSON(data []byte) error
- func (s *Asset) Unpack(in []byte) (int, error)
- type BlockIdType
- type ChainIdType
- type CheckEmpty
- type CheckSum256Type
- type Compare
- type Config
- type CurrencyName
- type DigestType
- type ExtendedAsset
- type HexBytes
- type IdType
- type KeyType
- type Microseconds
- type Name
- type NamePair
- type NodeIdType
- type Options
- type Pair
- type PermissionLevel
- type PermissionName
- type ScopeName
- type SizeT
- type StaticVariant
- type Symbol
- func (sym *Symbol) Decimals() uint8
- func (sym Symbol) FromString(from *string) Symbol
- func (sym *Symbol) Name() string
- func (s Symbol) Pack() (re []byte, err error)
- func (sym Symbol) String() string
- func (sym *Symbol) SymbolValue() uint64
- func (sym *Symbol) ToSymbolCode() SymbolCode
- func (s *Symbol) Unpack(in []byte) (int, error)
- func (sym *Symbol) Valid() bool
- func (sym *Symbol) ValidName(name string) bool
- type SymbolCode
- type TableName
- type TimePoint
- func (tp TimePoint) AddUs(m Microseconds) TimePoint
- func (tp TimePoint) MarshalJSON() ([]byte, error)
- func (tp TimePoint) SecSinceEpoch() uint32
- func (tp TimePoint) String() string
- func (tp TimePoint) Sub(t TimePoint) Microseconds
- func (tp TimePoint) SubTps(t TimePointSec) Microseconds
- func (tp TimePoint) SubUs(m Microseconds) TimePoint
- func (tp TimePoint) TimeSinceEpoch() Microseconds
- func (tp *TimePoint) UnmarshalJSON(data []byte) error
- type TimePointSec
- func (tp TimePointSec) AddSec(offset uint32) TimePointSec
- func (tp TimePointSec) AddUs(m Microseconds) TimePoint
- func (tp TimePointSec) MarshalJSON() ([]byte, error)
- func (tp TimePointSec) SecSinceEpoch() uint32
- func (tp TimePointSec) String() string
- func (tp TimePointSec) Sub(t TimePointSec) Microseconds
- func (tp TimePointSec) SubSec(offset uint32) TimePointSec
- func (tp TimePointSec) SubUs(m Microseconds) TimePoint
- func (tp TimePointSec) ToTimePoint() TimePoint
- func (tp *TimePointSec) UnmarshalJSON(data []byte) error
- type Timer
- type TransactionIdType
- type Tuple
- type Variant
- type Variants
- type Vint32
- type Vuint32
Constants ¶
const ( ChainFuncBase string = "/v1/chain" GetInfoFunc string = ChainFuncBase + "/get_info" PushTxnFunc string = ChainFuncBase + "/push_transaction" PushTxnsFunc string = ChainFuncBase + "/push_transactions" JsonToBinFunc string = ChainFuncBase + "/abi_json_to_bin" GetBlockFunc string = ChainFuncBase + "/get_block" GetBlockHeaderStateFunc string = ChainFuncBase + "/get_block_header_state" GetAccountFunc string = ChainFuncBase + "/get_account" GetTableFunc string = ChainFuncBase + "/get_table_rows" GetTableByScopeFunc string = ChainFuncBase + "/get_table_by_scope" GetCodeFunc string = ChainFuncBase + "/get_code" GetCodeHashFunc string = ChainFuncBase + "/get_code_hash" GetAbiFunc string = ChainFuncBase + "/get_abi" GetRawAbiFunc string = ChainFuncBase + "/get_raw_abi" GetRawCodeAndAbiFunc string = ChainFuncBase + "/get_raw_code_and_abi" GetCurrencyBalanceFunc string = ChainFuncBase + "/get_currency_balance" GetCurrencyStatsFunc string = ChainFuncBase + "/get_currency_stats" GetProducersFunc string = ChainFuncBase + "/get_producers" GetScheduleFunc string = ChainFuncBase + "/get_producer_schedule" GetRequiredKeys string = ChainFuncBase + "/get_required_keys" HistoryFuncBase string = "/v1/history" GetActionsFunc string = HistoryFuncBase + "/get_actions" GetTransactionFunc string = HistoryFuncBase + "/get_transaction" GetKeyAccountsFunc string = HistoryFuncBase + "/get_key_accounts" GetControlledAccountsFunc string = HistoryFuncBase + "/get_controlled_accounts" AccountHistoryFuncBase string = "/v1/account_history" GetTransactionsFunc string = AccountHistoryFuncBase + "/get_transactions" NetFuncBase string = "/v1/net" NetConnect string = NetFuncBase + "/connect" NetDisconnect string = NetFuncBase + "/disconnect" NetStatus string = NetFuncBase + "/status" NetConnections string = NetFuncBase + "/connections" WalletFuncBase string = "/v1/wallet" WalletCreate string = WalletFuncBase + "/create" WalletOpen string = WalletFuncBase + "/open" WalletList string = WalletFuncBase + "/list_wallets" WalletListKeys string = WalletFuncBase + "/list_keys" WalletPublicKeys string = WalletFuncBase + "/get_public_keys" WalletLock string = WalletFuncBase + "/lock" WalletLockAll string = WalletFuncBase + "/lock_all" WalletUnlock string = WalletFuncBase + "/unlock" WalletImportKey string = WalletFuncBase + "/import_key" WalletRemoveKey string = WalletFuncBase + "/remove_key" WalletCreateKey string = WalletFuncBase + "/create_key" WalletSignTrx string = WalletFuncBase + "/sign_transaction" ProducerFuncBase string = "/v1/producer" ProducerPause string = ProducerFuncBase + "/pause" ProducerResume string = ProducerFuncBase + "/resume" ProducerPaused string = ProducerFuncBase + "/paused" ProducerGetRuntimeOptions string = ProducerFuncBase + "/get_runtime_options" ProducerUpdateRuntimeOptions string = ProducerFuncBase + "/update_runtime_options" ProducerAddGreylistAccounts string = ProducerFuncBase + "/add_greylist_accounts" ProducerRemoveGreylistAccounts string = ProducerFuncBase + "/remove_greylist_accounts" ProducerGetGreylist string = ProducerFuncBase + "/get_greylist" ProducerGetWhitelistBlacklist string = ProducerFuncBase + "/get_whitelist_blacklist" ProducerSetWhitelistBlacklist string = ProducerFuncBase + "/set_whitelist_blacklist" ProducerGetIntegrityHash string = ProducerFuncBase + "/get_integrity_hash" ProducerCreateSnapshot string = ProducerFuncBase + "/create_snapshot" )
const (
HttpEndPoint = "http://127.0.0.1:8888"
)
const (
LargeNumberNoOverflow = int64(^uint(0)>>1) / 2
)
const SizeofAsset int = 16
Variables ¶
var EOSSymbol = Symbol{Precision: 4, Symbol: "EOS"}
EOSSymbol represents the standard EOS symbol on the chain. It's here just to speed up things.
var MaxPrecision = uint8(18)
var TypeName = reflect.TypeOf(Name(0))
for treeset
var TypePair = reflect.TypeOf(&Pair{})
Functions ¶
func AbsolutePath ¶
AbsolutePath returns datadir + filename, or filename if it is absolute.
func BillableSizeV ¶
func CheckParseInt64 ¶
func CheckParseInt64(s string)
func CompareAccountDelta ¶
func CompareAccountDelta(first interface{}, second interface{}) int
func CompareName ¶
func CompareName(first interface{}, second interface{}) int
func CompareNamePair ¶
func CompareNamePair(a, b interface{}) int
func ComparePermissionLevel ¶
func ComparePermissionLevel(first interface{}, second interface{}) int
func CompareString ¶
func DecodeIdTypeByte ¶
func DecodeIdTypeString ¶
func EndianReverseU32 ¶
func EndianReverseU64 ¶
func EosPercent ¶
func FromVariant ¶
func FromVariant(variant Variant, T interface{})
func NameSuffix ¶
func Set ¶
Set sets a json value for the specified path. A path is in dot syntax, such as "name.last" or "age". This function expects that the json is well-formed, and does not validate. Invalid json will not panic, but it may return back unexpected results. An error is returned if the path is not valid.
A path is a series of keys separated by a dot.
{ "name": {"first": "Tom", "last": "Anderson"}, "age":37, "children": ["Sara","Alex","Jack"], "friends": [ {"first": "James", "last": "Murphy"}, {"first": "Roger", "last": "Craig"} ] } "name.last" >> "Anderson" "age" >> 37 "children.1" >> "Alex"
func SetBytes ¶
SetBytes sets a json value for the specified path. If working with bytes, this method preferred over Set(string(data), path, value)
func SetBytesOptions ¶
SetBytesOptions sets a json value for the specified path with options. If working with bytes, this method preferred over SetOptions(string(data), path, value)
func SetOptions ¶
SetOptions sets a json value for the specified path with options. A path is in dot syntax, such as "name.last" or "age". This function expects that the json is well-formed, and does not validate. Invalid json will not panic, but it may return back unexpected results. An error is returned if the path is not valid.
func SetRaw ¶
SetRaw sets a raw json value for the specified path. This function works the same as Set except that the value is set as a raw block of json. This allows for setting premarshalled json objects.
func SetRawBytes ¶
SetRawBytes sets a raw json value for the specified path. If working with bytes, this method preferred over SetRaw(string(data), path, value)
func SetRawBytesOptions ¶
SetRawBytesOptions sets a raw json value for the specified path with options. If working with bytes, this method preferred over SetRawOptions(string(data), path, value, opts)
func SetRawOptions ¶
SetRawOptions sets a raw json value for the specified path with options. This furnction works the same as SetOptions except that the value is set as a raw block of json. This allows for setting premarshalled json objects.
func StringToSymbol ¶
func WriteInt16 ¶
func WriteInt32 ¶
func WriteInt64 ¶
func WriteUVarInt ¶
func WriteString(s string) []byte { return WriteByteArray([]byte(s)) }
func WriteByteArray(b []byte) []byte { //EosAssert(len(b) <= MAX_SIZE_OF_BYTE_ARRAYS, &exception.AssertException{}, "rlp encode ByteArray") if err := WriteUVarInt(len(b)); err != nil { return err } return e.toWriter(b) }
func WriteUint16 ¶
func WriteUint32 ¶
func WriteUint64 ¶
func WriteUint8 ¶
func WriteVarInt ¶
Types ¶
type AccountDelta ¶
type AccountDelta struct { Account AccountName Delta int64 }
func NewAccountDelta ¶
func NewAccountDelta(name AccountName, d int64) *AccountDelta
type AccountName ¶
type AccountName = Name
type ActionName ¶
type ActionName = Name
type Asset ¶
func NewAssetWithCheck ¶
func NewEOSAsset ¶
func NewEOSAssetFromString ¶
func (Asset) FromString ¶
func (Asset) MarshalJSON ¶
func (*Asset) UnmarshalJSON ¶
type ChainIdType ¶
type CheckEmpty ¶
type CheckEmpty interface {
IsEmpty() bool
}
type CheckSum256Type ¶
type Config ¶
type Config struct { SystemAccountName AccountName NullAccountName AccountName ProducersAccountName AccountName // Active permission of producers account requires greater than 2/3 of the producers to authorize MajorityProducersPermissionName PermissionName MinorityProducersPermissionName PermissionName EosioAuthScope AccountName EosioAllScope AccountName ActiveName PermissionName OwnerName PermissionName EosioAnyName PermissionName EosioCodeName PermissionName RateLimitingPrecision uint32 BlockIntervalMs int64 BlockIntervalUs int64 BlockTimestampEpochMs int64 BlockTimestamoEpochNanos int64 //chain_plugin config DefaultAbiSerializerMaxTimeMs uint32 /** * The number of sequential blocks produced by a single producer */ ProducerRepetitions int MaxProducers int FixedNetOverheadOfPackedTrx uint32 //TODO: C++ default value 16 and is this reasonable? OverheadPerRowPerIndexRamBytes uint32 ///< overhead accounts for basic tracking structures in a row per index OverheadPerAccountRamBytes uint32 //= 2*1024; ///< overhead accounts for basic account storage and pre-pays features like account recovery SetcodeRamBytesMultiplier uint32 //= 10; ///< multiplier on contract size to account for multiple copies and cached compilation HashingChecktimeBlockSize uint32 //= 10*1024; BillableAlignment uint64 BillableSize map[string]billableSize MaxTrackedDposConfirmations int ///< TransactionIdNetUsage uint32 Percent_100 int Percent_1 int IrreversibleThresholdPercent int AccountCpuUsageAverageWindowMs uint32 AccountNetUsageAverageWindowMs uint32 BlockCpuUsageAverageWindowMs uint32 BlockSizeAverageWindowMs uint32 /**************************chain_config start****************************/ MaxBlockNetUsage uint64 ///< the maxiumum net usage in instructions for a block TargetBlockNetUsagePct uint32 ///< the target percent (1% == 100, 100%= 10,000) of maximum net usage; exceeding this triggers congestion handling MaxTransactionNetUsage uint32 ///< the maximum objectively measured net usage that the chain will allow regardless of account limits BasePerTransactionNetUsage uint32 ///< the base amount of net usage billed for a transaction to cover incidentals NetUsageLeeway uint32 ContextFreeDiscountNetUsageNum uint32 ///< the numerator for the discount on net usage of context-free data ContextFreeDiscountNetUsageDen uint32 ///< the denominator for the discount on net usage of context-free data MaxBlockCpuUsage uint32 ///< the maxiumum billable cpu usage (in microseconds) for a block TargetBlockCpuUsagePct uint32 ///< the target percent (1% == 100, 100%= 10,000) of maximum cpu usage; exceeding this triggers congestion handling MaxTransactionCpuUsage uint32 ///< the maximum billable cpu usage (in microseconds) that the chain will allow regardless of account limits MinTransactionCpuUsage uint32 ///< the minimum billable cpu usage (in microseconds) that the chain requires MaxTrxLifetime uint32 //MaxTransactionLifetime uint32 ///< the maximum number of seconds that an input transaction's expiration can be ahead of the time of the block in which it is first included DeferredTrxExpirationWindow uint32 ///< the number of seconds after the time a deferred transaction can first execute until it expires MaxTrxDelay uint32 ///< the maximum number of seconds that can be imposed as a delay requirement by authorization checks MaxInlineActionSize uint32 ///< maximum allowed size (in bytes) of an inline action MaxInlineActionDepth uint16 ///< recursion depth limit on sending inline actions MaxAuthorityDepth uint16 ///< recursion depth limit for checking if an authority is satisfied MinNetUsageDeltaBetweenBaseAndMaxForTrx uint32 ForkDbName string DBFileName string ReversibleFileName string BlockFileName string DefaultBlocksDirName string DefaultReversibleBlocksDirName string DefaultStateDirName string DefaultStateSize uint64 DefaultStateGuardSize uint64 DefaultReversibleCacheSize uint64 DefaultReversibleGuardSize uint64 }
var DefaultConfig Config
type CurrencyName ¶
type CurrencyName string
type DigestType ¶
type ExtendedAsset ¶
type ExtendedAsset struct { Asset Asset `json:"asset"` Contract AccountName }
type HexBytes ¶
type HexBytes []byte
HexBytes
func (HexBytes) MarshalJSON ¶
func (*HexBytes) UnmarshalJSON ¶
type Microseconds ¶
type Microseconds int64
func Days ¶
func Days(d int64) Microseconds
func Hours ¶
func Hours(h int64) Microseconds
func MaxMicroseconds ¶
func MaxMicroseconds() Microseconds
func Milliseconds ¶
func Milliseconds(s int64) Microseconds
func MinMicroseconds ¶
func MinMicroseconds() Microseconds
func Minutes ¶
func Minutes(m int64) Microseconds
func Seconds ¶
func Seconds(s int64) Microseconds
func (Microseconds) Count ¶
func (ms Microseconds) Count() int64
func (Microseconds) ToSeconds ¶
func (ms Microseconds) ToSeconds() int64
type Name ¶
type Name uint64
ported from libraries/chain/name.cpp in eosio
func N ¶
N converts a base32 string to a uint64. 64-bit unsigned integer representation of the name.
func (Name) MarshalJSON ¶
func (*Name) UnmarshalJSON ¶
type NamePair ¶
type NamePair struct { First AccountName Second ActionName }
type NodeIdType ¶
type Options ¶
type Options struct { // Optimistic is a hint that the value likely exists which // allows for the sjson to perform a fast-track search and replace. Optimistic bool // ReplaceInPlace is a hint to replace the input json rather than // allocate a new json byte slice. When this field is specified // the input json will not longer be valid and it should not be used // In the case when the destination slice doesn't have enough free // bytes to replace the data in place, a new bytes slice will be // created under the hood. // The Optimistic flag must be set to true and the input must be a // byte slice in order to use this field. ReplaceInPlace bool }
Options represents additional options for the Set and Delete functions.
type PermissionLevel ¶
type PermissionLevel struct { Actor AccountName `json:"actor"` Permission PermissionName `json:"permission"` }
func (PermissionLevel) String ¶
func (level PermissionLevel) String() string
type PermissionName ¶
type PermissionName = Name
type StaticVariant ¶
type StaticVariant = Variant // use type-assert to get static_variant
type Symbol ¶
NOTE: there's also a new ExtendedSymbol (which includes the contract (as AccountName) on which it is)
func (Symbol) FromString ¶
func (*Symbol) SymbolValue ¶
func (*Symbol) ToSymbolCode ¶
func (sym *Symbol) ToSymbolCode() SymbolCode
type SymbolCode ¶
type SymbolCode = uint64
type TimePoint ¶
type TimePoint Microseconds
func FromIsoString ¶
func MaxTimePoint ¶
func MaxTimePoint() TimePoint
func MinTimePoint ¶
func MinTimePoint() TimePoint
func (TimePoint) AddUs ¶
func (tp TimePoint) AddUs(m Microseconds) TimePoint
func (TimePoint) MarshalJSON ¶
func (TimePoint) SecSinceEpoch ¶
func (TimePoint) Sub ¶
func (tp TimePoint) Sub(t TimePoint) Microseconds
func (TimePoint) SubTps ¶
func (tp TimePoint) SubTps(t TimePointSec) Microseconds
func (TimePoint) SubUs ¶
func (tp TimePoint) SubUs(m Microseconds) TimePoint
func (TimePoint) TimeSinceEpoch ¶
func (tp TimePoint) TimeSinceEpoch() Microseconds
func (*TimePoint) UnmarshalJSON ¶
type TimePointSec ¶
type TimePointSec uint32
*
- A lower resolution time_point accurate only to seconds from 1970
func FromIsoStringSec ¶
func FromIsoStringSec(s string) (TimePointSec, error)
func MaxTimePointSec ¶
func MaxTimePointSec() TimePointSec
func MinTimePointSec ¶
func MinTimePointSec() TimePointSec
func NewTimePointSecTp ¶
func NewTimePointSecTp(t TimePoint) TimePointSec
func (TimePointSec) AddSec ¶
func (tp TimePointSec) AddSec(offset uint32) TimePointSec
func (TimePointSec) AddUs ¶
func (tp TimePointSec) AddUs(m Microseconds) TimePoint
func (TimePointSec) MarshalJSON ¶
func (tp TimePointSec) MarshalJSON() ([]byte, error)
func (TimePointSec) SecSinceEpoch ¶
func (tp TimePointSec) SecSinceEpoch() uint32
func (TimePointSec) String ¶
func (tp TimePointSec) String() string
func (TimePointSec) Sub ¶
func (tp TimePointSec) Sub(t TimePointSec) Microseconds
func (TimePointSec) SubSec ¶
func (tp TimePointSec) SubSec(offset uint32) TimePointSec
func (TimePointSec) SubUs ¶
func (tp TimePointSec) SubUs(m Microseconds) TimePoint
func (TimePointSec) ToTimePoint ¶
func (tp TimePointSec) ToTimePoint() TimePoint
func (*TimePointSec) UnmarshalJSON ¶
func (tp *TimePointSec) UnmarshalJSON(data []byte) error
type Timer ¶
type Timer asio.DeadlineTimer
*
- using asio.DeadlineTimer
func (*Timer) ExpiresAt ¶
func (t *Timer) ExpiresAt(epoch Microseconds)
func (*Timer) ExpiresFromNow ¶
func (t *Timer) ExpiresFromNow(m Microseconds)
func (*Timer) ExpiresUntil ¶
type TransactionIdType ¶
func TransactionIdNil ¶
func TransactionIdNil() TransactionIdType