Documentation ¶
Index ¶
- Constants
- Variables
- func ActorCodeTypeName(code cid.Cid) string
- func AssertCidsEqual(a *assert.Assertions, m cid.Cid, n cid.Cid)
- func AssertHaveSameCid(a *assert.Assertions, m HasCid, n HasCid)
- func BigToFixed(f *big.Float) (uint64, error)
- func FixedStr(fixed uint64) (string, error)
- func FixedToBig(fixed uint64) (*big.Float, error)
- func GenerateKeyInfoSeed() io.Reader
- func IsValidSignature(data []byte, addr address.Address, sig Signature) bool
- func MsgCidsEqual(m1, m2 *Message) bool
- func NewCidForTestGetter() func() cid.Cid
- func NewMessageForTestGetter() func() *Message
- func NewMockSignersAndKeyInfo(numSigners int) (MockSigner, []KeyInfo)
- func NewSignedMessageForTestGetter(ms MockSigner) func() *SignedMessage
- func NewTestPoSt() [192]byte
- func SmsgCidsEqual(m1, m2 *SignedMessage) bool
- func SomeCid() cid.Cid
- func SortBlocks(blks []*Block)
- type AttoFIL
- func NewAttoFIL(x *big.Int) *AttoFIL
- func NewAttoFILFromBytes(buf []byte) *AttoFIL
- func NewAttoFILFromFIL(x uint64) *AttoFIL
- func NewAttoFILFromFILString(s string) (*AttoFIL, bool)
- func NewAttoFILFromString(s string, base int) (*AttoFIL, bool)
- func NewGasPrice(price int64) AttoFIL
- func NewZeroAttoFIL() *AttoFIL
- func (z *AttoFIL) Add(y *AttoFIL) *AttoFIL
- func (z *AttoFIL) Bytes() []byte
- func (z *AttoFIL) CalculatePrice(numBytes *BytesAmount) *AttoFIL
- func (z *AttoFIL) DivCeil(y *AttoFIL) *AttoFIL
- func (z *AttoFIL) Equal(y *AttoFIL) bool
- func (z *AttoFIL) GreaterEqual(y *AttoFIL) bool
- func (z *AttoFIL) GreaterThan(y *AttoFIL) bool
- func (z *AttoFIL) IsNegative() bool
- func (z *AttoFIL) IsPositive() bool
- func (z *AttoFIL) IsZero() bool
- func (z *AttoFIL) LessEqual(y *AttoFIL) bool
- func (z *AttoFIL) LessThan(y *AttoFIL) bool
- func (z AttoFIL) MarshalJSON() ([]byte, error)
- func (z *AttoFIL) MulBigInt(x *big.Int) *AttoFIL
- func (z *AttoFIL) String() string
- func (z *AttoFIL) Sub(y *AttoFIL) *AttoFIL
- func (z *AttoFIL) UnmarshalJSON(b []byte) error
- type Block
- type BlockHeight
- func (z *BlockHeight) Add(y *BlockHeight) *BlockHeight
- func (z *BlockHeight) AsBigInt() *big.Int
- func (z *BlockHeight) Bytes() []byte
- func (z *BlockHeight) Equal(y *BlockHeight) bool
- func (z *BlockHeight) GreaterEqual(y *BlockHeight) bool
- func (z *BlockHeight) GreaterThan(y *BlockHeight) bool
- func (z *BlockHeight) LessEqual(y *BlockHeight) bool
- func (z *BlockHeight) LessThan(y *BlockHeight) bool
- func (z BlockHeight) MarshalJSON() ([]byte, error)
- func (z *BlockHeight) String() string
- func (z *BlockHeight) Sub(y *BlockHeight) *BlockHeight
- func (z *BlockHeight) UnmarshalJSON(b []byte) error
- type BytesAmount
- func (z *BytesAmount) Add(y *BytesAmount) *BytesAmount
- func (z *BytesAmount) Bytes() []byte
- func (z *BytesAmount) Equal(y *BytesAmount) bool
- func (z *BytesAmount) GreaterEqual(y *BytesAmount) bool
- func (z *BytesAmount) GreaterThan(y *BytesAmount) bool
- func (z *BytesAmount) IsNegative() bool
- func (z *BytesAmount) IsPositive() bool
- func (z *BytesAmount) IsZero() bool
- func (z *BytesAmount) LessEqual(y *BytesAmount) bool
- func (z *BytesAmount) LessThan(y *BytesAmount) bool
- func (z BytesAmount) MarshalJSON() ([]byte, error)
- func (z *BytesAmount) Mul(y *BytesAmount) *BytesAmount
- func (z *BytesAmount) String() string
- func (z *BytesAmount) Sub(y *BytesAmount) *BytesAmount
- func (z *BytesAmount) Uint64() uint64
- func (z *BytesAmount) UnmarshalJSON(b []byte) error
- type ChannelID
- type Commitments
- type GasUnits
- type HasCid
- type KeyInfo
- type Message
- type MessageMaker
- type MessageReceipt
- type MeteredMessage
- type MockRecoverer
- type MockSigner
- type Recoverer
- type Signature
- type SignedMessage
- func (smsg *SignedMessage) Cid() (cid.Cid, error)
- func (smsg *SignedMessage) Equals(other *SignedMessage) bool
- func (smsg *SignedMessage) Marshal() ([]byte, error)
- func (smsg *SignedMessage) RecoverAddress(r Recoverer) (address.Address, error)
- func (smsg *SignedMessage) String() string
- func (smsg *SignedMessage) Unmarshal(b []byte) error
- func (smsg *SignedMessage) VerifySignature() bool
- type Signer
- type SortedCidSet
- func (s *SortedCidSet) Add(id cid.Cid) bool
- func (s *SortedCidSet) Clear()
- func (s *SortedCidSet) Contains(s2 *SortedCidSet) bool
- func (s SortedCidSet) Empty() bool
- func (s SortedCidSet) Equals(s2 SortedCidSet) bool
- func (s SortedCidSet) Has(id cid.Cid) bool
- func (s SortedCidSet) Iter() SortedCidSetIterator
- func (s SortedCidSet) Len() int
- func (s SortedCidSet) MarshalJSON() ([]byte, error)
- func (s *SortedCidSet) Remove(id cid.Cid) bool
- func (s SortedCidSet) String() string
- func (s SortedCidSet) ToSlice() []cid.Cid
- func (s *SortedCidSet) UnmarshalJSON(b []byte) error
- type SortedCidSetIterator
- type Tip
- type TipSet
- func (ts TipSet) AddBlock(b *Block) error
- func (ts TipSet) Clone() TipSet
- func (ts TipSet) Equals(ts2 TipSet) bool
- func (ts TipSet) Height() (uint64, error)
- func (ts TipSet) MinTicket() (Signature, error)
- func (ts TipSet) ParentWeight() (uint64, error)
- func (ts TipSet) Parents() (SortedCidSet, error)
- func (ts TipSet) String() string
- func (ts TipSet) ToSlice() []*Block
- func (ts TipSet) ToSortedCidSet() SortedCidSet
- type Uint64
Constants ¶
const DefaultHashFunction = mh.BLAKE2B_MIN + 31
DefaultHashFunction represents the default hashing function to use
const MaxFixedPointIntegralNum = 18014398509481983 // (2^54 - 1)
MaxFixedPointIntegralNum is the largest whole number that can be encoded as a fixed point.
const (
// SECP256K1 is a curve used to compute private keys
SECP256K1 = "secp256k1"
)
Variables ¶
var ( // ErrMessageSigned is returned when `Sign()` is called on a signedmessage that has previously been signed ErrMessageSigned = errors.New("message already contains a signature") // ErrMessageUnsigned is returned when `RecoverAddress` is called on a signedmessage that does not contain a signature ErrMessageUnsigned = errors.New("message does not contain a signature") )
var AccountActorCodeCid cid.Cid
AccountActorCodeCid is the cid of the above object
var AccountActorCodeObj ipld.Node
AccountActorCodeObj is the code representation of the builtin account actor.
var ActorCodeCidTypeNames = make(map[cid.Cid]string)
ActorCodeCidTypeNames maps Actor codeCid's to the name of the associated Actor type.
var BlockGasLimit = NewGasUnits(10000000)
BlockGasLimit is the maximum amount of gas that can be used to execute messages in a single block
var BootstrapMinerActorCodeCid cid.Cid
BootstrapMinerActorCodeCid is the cid of the above object
var BootstrapMinerActorCodeObj ipld.Node
BootstrapMinerActorCodeObj is the code representation of the bootstrap miner actor.
var ( // ErrEmptyTipSet is returned when a method requiring a non-empty tipset is called on an empty tipset ErrEmptyTipSet = errors.New("empty tipset calling unallowed method") )
var ( // ErrInvalidMessageLength is returned when the message length does not match the expected length. ErrInvalidMessageLength = errors.New("invalid message length") )
var MinerActorCodeCid cid.Cid
MinerActorCodeCid is the cid of the above object
var MinerActorCodeObj ipld.Node
MinerActorCodeObj is the code representation of the builtin miner actor.
var PaymentBrokerActorCodeCid cid.Cid
PaymentBrokerActorCodeCid is the cid of the above object
var PaymentBrokerActorCodeObj ipld.Node
PaymentBrokerActorCodeObj is the code representation of the builtin payment broker actor.
var StorageMarketActorCodeCid cid.Cid
StorageMarketActorCodeCid is the cid of the above object
var StorageMarketActorCodeObj ipld.Node
StorageMarketActorCodeObj is the code representation of the builtin storage market actor.
Functions ¶
func ActorCodeTypeName ¶
func ActorCodeTypeName(code cid.Cid) string
ActorCodeTypeName returns the (string) name of the Go type of the actor with cid, code.
func AssertCidsEqual ¶
func AssertCidsEqual(a *assert.Assertions, m cid.Cid, n cid.Cid)
AssertCidsEqual asserts that two CIDS are identical.
func AssertHaveSameCid ¶
func AssertHaveSameCid(a *assert.Assertions, m HasCid, n HasCid)
AssertHaveSameCid asserts that two values have identical CIDs.
func BigToFixed ¶
BigToFixed takes in a big Float and returns a uint64 encoded fixed point.
func FixedStr ¶
FixedStr returns a printable string with the correct decimal place for the input uint64 encoded fixed point number.
func FixedToBig ¶
FixedToBig takes in a uint64 encoded fixed point and returns a big Float.
func GenerateKeyInfoSeed ¶
GenerateKeyInfoSeed returns a random to be passed to MustGenerateKeyInfo
func IsValidSignature ¶
IsValidSignature cryptographically verifies that 'sig' is the signed hash of 'data' with the public key belonging to `addr`.
func MsgCidsEqual ¶
MsgCidsEqual returns true if the message cids are equal. It panics if it can't get their cid.
func NewCidForTestGetter ¶
func NewCidForTestGetter() func() cid.Cid
NewCidForTestGetter returns a closure that returns a Cid unique to that invocation. The Cid is unique wrt the closure returned, not globally. You can use this function in tests.
func NewMessageForTestGetter ¶
func NewMessageForTestGetter() func() *Message
NewMessageForTestGetter returns a closure that returns a message unique to that invocation. The message is unique wrt the closure returned, not globally. You can use this function in tests instead of manually creating messages -- it both reduces duplication and gives us exactly one place to create valid messages for tests if messages require validation in the future.
func NewMockSignersAndKeyInfo ¶
func NewMockSignersAndKeyInfo(numSigners int) (MockSigner, []KeyInfo)
NewMockSignersAndKeyInfo is a convenience function to generate a mock signers with some keys.
func NewSignedMessageForTestGetter ¶
func NewSignedMessageForTestGetter(ms MockSigner) func() *SignedMessage
NewSignedMessageForTestGetter returns a closure that returns a SignedMessage unique to that invocation. The message is unique wrt the closure returned, not globally. You can use this function in tests instead of manually creating messages -- it both reduces duplication and gives us exactly one place to create valid messages for tests if messages require validation in the future. TODO support chosing from address
func NewTestPoSt ¶
func NewTestPoSt() [192]byte
NewTestPoSt creates a trivial, right-sized byte slice for a Proof of Spacetime.
func SmsgCidsEqual ¶
func SmsgCidsEqual(m1, m2 *SignedMessage) bool
SmsgCidsEqual returns true if the SignedMessage cids are equal. It panics if it can't get their cid.
func SomeCid ¶
func SomeCid() cid.Cid
SomeCid generates a Cid for use in tests where you want a Cid but don't care what it is.
func SortBlocks ¶
func SortBlocks(blks []*Block)
SortBlocks sorts a slice of blocks in the canonical order (by min tickets)
Types ¶
type AttoFIL ¶
type AttoFIL struct {
// contains filtered or unexported fields
}
AttoFIL represents a signed multi-precision integer quantity of attofilecoin (atto is metric for 10**-18). The zero value for AttoFIL represents the value 0.
var ZeroAttoFIL *AttoFIL
ZeroAttoFIL represents an AttoFIL quantity of 0
func NewAttoFIL ¶
NewAttoFIL allocates and returns a new AttoFIL set to x.
func NewAttoFILFromBytes ¶
NewAttoFILFromBytes allocates and returns a new AttoFIL set to the value of buf as the bytes of a big-endian unsigned integer.
func NewAttoFILFromFIL ¶
NewAttoFILFromFIL returns a new AttoFIL representing a quantity of attofilecoin equal to x filecoin.
func NewAttoFILFromFILString ¶
NewAttoFILFromFILString allocates a new AttoFIL set to the value of s filecoin, interpreted as a decimal in base 10, and returns it and a boolean indicating success.
func NewAttoFILFromString ¶
NewAttoFILFromString allocates a new AttoFIL set to the value of s attofilecoin, interpreted in the given base, and returns it and a boolean indicating success.
func NewGasPrice ¶
NewGasPrice constructs a gas price (in AttoFIL) from the given number.
func NewZeroAttoFIL ¶
func NewZeroAttoFIL() *AttoFIL
NewZeroAttoFIL returns a new zero quantity of attofilecoin. It is different from ZeroAttoFIL in that this value may be used/mutated.
func (*AttoFIL) CalculatePrice ¶
func (z *AttoFIL) CalculatePrice(numBytes *BytesAmount) *AttoFIL
CalculatePrice treats z as a price in AttoFIL/Byte and applies it to numBytes to calculate a total price.
func (*AttoFIL) DivCeil ¶
DivCeil returns the minimum number of times this value can be divided into smaller amounts such that none of the smaller amounts are greater than the given divisor. Equal to ceil(z/y) if AttoFIL could be fractional. If y is zero a panic will occur.
func (*AttoFIL) GreaterEqual ¶
GreaterEqual returns true if z >= y
func (*AttoFIL) GreaterThan ¶
GreaterThan returns true if z > y
func (*AttoFIL) IsNegative ¶
IsNegative returns true if z is less than zero.
func (*AttoFIL) IsPositive ¶
IsPositive returns true if z is greater than zero.
func (AttoFIL) MarshalJSON ¶
MarshalJSON converts an AttoFIL to a byte array and returns it.
func (*AttoFIL) UnmarshalJSON ¶
UnmarshalJSON converts a byte array to an AttoFIL.
type Block ¶
type Block struct { // Miner is the address of the miner actor that mined this block. Miner address.Address `json:"miner"` // Ticket is the winning ticket that was submitted with this block. Ticket Signature `json:"ticket"` // Parents is the set of parents this block was based on. Typically one, // but can be several in the case where there were multiple winning ticket- // holders for an epoch. Parents SortedCidSet `json:"parents"` // ParentWeight is the aggregate chain weight of the parent set. ParentWeight Uint64 `json:"parentWeight"` // Height is the chain height of this block. Height Uint64 `json:"height"` // Nonce is a temporary field used to differentiate blocks for testing Nonce Uint64 `json:"nonce"` // Messages is the set of messages included in this block // TODO: should be a merkletree-ish thing Messages []*SignedMessage `json:"messages"` // StateRoot is a cid pointer to the state tree after application of the // transactions state transitions. StateRoot cid.Cid `json:"stateRoot,omitempty" refmt:",omitempty"` // MessageReceipts is a set of receipts matching to the sending of the `Messages`. MessageReceipts []*MessageReceipt `json:"messageReceipts"` // Proof is a proof of spacetime generated using the hash of the previous ticket as // a challenge Proof proofs.PoStProof `json:"proof"` // contains filtered or unexported fields }
Block is a block in the blockchain.
func DecodeBlock ¶
DecodeBlock decodes raw cbor bytes into a Block.
func NewBlockForTest ¶
NewBlockForTest returns a new block. If a parent block is provided, the returned block will be configured as if it were a child of that parent. The returned block has not been persisted into the store.
func (Block) IsParentOf ¶
IsParentOf returns true if the argument is a parent of the receiver.
type BlockHeight ¶
type BlockHeight struct {
// contains filtered or unexported fields
}
An BlockHeight is a signed multi-precision integer.
func NewBlockHeight ¶
func NewBlockHeight(x uint64) *BlockHeight
NewBlockHeight allocates and returns a new BlockHeight set to x.
func NewBlockHeightFromBytes ¶
func NewBlockHeightFromBytes(buf []byte) *BlockHeight
NewBlockHeightFromBytes allocates and returns a new BlockHeight set to the value of buf as the bytes of a big-endian unsigned integer.
func NewBlockHeightFromString ¶
func NewBlockHeightFromString(s string, base int) (*BlockHeight, bool)
NewBlockHeightFromString allocates a new BlockHeight set to the value of s, interpreted in the given base, and returns it and a boolean indicating success.
func (*BlockHeight) Add ¶
func (z *BlockHeight) Add(y *BlockHeight) *BlockHeight
Add adds the given value to the current value and returns a copy
func (*BlockHeight) AsBigInt ¶
func (z *BlockHeight) AsBigInt() *big.Int
AsBigInt returns the blockheight as a big.Int
func (*BlockHeight) Bytes ¶
func (z *BlockHeight) Bytes() []byte
Bytes returns the absolute value of x as a big-endian byte slice.
func (*BlockHeight) Equal ¶
func (z *BlockHeight) Equal(y *BlockHeight) bool
Equal returns true if z = y
func (*BlockHeight) GreaterEqual ¶
func (z *BlockHeight) GreaterEqual(y *BlockHeight) bool
GreaterEqual returns true if z >= y
func (*BlockHeight) GreaterThan ¶
func (z *BlockHeight) GreaterThan(y *BlockHeight) bool
GreaterThan returns true if z > y
func (*BlockHeight) LessEqual ¶
func (z *BlockHeight) LessEqual(y *BlockHeight) bool
LessEqual returns true if z <= y
func (*BlockHeight) LessThan ¶
func (z *BlockHeight) LessThan(y *BlockHeight) bool
LessThan returns true if z < y
func (BlockHeight) MarshalJSON ¶
func (z BlockHeight) MarshalJSON() ([]byte, error)
MarshalJSON converts a BlockHeight to a byte array and returns it.
func (*BlockHeight) String ¶
func (z *BlockHeight) String() string
String returns a string version of the ID
func (*BlockHeight) Sub ¶
func (z *BlockHeight) Sub(y *BlockHeight) *BlockHeight
Sub subtracts y from a copy of z and returns the copy.
func (*BlockHeight) UnmarshalJSON ¶
func (z *BlockHeight) UnmarshalJSON(b []byte) error
UnmarshalJSON converts a byte array to a BlockHeight.
type BytesAmount ¶
type BytesAmount struct {
// contains filtered or unexported fields
}
An BytesAmount represents a signed multi-precision integer. The zero value for a BytesAmount represents the value 0.
var ZeroBytes *BytesAmount
ZeroBytes represents a BytesAmount of 0
func NewBytesAmount ¶
func NewBytesAmount(x uint64) *BytesAmount
NewBytesAmount allocates and returns a new BytesAmount set to x.
func NewBytesAmountFromBytes ¶
func NewBytesAmountFromBytes(buf []byte) *BytesAmount
NewBytesAmountFromBytes allocates and returns a new BytesAmount set to the value of buf as the bytes of a big-endian unsigned integer.
func NewBytesAmountFromString ¶
func NewBytesAmountFromString(s string, base int) (*BytesAmount, bool)
NewBytesAmountFromString allocates a new BytesAmount set to the value of s, interpreted in the given base, and returns it and a boolean indicating success.
func (*BytesAmount) Add ¶
func (z *BytesAmount) Add(y *BytesAmount) *BytesAmount
Add sets z to the sum x+y and returns z.
func (*BytesAmount) Bytes ¶
func (z *BytesAmount) Bytes() []byte
Bytes returns the absolute value of x as a big-endian byte slice.
func (*BytesAmount) Equal ¶
func (z *BytesAmount) Equal(y *BytesAmount) bool
Equal returns true if z = y
func (*BytesAmount) GreaterEqual ¶
func (z *BytesAmount) GreaterEqual(y *BytesAmount) bool
GreaterEqual returns true if z >= y
func (*BytesAmount) GreaterThan ¶
func (z *BytesAmount) GreaterThan(y *BytesAmount) bool
GreaterThan returns true if z > y
func (*BytesAmount) IsNegative ¶
func (z *BytesAmount) IsNegative() bool
IsNegative returns true if z is less than zero.
func (*BytesAmount) IsPositive ¶
func (z *BytesAmount) IsPositive() bool
IsPositive returns true if z is greater than zero.
func (*BytesAmount) IsZero ¶
func (z *BytesAmount) IsZero() bool
IsZero returns true if z equals zero.
func (*BytesAmount) LessEqual ¶
func (z *BytesAmount) LessEqual(y *BytesAmount) bool
LessEqual returns true if z <= y
func (*BytesAmount) LessThan ¶
func (z *BytesAmount) LessThan(y *BytesAmount) bool
LessThan returns true if z < y
func (BytesAmount) MarshalJSON ¶
func (z BytesAmount) MarshalJSON() ([]byte, error)
MarshalJSON converts a BytesAmount to a byte array and returns it.
func (*BytesAmount) Mul ¶
func (z *BytesAmount) Mul(y *BytesAmount) *BytesAmount
Mul sets z to x*y and returns z.
func (*BytesAmount) String ¶
func (z *BytesAmount) String() string
func (*BytesAmount) Sub ¶
func (z *BytesAmount) Sub(y *BytesAmount) *BytesAmount
Sub sets z to the difference x-y and returns z.
func (*BytesAmount) Uint64 ¶
func (z *BytesAmount) Uint64() uint64
Uint64 returns the uint64 representation of x. If x cannot be represented in a uint64, the result is undefined.
func (*BytesAmount) UnmarshalJSON ¶
func (z *BytesAmount) UnmarshalJSON(b []byte) error
UnmarshalJSON converts a byte array to a BytesAmount.
type ChannelID ¶
type ChannelID struct {
// contains filtered or unexported fields
}
An ChannelID is a signed multi-precision integer.
func NewChannelID ¶
NewChannelID allocates and returns a new ChannelID set to x.
func NewChannelIDFromBytes ¶
NewChannelIDFromBytes allocates and returns a new ChannelID set to the value of buf as the bytes of a big-endian unsigned integer.
func NewChannelIDFromString ¶
NewChannelIDFromString allocates a new ChannelID set to the value of s, interpreted in the given base, and returns it and a boolean indicating success.
func (ChannelID) MarshalJSON ¶
MarshalJSON converts a ChannelID to a byte array and returns it.
func (*ChannelID) UnmarshalJSON ¶
UnmarshalJSON converts a byte array to a ChannelID.
type Commitments ¶
Commitments is a struct containing the replica and data commitments produced when sealing a sector.
type GasUnits ¶
type GasUnits = Uint64
GasUnits represents number of units of gas consumed
func NewGasUnits ¶
NewGasUnits constructs a new GasUnits from the given number.
type HasCid ¶
type HasCid interface {
Cid() cid.Cid
}
HasCid allows two values with CIDs to be compared.
type KeyInfo ¶
type KeyInfo struct { // Private key. PrivateKey []byte `json:"privateKey"` // Curve used to generate private key. Curve string `json:"curve"` }
KeyInfo is a key and its type used for signing.
func MustGenerateKeyInfo ¶
MustGenerateKeyInfo generates a slice of KeyInfo size `n` with seed `seed`
type Message ¶
type Message struct { To address.Address `json:"to"` From address.Address `json:"from"` // When receiving a message from a user account the nonce in // the message must match the expected nonce in the from actor. // This prevents replay attacks. Nonce Uint64 `json:"nonce"` Value *AttoFIL `json:"value"` Method string `json:"method"` Params []byte `json:"params"` }
Message is an exchange of information between two actors modeled as a function call. Messages are the equivalent of transactions in Ethereum.
func NewMessage ¶
func NewMessage(from, to address.Address, nonce uint64, value *AttoFIL, method string, params []byte) *Message
NewMessage creates a new message.
func NewMsgs ¶
NewMsgs returns n messages. The messages returned are unique to this invocation but are not unique globally (ie, a second call to NewMsgs will return the same set of messages).
func NewMsgsWithAddrs ¶
NewMsgsWithAddrs returns a slice of `n` messages who's `From` field's are pulled from `a`. This method should be used when the addresses returned are to be signed at a later point.
func (*Message) Cid ¶
Cid returns the canonical CID for the message. TODO: can we avoid returning an error?
type MessageMaker ¶
type MessageMaker struct { DefaultGasPrice AttoFIL DefaultGasUnits GasUnits // contains filtered or unexported fields }
MessageMaker creates unique, signed messages for use in tests.
func NewMessageMaker ¶
func NewMessageMaker(t *testing.T, keys []KeyInfo) *MessageMaker
NewMessageMaker creates a new message maker with a set of signing keys.
func (*MessageMaker) Addresses ¶
func (mm *MessageMaker) Addresses() []address.Address
Addresses returns the addresses for which this maker can sign messages.
func (*MessageMaker) NewSignedMessage ¶
func (mm *MessageMaker) NewSignedMessage(from address.Address, nonce uint64) *SignedMessage
NewSignedMessage creates a new message.
func (*MessageMaker) Signer ¶
func (mm *MessageMaker) Signer() *MockSigner
Signer returns the signer with which this maker signs messages.
type MessageReceipt ¶
type MessageReceipt struct { // `0` is success, anything else is an error code in unix style. ExitCode uint8 `json:"exitCode"` // Return contains the return values, if any, from processing a message. // This can be non-empty even in the case of error (e.g., to provide // programmatically readable detail about errors). Return [][]byte `json:"return"` // GasAttoFIL Charge is the actual amount of FIL transferred from the sender to the miner for processing the message GasAttoFIL *AttoFIL `json:"gasAttoFIL"` }
MessageReceipt represents the result of sending a message.
type MeteredMessage ¶
type MeteredMessage struct { Message `json:"message"` GasPrice AttoFIL `json:"gasPrice"` GasLimit GasUnits `json:"gasLimit"` }
MeteredMessage contains a message and its associated gas price and gas limit
func NewMeteredMessage ¶
func NewMeteredMessage(msg Message, gasPrice AttoFIL, gasLimit GasUnits) *MeteredMessage
NewMeteredMessage accepts a message `msg`, a gas price `gasPrice` and a `gasLimit`. It returns a network message with the message, gas price and gas limit included.
func (*MeteredMessage) Equals ¶
func (msg *MeteredMessage) Equals(other *MeteredMessage) bool
Equals tests whether two metered messages are equal
func (*MeteredMessage) Marshal ¶
func (msg *MeteredMessage) Marshal() ([]byte, error)
Marshal the message into bytes.
func (*MeteredMessage) Unmarshal ¶
func (msg *MeteredMessage) Unmarshal(b []byte) error
Unmarshal a message from the given bytes.
type MockRecoverer ¶
type MockRecoverer struct{}
MockRecoverer implements the Recoverer interface
func (*MockRecoverer) Ecrecover ¶
func (mr *MockRecoverer) Ecrecover(data []byte, sig Signature) ([]byte, error)
Ecrecover returns an uncompressed public key that could produce the given signature from data. Note: The returned public key should not be used to verify `data` is valid since a public key may have N private key pairs
type MockSigner ¶
type MockSigner struct { AddrKeyInfo map[address.Address]KeyInfo Addresses []address.Address PubKeys [][]byte }
MockSigner implements the Signer interface
func NewMockSigner ¶
func NewMockSigner(kis []KeyInfo) MockSigner
NewMockSigner returns a new mock signer, capable of signing data with keys (addresses derived from) in keyinfo
func (MockSigner) CreateTicket ¶
CreateTicket is effectively a duplicate of Wallet CreateTicket for testing purposes.
func (MockSigner) GetAddressForPubKey ¶
func (ms MockSigner) GetAddressForPubKey(pk []byte) (address.Address, error)
GetAddressForPubKey looks up a KeyInfo address associated with a given PublicKey for a MockSigner
type SignedMessage ¶
type SignedMessage struct { MeteredMessage `json:"meteredMessage"` Signature Signature `json:"signature"` }
SignedMessage contains a message and its signature TODO do not export these fields as it increases the chances of producing a `SignedMessage` with an empty signature.
func NewSignedMessage ¶
func NewSignedMessage(msg Message, s Signer, gasPrice AttoFIL, gasLimit GasUnits) (*SignedMessage, error)
NewSignedMessage accepts a message `msg` and a signer `s`. NewSignedMessage returns a `SignedMessage` containing a signature derived from the serialized `msg` and `msg.From`
func NewSignedMsgs ¶
func NewSignedMsgs(n int, ms MockSigner) []*SignedMessage
NewSignedMsgs returns n signed messages. The messages returned are unique to this invocation but are not unique globally (ie, a second call to NewSignedMsgs will return the same set of messages).
func SignMsgs ¶
func SignMsgs(ms MockSigner, msgs []*Message) ([]*SignedMessage, error)
SignMsgs returns a slice of signed messages where the original messages are `msgs`, if signing one of the `msgs` fails an error is returned
func (*SignedMessage) Cid ¶
func (smsg *SignedMessage) Cid() (cid.Cid, error)
Cid returns the canonical CID for the SignedMessage. TODO: can we avoid returning an error?
func (*SignedMessage) Equals ¶
func (smsg *SignedMessage) Equals(other *SignedMessage) bool
Equals tests whether two signed messages are equal.
func (*SignedMessage) Marshal ¶
func (smsg *SignedMessage) Marshal() ([]byte, error)
Marshal the SignedMessage into bytes.
func (*SignedMessage) RecoverAddress ¶
func (smsg *SignedMessage) RecoverAddress(r Recoverer) (address.Address, error)
RecoverAddress returns the address derived from the signature and message encapsulated in `SignedMessage`
func (*SignedMessage) String ¶
func (smsg *SignedMessage) String() string
func (*SignedMessage) Unmarshal ¶
func (smsg *SignedMessage) Unmarshal(b []byte) error
Unmarshal a SignedMessage from the given bytes.
func (*SignedMessage) VerifySignature ¶
func (smsg *SignedMessage) VerifySignature() bool
VerifySignature returns true iff the signature over the message as calculated from EC recover matches the message sender address.
type SortedCidSet ¶
type SortedCidSet struct {
// contains filtered or unexported fields
}
SortedCidSet is a set of Cids that is maintained sorted. The externally visible effect as compared to cid.Set is that iteration is cheap and always in-order. Sort order is lexicographic ascending, by serialization of the cid. TODO: This should probably go into go-cid package - see https://github.com/ipfs/go-cid/issues/45.
func NewSortedCidSet ¶
func NewSortedCidSet(ids ...cid.Cid) (res SortedCidSet)
NewSortedCidSet returns a SortedCidSet with the specified items.
func (*SortedCidSet) Add ¶
func (s *SortedCidSet) Add(id cid.Cid) bool
Add adds a cid to the set. Returns true if the item was added (didn't already exist), false otherwise.
func (*SortedCidSet) Contains ¶
func (s *SortedCidSet) Contains(s2 *SortedCidSet) bool
Contains checks if s2 is a sub-tipset of s
func (SortedCidSet) Empty ¶
func (s SortedCidSet) Empty() bool
Empty returns true if the set is empty.
func (SortedCidSet) Equals ¶
func (s SortedCidSet) Equals(s2 SortedCidSet) bool
Equals returns true if the set contains the same items as another set.
func (SortedCidSet) Has ¶
func (s SortedCidSet) Has(id cid.Cid) bool
Has returns true if the set contains the specified cid.
func (SortedCidSet) Iter ¶
func (s SortedCidSet) Iter() SortedCidSetIterator
Iter returns an iterator that allows the caller to iterate the set in its sort order.
func (SortedCidSet) Len ¶
func (s SortedCidSet) Len() int
Len returns the number of items in the set.
func (SortedCidSet) MarshalJSON ¶
func (s SortedCidSet) MarshalJSON() ([]byte, error)
MarshalJSON serializes the set to JSON.
func (*SortedCidSet) Remove ¶
func (s *SortedCidSet) Remove(id cid.Cid) bool
Remove removes a cid from the set. Returns true if the item was removed (did in fact exist in the set), false otherwise.
func (SortedCidSet) String ¶
func (s SortedCidSet) String() string
String returns a string listing the cids in the set.
func (SortedCidSet) ToSlice ¶
func (s SortedCidSet) ToSlice() []cid.Cid
ToSlice returns a slice listing the cids in the set.
func (*SortedCidSet) UnmarshalJSON ¶
func (s *SortedCidSet) UnmarshalJSON(b []byte) error
UnmarshalJSON parses JSON into the set.
type SortedCidSetIterator ¶
type SortedCidSetIterator struct {
// contains filtered or unexported fields
}
SortedCidSetIterator is a iterator over a sorted collection of CIDs.
func (*SortedCidSetIterator) Complete ¶
func (si *SortedCidSetIterator) Complete() bool
Complete returns true if the iterator has reached the end of the set.
func (*SortedCidSetIterator) Next ¶
func (si *SortedCidSetIterator) Next() bool
Next advances the iterator to the next item and returns true if there is such an item.
func (SortedCidSetIterator) Value ¶
func (si SortedCidSetIterator) Value() cid.Cid
Value returns the current item for the iterator
type Tip ¶
type Tip = Block
Tip is what expected consensus needs from a Block. For now it *is* a Block.
type TipSet ¶
type TipSet map[cid.Cid]*Tip
TipSet is a set of Tips, blocks at the same height with the same parent set, keyed by Cid.
func NewTipSet ¶
NewTipSet returns a TipSet wrapping the input blocks. PRECONDITION: all blocks are the same height and have the same parent set.
func RequireNewTipSet ¶
func RequireNewTipSet(require *require.Assertions, blks ...*Block) TipSet
RequireNewTipSet instantiates and returns a new tipset of the given blocks and requires that the setup validation succeed.
func (TipSet) AddBlock ¶
AddBlock adds the provided block to this tipset. PRECONDITION: this block has the same height parent set as other members of ts.
func (TipSet) Equals ¶
Equals returns true if the tipset contains the same blocks as another set. Equality is not tested deeply. If blocks of two tipsets are stored at different memory addresses but have the same cids the tipsets will be equal.
func (TipSet) ParentWeight ¶
ParentWeight returns the tipset's ParentWeight in fixed point form.
func (TipSet) Parents ¶
func (ts TipSet) Parents() (SortedCidSet, error)
Parents returns the parents of a tipset.
func (TipSet) ToSortedCidSet ¶
func (ts TipSet) ToSortedCidSet() SortedCidSet
ToSortedCidSet returns a SortedCidSet containing the Cids in the TipSet.
type Uint64 ¶
type Uint64 uint64
Uint64 is an unsigned 64-bit variable-length-encoded integer.
func (Uint64) MarshalJSON ¶
MarshalJSON converts a Uint64 to a json string and returns it.
func (*Uint64) UnmarshalJSON ¶
UnmarshalJSON converts a json string to a Uint64.
Source Files ¶
- atto_fil.go
- block.go
- block_height.go
- bytes_amount.go
- channel_id.go
- commitments.go
- constants.go
- fixed_point.go
- helpers.go
- keyinfo.go
- message.go
- message_receipt.go
- metered_message.go
- recoverer.go
- signature.go
- signed_message.go
- signer.go
- sorted_cid_set.go
- testing.go
- testing_messages.go
- tipset.go
- uint64.go