Documentation ¶
Overview ¶
Package chain is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ApplyReward(db database.Database, blkID ids.ID, txID ids.ID, sender common.Address, ...) (common.Address, bool, error)
- func BuildBlock(vm VM, preferred ids.ID) (snowman.Block, error)
- func CompactablePrefixKey(pfx byte) []byte
- func DeleteSpaceKey(db database.Database, space []byte, key []byte) error
- func DeriveSender(dh []byte, sig []byte) (*ecdsa.PublicKey, error)
- func DigestHash(utx UnsignedTransaction) ([]byte, error)
- func ExpireNext(db database.Database, rparent int64, rcurrent int64, bootstrapped bool) (err error)
- func ExpiryDataValue(address common.Address, space []byte) (v []byte)
- func GetAllOwned(db database.Database, owner common.Address) (spaces []string, err error)
- func GetBalance(db database.KeyValueReader, address common.Address) (uint64, error)
- func GetLastAccepted(db database.KeyValueReader) (ids.ID, error)
- func GetValue(db database.KeyValueReader, space []byte, key []byte) ([]byte, bool, error)
- func HasLastAccepted(db database.Database) (bool, error)
- func HasSpace(db database.KeyValueReader, space []byte) (bool, error)
- func HasSpaceKey(db database.KeyValueReader, space []byte, key []byte) (bool, error)
- func HasTransaction(db database.KeyValueReader, txID ids.ID) (bool, error)
- func Marshal(source interface{}) ([]byte, error)
- func ModifyBalance(db database.KeyValueReaderWriter, address common.Address, add bool, ...) (uint64, error)
- func MoveSpaceInfo(db database.KeyValueWriterDeleter, oldOwner common.Address, space []byte, ...) error
- func PrefixBalanceKey(address common.Address) (k []byte)
- func PrefixBlockKey(blockID ids.ID) (k []byte)
- func PrefixExpiryKey(expiry uint64, rspace ids.ShortID) (k []byte)
- func PrefixOwnedKey(address common.Address, space []byte) (k []byte)
- func PrefixPruningKey(expired uint64, rspace ids.ShortID) (k []byte)
- func PrefixTxKey(txID ids.ID) (k []byte)
- func PrefixTxValueKey(txID ids.ID) (k []byte)
- func PruneNext(db database.Database, limit int) (removals int, err error)
- func PutSpaceInfo(db database.KeyValueWriterDeleter, space []byte, i *SpaceInfo, ...) error
- func PutSpaceKey(db database.KeyValueReaderWriter, space []byte, key []byte, vmeta *ValueMeta) error
- func RangeTimeKey(p byte, t uint64) (k []byte)
- func RawSpace(space []byte, blockTime uint64) (ids.ShortID, error)
- func SetBalance(db database.KeyValueWriter, address common.Address, bal uint64) error
- func SetLastAccepted(db database.KeyValueWriter, block *StatelessBlock) error
- func SetTransaction(db database.KeyValueWriter, tx *Transaction) error
- func Sign(dh []byte, priv *ecdsa.PrivateKey) ([]byte, error)
- func SpaceInfoKey(space []byte) (k []byte)
- func SpaceValueKey(rspace ids.ShortID, key []byte) (k []byte)
- func Unmarshal(source []byte, destination interface{}) (uint16, error)
- type Activity
- type Airdrop
- type BaseTx
- func (b *BaseTx) Copy() *BaseTx
- func (b *BaseTx) ExecuteBase(g *Genesis) error
- func (b *BaseTx) FeeUnits(g *Genesis) uint64
- func (b *BaseTx) GetBlockID() ids.ID
- func (b *BaseTx) GetMagic() uint64
- func (b *BaseTx) GetPrice() uint64
- func (b *BaseTx) LoadUnits(g *Genesis) uint64
- func (b *BaseTx) SetBlockID(bid ids.ID)
- func (b *BaseTx) SetMagic(magic uint64)
- func (b *BaseTx) SetPrice(price uint64)
- type ClaimTx
- type CompactRange
- type Context
- type CustomAllocation
- type DeleteTx
- type Genesis
- type Input
- type KeyValueMeta
- type LifelineTx
- type Mempool
- type MockMempool
- type MockMempoolMockRecorder
- func (mr *MockMempoolMockRecorder) Add(arg0 interface{}) *gomock.Call
- func (mr *MockMempoolMockRecorder) Len() *gomock.Call
- func (mr *MockMempoolMockRecorder) NewTxs(arg0 interface{}) *gomock.Call
- func (mr *MockMempoolMockRecorder) PopMax() *gomock.Call
- func (mr *MockMempoolMockRecorder) Prune(arg0 interface{}) *gomock.Call
- type MockUnsignedTransaction
- func (m *MockUnsignedTransaction) Activity() *Activity
- func (m *MockUnsignedTransaction) Copy() UnsignedTransaction
- func (m *MockUnsignedTransaction) EXPECT() *MockUnsignedTransactionMockRecorder
- func (m *MockUnsignedTransaction) Execute(arg0 *TransactionContext) error
- func (m *MockUnsignedTransaction) ExecuteBase(arg0 *Genesis) error
- func (m *MockUnsignedTransaction) FeeUnits(arg0 *Genesis) uint64
- func (m *MockUnsignedTransaction) GetBlockID() ids.ID
- func (m *MockUnsignedTransaction) GetMagic() uint64
- func (m *MockUnsignedTransaction) GetPrice() uint64
- func (m *MockUnsignedTransaction) LoadUnits(arg0 *Genesis) uint64
- func (m *MockUnsignedTransaction) SetBlockID(arg0 ids.ID)
- func (m *MockUnsignedTransaction) SetMagic(arg0 uint64)
- func (m *MockUnsignedTransaction) SetPrice(arg0 uint64)
- func (m *MockUnsignedTransaction) TypedData() *tdata.TypedData
- type MockUnsignedTransactionMockRecorder
- func (mr *MockUnsignedTransactionMockRecorder) Activity() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) Copy() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) Execute(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) ExecuteBase(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) FeeUnits(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) GetBlockID() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) GetMagic() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) GetPrice() *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) LoadUnits(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) SetBlockID(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) SetMagic(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) SetPrice(arg0 interface{}) *gomock.Call
- func (mr *MockUnsignedTransactionMockRecorder) TypedData() *gomock.Call
- type MockVM
- func (m *MockVM) Accepted(arg0 *StatelessBlock)
- func (m *MockVM) EXPECT() *MockVMMockRecorder
- func (m *MockVM) ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error)
- func (m *MockVM) Genesis() *Genesis
- func (m *MockVM) GetStatelessBlock(arg0 ids.ID) (*StatelessBlock, error)
- func (m *MockVM) IsBootstrapped() bool
- func (m *MockVM) Mempool() Mempool
- func (m *MockVM) Rejected(arg0 *StatelessBlock)
- func (m *MockVM) State() database.Database
- func (m *MockVM) Verified(arg0 *StatelessBlock)
- type MockVMMockRecorder
- func (mr *MockVMMockRecorder) Accepted(arg0 interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) ExecutionContext(currentTime, parent interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) Genesis() *gomock.Call
- func (mr *MockVMMockRecorder) GetStatelessBlock(arg0 interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) IsBootstrapped() *gomock.Call
- func (mr *MockVMMockRecorder) Mempool() *gomock.Call
- func (mr *MockVMMockRecorder) Rejected(arg0 interface{}) *gomock.Call
- func (mr *MockVMMockRecorder) State() *gomock.Call
- func (mr *MockVMMockRecorder) Verified(arg0 interface{}) *gomock.Call
- type MoveTx
- type SetTx
- type SpaceInfo
- type StatefulBlock
- type StatelessBlock
- func DummyBlock(tmstp int64, tx *Transaction) *StatelessBlock
- func NewBlock(vm VM, parent snowman.Block, tmstp int64, context *Context) *StatelessBlock
- func ParseBlock(source []byte, status choices.Status, vm VM) (*StatelessBlock, error)
- func ParseStatefulBlock(blk *StatefulBlock, source []byte, status choices.Status, vm VM) (*StatelessBlock, error)
- func (b *StatelessBlock) Accept(ctx context.Context) error
- func (b *StatelessBlock) Bytes() []byte
- func (b *StatelessBlock) Height() uint64
- func (b *StatelessBlock) ID() ids.ID
- func (b *StatelessBlock) Parent() ids.ID
- func (b *StatelessBlock) Reject(ctx context.Context) error
- func (b *StatelessBlock) SetChildrenDB(db database.Database) error
- func (b *StatelessBlock) Status() choices.Status
- func (b *StatelessBlock) Timestamp() time.Time
- func (b *StatelessBlock) Verify(ctx context.Context) error
- type Transaction
- func (t *Transaction) Activity() *Activity
- func (t *Transaction) Bytes() []byte
- func (t *Transaction) Copy() *Transaction
- func (t *Transaction) DigestHash() []byte
- func (t *Transaction) Execute(g *Genesis, db database.Database, blk *StatelessBlock, context *Context) error
- func (t *Transaction) ID() ids.ID
- func (t *Transaction) Init(g *Genesis) error
- func (t *Transaction) Sender() common.Address
- func (t *Transaction) Size() uint64
- type TransactionContext
- type TransferTx
- type UnsignedTransaction
- type VM
- type ValueMeta
Constants ¶
const ( Claim = "claim" Lifeline = "lifeline" Set = "set" Delete = "delete" Move = "move" Transfer = "transfer" // Non-user created event Reward = "reward" )
const ( LotteryRewardDivisor = 100 MinBlockCost = 0 DefaultFreeClaimStorage = 1 * units.MiB DefaultValueUnitSize = 1 * units.KiB DefaultFreeClaimUnits = DefaultFreeClaimStorage / DefaultValueUnitSize DefaultFreeClaimDuration = 60 * 60 * 24 * 30 // 30 Days DefaultLookbackWindow = 60 )
const (
// 0x + hex-encoded hash
HashLen = 66
)
Variables ¶
var ( // Genesis Correctness ErrInvalidMagic = errors.New("invalid magic") ErrInvalidBlockRate = errors.New("invalid block rate") // Block Correctness ErrTimestampTooEarly = errors.New("block timestamp too early") ErrTimestampTooLate = errors.New("block timestamp too late") ErrNoTxs = errors.New("no transactions") ErrInvalidCost = errors.New("invalid block cost") ErrInvalidPrice = errors.New("invalid price") ErrInsufficientSurplus = errors.New("insufficient surplus fee") ErrParentBlockNotVerified = errors.New("parent block not verified or accepted") // Tx Correctness ErrInvalidBlockID = errors.New("invalid blockID") ErrInvalidSignature = errors.New("invalid signature") ErrDuplicateTx = errors.New("duplicate transaction") ErrInsufficientPrice = errors.New("insufficient price") ErrInvalidType = errors.New("invalid tx type") ErrTypedDataKeyMissing = errors.New("typed data key missing") // Execution Correctness ErrValueEmpty = errors.New("value empty") ErrValueTooBig = errors.New("value too big") ErrSpaceExpired = errors.New("space expired") ErrKeyMissing = errors.New("key missing") ErrInvalidKey = errors.New("key is invalid") ErrAddressMismatch = errors.New("address does not match decoded space") ErrSpaceNotExpired = errors.New("space not expired") ErrSpaceMissing = errors.New("space missing") ErrInvalidBalance = errors.New("invalid balance") ErrNonActionable = errors.New("transaction doesn't do anything") ErrBlockTooBig = errors.New("block too big") )
var ( CompactRanges = []*CompactRange{ {[]byte{infoPrefix, parser.ByteDelimiter}, []byte{keyPrefix, parser.ByteDelimiter}}, {[]byte{keyPrefix, parser.ByteDelimiter}, []byte{expiryPrefix, parser.ByteDelimiter}}, {[]byte{expiryPrefix, parser.ByteDelimiter}, []byte{balancePrefix, parser.ByteDelimiter}}, {[]byte{balancePrefix, parser.ByteDelimiter}, []byte{ownedPrefix, parser.ByteDelimiter}}, {[]byte{ownedPrefix, parser.ByteDelimiter}, []byte{ownedPrefix + 1, parser.ByteDelimiter}}, } )
var ErrInvalidKeyFormat = errors.New("invalid key format")
Functions ¶
func ApplyReward ¶
func CompactablePrefixKey ¶
func DigestHash ¶
func DigestHash(utx UnsignedTransaction) ([]byte, error)
func ExpireNext ¶
ExpireNext queries "expiryPrefix" key space to find expiring keys, deletes their spaceInfos, and schedules its key pruning with its raw space.
func GetAllOwned ¶
func GetBalance ¶
func GetLastAccepted ¶
func GetLastAccepted(db database.KeyValueReader) (ids.ID, error)
func HasSpaceKey ¶
func HasTransaction ¶
func ModifyBalance ¶
func MoveSpaceInfo ¶
func MoveSpaceInfo( db database.KeyValueWriterDeleter, oldOwner common.Address, space []byte, i *SpaceInfo, ) error
MoveSpaceInfo should only be used if the expiry isn't changing and SpaceInfo is already in the database.
func PrefixBalanceKey ¶
[balancePrefix] + [delimiter] + [address]
func PrefixBlockKey ¶
[blockPrefix] + [delimiter] + [blockID]
func PrefixExpiryKey ¶
[expiryPrefix] + [delimiter] + [timestamp] + [delimiter] + [rawSpace]
func PrefixOwnedKey ¶
[ownedPrefix] + [delimiter] + [address] + [delimiter] + [space]
func PrefixPruningKey ¶
[pruningPrefix] + [delimiter] + [timestamp] + [delimiter] + [rawSpace]
func PrefixTxValueKey ¶
[txValuePrefix] + [delimiter] + [txID]
func PruneNext ¶
PruneNext queries the keys that are currently marked with "pruningPrefix", and clears them from the database.
func PutSpaceInfo ¶
func PutSpaceKey ¶
func RangeTimeKey ¶
expiry/pruningPrefix + [delimiter] + [timestamp] + [delimiter]
func SetBalance ¶
func SetLastAccepted ¶
func SetLastAccepted(db database.KeyValueWriter, block *StatelessBlock) error
func SetTransaction ¶
func SetTransaction(db database.KeyValueWriter, tx *Transaction) error
func SpaceValueKey ¶
Assumes [space] and [key] do not contain delimiter [keyPrefix] + [delimiter] + [rawSpace] + [delimiter] + [key]
Types ¶
type Activity ¶
type Activity struct { Tmstmp int64 `serialize:"true" json:"timestamp"` TxID ids.ID `serialize:"true" json:"txId"` Typ string `serialize:"true" json:"type"` Sender string `serialize:"true" json:"sender,omitempty"` // empty when reward Space string `serialize:"true" json:"space,omitempty"` Key string `serialize:"true" json:"key,omitempty"` To string `serialize:"true" json:"to,omitempty"` // common.Address will be 0x000 when not populated Units uint64 `serialize:"true" json:"units,omitempty"` }
type BaseTx ¶
type BaseTx struct { // BlkID is the ID of a block in the [lookbackWindow]. BlockID ids.ID `serialize:"true" json:"blockId"` // Magic is a value defined in genesis to protect against replay attacks on // different VMs. Magic uint64 `serialize:"true" json:"magic"` // Price is the value per unit to spend on this transaction. Price uint64 `serialize:"true" json:"price"` }
func (*BaseTx) ExecuteBase ¶
func (*BaseTx) GetBlockID ¶
func (*BaseTx) SetBlockID ¶
type ClaimTx ¶
type ClaimTx struct { *BaseTx `serialize:"true" json:"baseTx"` // Space is the namespace for the "SpaceInfo" // whose owner can write and read value for the // specific key space. // The space must be ^[a-z0-9]{1,256}$. Space string `serialize:"true" json:"space"` }
func (*ClaimTx) Copy ¶
func (c *ClaimTx) Copy() UnsignedTransaction
func (*ClaimTx) Execute ¶
func (c *ClaimTx) Execute(t *TransactionContext) error
type CompactRange ¶
type CustomAllocation ¶
type DeleteTx ¶
type DeleteTx struct { *BaseTx `serialize:"true" json:"baseTx"` // Space is the namespace for the "SpaceInfo" // whose owner can write and read value for the // specific key space. // The space must be ^[a-z0-9]{1,256}$. Space string `serialize:"true" json:"space"` // Key is parsed from the given input, with its space removed. Key string `serialize:"true" json:"key"` }
func (*DeleteTx) Copy ¶
func (d *DeleteTx) Copy() UnsignedTransaction
func (*DeleteTx) Execute ¶
func (d *DeleteTx) Execute(t *TransactionContext) error
type Genesis ¶
type Genesis struct { Magic uint64 `serialize:"true" json:"magic"` // Tx params BaseTxUnits uint64 `serialize:"true" json:"baseTxUnits"` // SetTx params ValueUnitSize uint64 `serialize:"true" json:"valueUnitSize"` MaxValueSize uint64 `serialize:"true" json:"maxValueSize"` ValueExpiryDiscount uint64 `serialize:"true" json:"valueExpiryDiscount"` // Claim Params ClaimLoadMultiplier uint64 `serialize:"true" json:"claimLoadMultiplier"` MinClaimFee uint64 `serialize:"true" json:"minClaimFee"` SpaceDesirabilityMultiplier uint64 `serialize:"true" json:"spaceDesirabilityMultiplier"` // Lifeline Params SpaceRenewalDiscount uint64 `serialize:"true" json:"spaceRenewalDiscount"` // Reward Params ClaimReward uint64 `serialize:"true" json:"claimReward"` ClaimExpiryUnits uint64 `serialize:"true" json:"claimExpiryUnits"` // Mining Reward (% of min required fee) LotteryRewardMultipler uint64 `serialize:"true" json:"lotteryRewardMultipler"` // divided by 100 // Fee Mechanism Params MinPrice uint64 `serialize:"true" json:"minPrice"` LookbackWindow int64 `serialize:"true" json:"lookbackWindow"` TargetBlockRate int64 `serialize:"true" json:"targetBlockRate"` // seconds TargetBlockSize uint64 `serialize:"true" json:"targetBlockSize"` // units MaxBlockSize uint64 `serialize:"true" json:"maxBlockSize"` // units BlockCostEnabled bool `serialize:"true" json:"blockCostEnabled"` // Allocations CustomAllocation []*CustomAllocation `serialize:"true" json:"customAllocation"` AirdropHash string `serialize:"true" json:"airdropHash"` AirdropUnits uint64 `serialize:"true" json:"airdropUnits"` }
func DefaultGenesis ¶
func DefaultGenesis() *Genesis
func (*Genesis) StatefulBlock ¶
func (g *Genesis) StatefulBlock() *StatefulBlock
type Input ¶
type Input struct { Typ string `json:"type"` Space string `json:"space"` Key string `json:"key"` Value []byte `json:"value"` To common.Address `json:"to"` Units uint64 `json:"units"` }
func (*Input) Decode ¶
func (i *Input) Decode() (UnsignedTransaction, error)
type KeyValueMeta ¶
type KeyValueMeta struct { Key string `serialize:"true" json:"key"` ValueMeta *ValueMeta `serialize:"true" json:"valueMeta"` }
func GetAllValueMetas ¶
type LifelineTx ¶
type LifelineTx struct { *BaseTx `serialize:"true" json:"baseTx"` // Space is the namespace for the "SpaceInfo" // whose owner can write and read value for the // specific key space. // // The space must be ^[a-z0-9]{1,256}$. Space string `serialize:"true" json:"space"` // Units is the number of [ClaimReward] to extend // the life of the [Space]. Units uint64 `serialize:"true" json:"units"` }
func (*LifelineTx) Activity ¶
func (l *LifelineTx) Activity() *Activity
func (*LifelineTx) Copy ¶
func (l *LifelineTx) Copy() UnsignedTransaction
func (*LifelineTx) Execute ¶
func (l *LifelineTx) Execute(t *TransactionContext) error
func (*LifelineTx) FeeUnits ¶
func (l *LifelineTx) FeeUnits(g *Genesis) uint64
func (*LifelineTx) LoadUnits ¶
func (l *LifelineTx) LoadUnits(g *Genesis) uint64
func (*LifelineTx) TypedData ¶
func (l *LifelineTx) TypedData() *tdata.TypedData
type Mempool ¶
type Mempool interface { Len() int Prune(set.Set[ids.ID]) PopMax() (*Transaction, uint64) Add(*Transaction) bool NewTxs(uint64) []*Transaction }
type MockMempool ¶
type MockMempool struct {
// contains filtered or unexported fields
}
MockMempool is a mock of Mempool interface.
func NewMockMempool ¶
func NewMockMempool(ctrl *gomock.Controller) *MockMempool
NewMockMempool creates a new mock instance.
func (*MockMempool) EXPECT ¶
func (m *MockMempool) EXPECT() *MockMempoolMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockMempool) NewTxs ¶
func (m *MockMempool) NewTxs(arg0 uint64) []*Transaction
NewTxs mocks base method.
func (*MockMempool) PopMax ¶
func (m *MockMempool) PopMax() (*Transaction, uint64)
PopMax mocks base method.
type MockMempoolMockRecorder ¶
type MockMempoolMockRecorder struct {
// contains filtered or unexported fields
}
MockMempoolMockRecorder is the mock recorder for MockMempool.
func (*MockMempoolMockRecorder) Add ¶
func (mr *MockMempoolMockRecorder) Add(arg0 interface{}) *gomock.Call
Add indicates an expected call of Add.
func (*MockMempoolMockRecorder) Len ¶
func (mr *MockMempoolMockRecorder) Len() *gomock.Call
Len indicates an expected call of Len.
func (*MockMempoolMockRecorder) NewTxs ¶
func (mr *MockMempoolMockRecorder) NewTxs(arg0 interface{}) *gomock.Call
NewTxs indicates an expected call of NewTxs.
func (*MockMempoolMockRecorder) PopMax ¶
func (mr *MockMempoolMockRecorder) PopMax() *gomock.Call
PopMax indicates an expected call of PopMax.
func (*MockMempoolMockRecorder) Prune ¶
func (mr *MockMempoolMockRecorder) Prune(arg0 interface{}) *gomock.Call
Prune indicates an expected call of Prune.
type MockUnsignedTransaction ¶
type MockUnsignedTransaction struct {
// contains filtered or unexported fields
}
MockUnsignedTransaction is a mock of UnsignedTransaction interface.
func NewMockUnsignedTransaction ¶
func NewMockUnsignedTransaction(ctrl *gomock.Controller) *MockUnsignedTransaction
NewMockUnsignedTransaction creates a new mock instance.
func (*MockUnsignedTransaction) Activity ¶
func (m *MockUnsignedTransaction) Activity() *Activity
Activity mocks base method.
func (*MockUnsignedTransaction) Copy ¶
func (m *MockUnsignedTransaction) Copy() UnsignedTransaction
Copy mocks base method.
func (*MockUnsignedTransaction) EXPECT ¶
func (m *MockUnsignedTransaction) EXPECT() *MockUnsignedTransactionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockUnsignedTransaction) Execute ¶
func (m *MockUnsignedTransaction) Execute(arg0 *TransactionContext) error
Execute mocks base method.
func (*MockUnsignedTransaction) ExecuteBase ¶
func (m *MockUnsignedTransaction) ExecuteBase(arg0 *Genesis) error
ExecuteBase mocks base method.
func (*MockUnsignedTransaction) FeeUnits ¶
func (m *MockUnsignedTransaction) FeeUnits(arg0 *Genesis) uint64
FeeUnits mocks base method.
func (*MockUnsignedTransaction) GetBlockID ¶
func (m *MockUnsignedTransaction) GetBlockID() ids.ID
GetBlockID mocks base method.
func (*MockUnsignedTransaction) GetMagic ¶
func (m *MockUnsignedTransaction) GetMagic() uint64
GetMagic mocks base method.
func (*MockUnsignedTransaction) GetPrice ¶
func (m *MockUnsignedTransaction) GetPrice() uint64
GetPrice mocks base method.
func (*MockUnsignedTransaction) LoadUnits ¶
func (m *MockUnsignedTransaction) LoadUnits(arg0 *Genesis) uint64
LoadUnits mocks base method.
func (*MockUnsignedTransaction) SetBlockID ¶
func (m *MockUnsignedTransaction) SetBlockID(arg0 ids.ID)
SetBlockID mocks base method.
func (*MockUnsignedTransaction) SetMagic ¶
func (m *MockUnsignedTransaction) SetMagic(arg0 uint64)
SetMagic mocks base method.
func (*MockUnsignedTransaction) SetPrice ¶
func (m *MockUnsignedTransaction) SetPrice(arg0 uint64)
SetPrice mocks base method.
func (*MockUnsignedTransaction) TypedData ¶
func (m *MockUnsignedTransaction) TypedData() *tdata.TypedData
TypedData mocks base method.
type MockUnsignedTransactionMockRecorder ¶
type MockUnsignedTransactionMockRecorder struct {
// contains filtered or unexported fields
}
MockUnsignedTransactionMockRecorder is the mock recorder for MockUnsignedTransaction.
func (*MockUnsignedTransactionMockRecorder) Activity ¶
func (mr *MockUnsignedTransactionMockRecorder) Activity() *gomock.Call
Activity indicates an expected call of Activity.
func (*MockUnsignedTransactionMockRecorder) Copy ¶
func (mr *MockUnsignedTransactionMockRecorder) Copy() *gomock.Call
Copy indicates an expected call of Copy.
func (*MockUnsignedTransactionMockRecorder) Execute ¶
func (mr *MockUnsignedTransactionMockRecorder) Execute(arg0 interface{}) *gomock.Call
Execute indicates an expected call of Execute.
func (*MockUnsignedTransactionMockRecorder) ExecuteBase ¶
func (mr *MockUnsignedTransactionMockRecorder) ExecuteBase(arg0 interface{}) *gomock.Call
ExecuteBase indicates an expected call of ExecuteBase.
func (*MockUnsignedTransactionMockRecorder) FeeUnits ¶
func (mr *MockUnsignedTransactionMockRecorder) FeeUnits(arg0 interface{}) *gomock.Call
FeeUnits indicates an expected call of FeeUnits.
func (*MockUnsignedTransactionMockRecorder) GetBlockID ¶
func (mr *MockUnsignedTransactionMockRecorder) GetBlockID() *gomock.Call
GetBlockID indicates an expected call of GetBlockID.
func (*MockUnsignedTransactionMockRecorder) GetMagic ¶
func (mr *MockUnsignedTransactionMockRecorder) GetMagic() *gomock.Call
GetMagic indicates an expected call of GetMagic.
func (*MockUnsignedTransactionMockRecorder) GetPrice ¶
func (mr *MockUnsignedTransactionMockRecorder) GetPrice() *gomock.Call
GetPrice indicates an expected call of GetPrice.
func (*MockUnsignedTransactionMockRecorder) LoadUnits ¶
func (mr *MockUnsignedTransactionMockRecorder) LoadUnits(arg0 interface{}) *gomock.Call
LoadUnits indicates an expected call of LoadUnits.
func (*MockUnsignedTransactionMockRecorder) SetBlockID ¶
func (mr *MockUnsignedTransactionMockRecorder) SetBlockID(arg0 interface{}) *gomock.Call
SetBlockID indicates an expected call of SetBlockID.
func (*MockUnsignedTransactionMockRecorder) SetMagic ¶
func (mr *MockUnsignedTransactionMockRecorder) SetMagic(arg0 interface{}) *gomock.Call
SetMagic indicates an expected call of SetMagic.
func (*MockUnsignedTransactionMockRecorder) SetPrice ¶
func (mr *MockUnsignedTransactionMockRecorder) SetPrice(arg0 interface{}) *gomock.Call
SetPrice indicates an expected call of SetPrice.
func (*MockUnsignedTransactionMockRecorder) TypedData ¶
func (mr *MockUnsignedTransactionMockRecorder) TypedData() *gomock.Call
TypedData indicates an expected call of TypedData.
type MockVM ¶
type MockVM struct {
// contains filtered or unexported fields
}
MockVM is a mock of VM interface.
func NewMockVM ¶
func NewMockVM(ctrl *gomock.Controller) *MockVM
NewMockVM creates a new mock instance.
func (*MockVM) Accepted ¶
func (m *MockVM) Accepted(arg0 *StatelessBlock)
Accepted mocks base method.
func (*MockVM) EXPECT ¶
func (m *MockVM) EXPECT() *MockVMMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockVM) ExecutionContext ¶
func (m *MockVM) ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error)
ExecutionContext mocks base method.
func (*MockVM) GetStatelessBlock ¶
func (m *MockVM) GetStatelessBlock(arg0 ids.ID) (*StatelessBlock, error)
GetStatelessBlock mocks base method.
func (*MockVM) IsBootstrapped ¶
IsBootstrapped mocks base method.
func (*MockVM) Rejected ¶
func (m *MockVM) Rejected(arg0 *StatelessBlock)
Rejected mocks base method.
func (*MockVM) Verified ¶
func (m *MockVM) Verified(arg0 *StatelessBlock)
Verified mocks base method.
type MockVMMockRecorder ¶
type MockVMMockRecorder struct {
// contains filtered or unexported fields
}
MockVMMockRecorder is the mock recorder for MockVM.
func (*MockVMMockRecorder) Accepted ¶
func (mr *MockVMMockRecorder) Accepted(arg0 interface{}) *gomock.Call
Accepted indicates an expected call of Accepted.
func (*MockVMMockRecorder) ExecutionContext ¶
func (mr *MockVMMockRecorder) ExecutionContext(currentTime, parent interface{}) *gomock.Call
ExecutionContext indicates an expected call of ExecutionContext.
func (*MockVMMockRecorder) Genesis ¶
func (mr *MockVMMockRecorder) Genesis() *gomock.Call
Genesis indicates an expected call of Genesis.
func (*MockVMMockRecorder) GetStatelessBlock ¶
func (mr *MockVMMockRecorder) GetStatelessBlock(arg0 interface{}) *gomock.Call
GetStatelessBlock indicates an expected call of GetStatelessBlock.
func (*MockVMMockRecorder) IsBootstrapped ¶
func (mr *MockVMMockRecorder) IsBootstrapped() *gomock.Call
IsBootstrapped indicates an expected call of IsBootstrapped.
func (*MockVMMockRecorder) Mempool ¶
func (mr *MockVMMockRecorder) Mempool() *gomock.Call
Mempool indicates an expected call of Mempool.
func (*MockVMMockRecorder) Rejected ¶
func (mr *MockVMMockRecorder) Rejected(arg0 interface{}) *gomock.Call
Rejected indicates an expected call of Rejected.
func (*MockVMMockRecorder) State ¶
func (mr *MockVMMockRecorder) State() *gomock.Call
State indicates an expected call of State.
func (*MockVMMockRecorder) Verified ¶
func (mr *MockVMMockRecorder) Verified(arg0 interface{}) *gomock.Call
Verified indicates an expected call of Verified.
type MoveTx ¶
type MoveTx struct { *BaseTx `serialize:"true" json:"baseTx"` // Space is the namespace for the "SpaceInfo" // whose owner can write and read value for the // specific key space. // The space must be ^[a-z0-9]{1,256}$. Space string `serialize:"true" json:"space"` // To is the recipient of the Space. To common.Address `serialize:"true" json:"to"` }
func (*MoveTx) Copy ¶
func (m *MoveTx) Copy() UnsignedTransaction
func (*MoveTx) Execute ¶
func (m *MoveTx) Execute(c *TransactionContext) error
type SetTx ¶
type SetTx struct { *BaseTx `serialize:"true" json:"baseTx"` // Space is the namespace for the "SpaceInfo" // whose owner can write and read value for the // specific key space. // The space must be ^[a-z0-9]{1,256}$. Space string `serialize:"true" json:"space"` // Key is parsed from the given input, with its space removed. Key string `serialize:"true" json:"key"` // Value is written as the key-value pair to the storage. If a previous value // exists, it is overwritten. Value []byte `serialize:"true" json:"value"` }
func (*SetTx) Copy ¶
func (s *SetTx) Copy() UnsignedTransaction
func (*SetTx) Execute ¶
func (s *SetTx) Execute(t *TransactionContext) error
type SpaceInfo ¶
type SpaceInfo struct { Owner common.Address `serialize:"true" json:"owner"` Created uint64 `serialize:"true" json:"created"` Updated uint64 `serialize:"true" json:"updated"` Expiry uint64 `serialize:"true" json:"expiry"` Units uint64 `serialize:"true" json:"units"` // decays faster the more units you have RawSpace ids.ShortID `serialize:"true" json:"rawSpace"` }
func GetSpaceInfo ¶
type StatefulBlock ¶
type StatefulBlock struct { Prnt ids.ID `serialize:"true" json:"parent"` Tmstmp int64 `serialize:"true" json:"timestamp"` Hght uint64 `serialize:"true" json:"height"` Price uint64 `serialize:"true" json:"price"` Cost uint64 `serialize:"true" json:"cost"` Txs []*Transaction `serialize:"true" json:"txs"` }
func GetBlock ¶
func GetBlock(db database.KeyValueReader, bid ids.ID) (*StatefulBlock, error)
func (*StatefulBlock) Dummy ¶
func (b *StatefulBlock) Dummy() bool
type StatelessBlock ¶
type StatelessBlock struct { *StatefulBlock `serialize:"true" json:"block"` Winners map[ids.ID]*Activity // contains filtered or unexported fields }
Stateless is defined separately from "Block" in case external packages needs use the stateful block without mocking VM or parent block
func DummyBlock ¶
func DummyBlock(tmstp int64, tx *Transaction) *StatelessBlock
DummyBlock is used for validating new txs and some tests
func ParseBlock ¶
func ParseStatefulBlock ¶
func ParseStatefulBlock( blk *StatefulBlock, source []byte, status choices.Status, vm VM, ) (*StatelessBlock, error)
func (*StatelessBlock) Accept ¶
func (b *StatelessBlock) Accept(ctx context.Context) error
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) ID ¶
func (b *StatelessBlock) ID() ids.ID
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) Reject ¶
func (b *StatelessBlock) Reject(ctx context.Context) error
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) SetChildrenDB ¶
func (b *StatelessBlock) SetChildrenDB(db database.Database) error
func (*StatelessBlock) Status ¶
func (b *StatelessBlock) Status() choices.Status
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) Timestamp ¶
func (b *StatelessBlock) Timestamp() time.Time
implements "snowman.Block"
type Transaction ¶
type Transaction struct { UnsignedTransaction `serialize:"true" json:"unsignedTransaction"` Signature []byte `serialize:"true" json:"signature"` // contains filtered or unexported fields }
func NewTx ¶
func NewTx(utx UnsignedTransaction, sig []byte) *Transaction
func (*Transaction) Activity ¶
func (t *Transaction) Activity() *Activity
func (*Transaction) Bytes ¶
func (t *Transaction) Bytes() []byte
func (*Transaction) Copy ¶
func (t *Transaction) Copy() *Transaction
func (*Transaction) DigestHash ¶
func (t *Transaction) DigestHash() []byte
func (*Transaction) Execute ¶
func (t *Transaction) Execute(g *Genesis, db database.Database, blk *StatelessBlock, context *Context) error
func (*Transaction) ID ¶
func (t *Transaction) ID() ids.ID
func (*Transaction) Init ¶
func (t *Transaction) Init(g *Genesis) error
func (*Transaction) Sender ¶
func (t *Transaction) Sender() common.Address
func (*Transaction) Size ¶
func (t *Transaction) Size() uint64
type TransactionContext ¶
type TransferTx ¶
type TransferTx struct { *BaseTx `serialize:"true" json:"baseTx"` // To is the recipient of the [Units]. To common.Address `serialize:"true" json:"to"` // Units are transferred to [To]. Units uint64 `serialize:"true" json:"units"` }
func (*TransferTx) Activity ¶
func (t *TransferTx) Activity() *Activity
func (*TransferTx) Copy ¶
func (t *TransferTx) Copy() UnsignedTransaction
func (*TransferTx) Execute ¶
func (t *TransferTx) Execute(c *TransactionContext) error
func (*TransferTx) TypedData ¶
func (t *TransferTx) TypedData() *tdata.TypedData
type UnsignedTransaction ¶
type UnsignedTransaction interface { Copy() UnsignedTransaction GetBlockID() ids.ID GetMagic() uint64 GetPrice() uint64 SetBlockID(ids.ID) SetMagic(uint64) SetPrice(uint64) FeeUnits(*Genesis) uint64 // number of units to mine tx LoadUnits(*Genesis) uint64 // units that should impact fee rate ExecuteBase(*Genesis) error Execute(*TransactionContext) error TypedData() *tdata.TypedData Activity() *Activity }
func ParseTypedData ¶
func ParseTypedData(td *tdata.TypedData) (UnsignedTransaction, error)
type VM ¶
type VM interface { Genesis() *Genesis IsBootstrapped() bool State() database.Database Mempool() Mempool GetStatelessBlock(ids.ID) (*StatelessBlock, error) ExecutionContext(currentTime int64, parent *StatelessBlock) (*Context, error) Verified(*StatelessBlock) Rejected(*StatelessBlock) Accepted(*StatelessBlock) }