types

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2019 License: Apache-2.0, MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHashFunction = mh.BLAKE2B_MIN + 31

DefaultHashFunction represents the default hashing function to use

View Source
const MaxFixedPointIntegralNum = 18014398509481983 // (2^54 - 1)

MaxFixedPointIntegralNum is the largest whole number that can be encoded as a fixed point.

View Source
const (
	// SECP256K1 is a curve used to compute private keys
	SECP256K1 = "secp256k1"
)

Variables

View Source
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")
)
View Source
var AccountActorCodeCid cid.Cid

AccountActorCodeCid is the cid of the above object

View Source
var AccountActorCodeObj ipld.Node

AccountActorCodeObj is the code representation of the builtin account actor.

View Source
var ActorCodeCidTypeNames = make(map[cid.Cid]string)

ActorCodeCidTypeNames maps Actor codeCid's to the name of the associated Actor type.

View Source
var BlockGasLimit = NewGasUnits(10000000)

BlockGasLimit is the maximum amount of gas that can be used to execute messages in a single block

View Source
var BootstrapMinerActorCodeCid cid.Cid

BootstrapMinerActorCodeCid is the cid of the above object

View Source
var BootstrapMinerActorCodeObj ipld.Node

BootstrapMinerActorCodeObj is the code representation of the bootstrap miner actor.

View Source
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")
)
View Source
var (
	// ErrInvalidMessageLength is returned when the message length does not match the expected length.
	ErrInvalidMessageLength = errors.New("invalid message length")
)
View Source
var MinerActorCodeCid cid.Cid

MinerActorCodeCid is the cid of the above object

View Source
var MinerActorCodeObj ipld.Node

MinerActorCodeObj is the code representation of the builtin miner actor.

View Source
var PaymentBrokerActorCodeCid cid.Cid

PaymentBrokerActorCodeCid is the cid of the above object

View Source
var PaymentBrokerActorCodeObj ipld.Node

PaymentBrokerActorCodeObj is the code representation of the builtin payment broker actor.

View Source
var StorageMarketActorCodeCid cid.Cid

StorageMarketActorCodeCid is the cid of the above object

View Source
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

func BigToFixed(f *big.Float) (uint64, error)

BigToFixed takes in a big Float and returns a uint64 encoded fixed point.

func FixedStr

func FixedStr(fixed uint64) (string, error)

FixedStr returns a printable string with the correct decimal place for the input uint64 encoded fixed point number.

func FixedToBig

func FixedToBig(fixed uint64) (*big.Float, error)

FixedToBig takes in a uint64 encoded fixed point and returns a big Float.

func GenerateKeyInfoSeed

func GenerateKeyInfoSeed() io.Reader

GenerateKeyInfoSeed returns a random to be passed to MustGenerateKeyInfo

func IsValidSignature

func IsValidSignature(data []byte, addr address.Address, sig Signature) bool

IsValidSignature cryptographically verifies that 'sig' is the signed hash of 'data' with the public key belonging to `addr`.

func MsgCidsEqual

func MsgCidsEqual(m1, m2 *Message) bool

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

func NewAttoFIL(x *big.Int) *AttoFIL

NewAttoFIL allocates and returns a new AttoFIL set to x.

func NewAttoFILFromBytes

func NewAttoFILFromBytes(buf []byte) *AttoFIL

NewAttoFILFromBytes allocates and returns a new AttoFIL set to the value of buf as the bytes of a big-endian unsigned integer.

func NewAttoFILFromFIL

func NewAttoFILFromFIL(x uint64) *AttoFIL

NewAttoFILFromFIL returns a new AttoFIL representing a quantity of attofilecoin equal to x filecoin.

func NewAttoFILFromFILString

func NewAttoFILFromFILString(s string) (*AttoFIL, bool)

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

func NewAttoFILFromString(s string, base int) (*AttoFIL, bool)

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

func NewGasPrice(price int64) AttoFIL

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) Add

func (z *AttoFIL) Add(y *AttoFIL) *AttoFIL

Add sets z to the sum x+y and returns z.

func (*AttoFIL) Bytes

func (z *AttoFIL) Bytes() []byte

Bytes returns the absolute value of x as a big-endian byte slice.

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

func (z *AttoFIL) DivCeil(y *AttoFIL) *AttoFIL

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) Equal

func (z *AttoFIL) Equal(y *AttoFIL) bool

Equal returns true if z = y

func (*AttoFIL) GreaterEqual

func (z *AttoFIL) GreaterEqual(y *AttoFIL) bool

GreaterEqual returns true if z >= y

func (*AttoFIL) GreaterThan

func (z *AttoFIL) GreaterThan(y *AttoFIL) bool

GreaterThan returns true if z > y

func (*AttoFIL) IsNegative

func (z *AttoFIL) IsNegative() bool

IsNegative returns true if z is less than zero.

func (*AttoFIL) IsPositive

func (z *AttoFIL) IsPositive() bool

IsPositive returns true if z is greater than zero.

func (*AttoFIL) IsZero

func (z *AttoFIL) IsZero() bool

IsZero returns true if z equals zero.

func (*AttoFIL) LessEqual

func (z *AttoFIL) LessEqual(y *AttoFIL) bool

LessEqual returns true if z <= y

func (*AttoFIL) LessThan

func (z *AttoFIL) LessThan(y *AttoFIL) bool

LessThan returns true if z < y

func (AttoFIL) MarshalJSON

func (z AttoFIL) MarshalJSON() ([]byte, error)

MarshalJSON converts an AttoFIL to a byte array and returns it.

func (*AttoFIL) MulBigInt

func (z *AttoFIL) MulBigInt(x *big.Int) *AttoFIL

MulBigInt multiplies attoFIL by a given big int

func (*AttoFIL) String

func (z *AttoFIL) String() string

func (*AttoFIL) Sub

func (z *AttoFIL) Sub(y *AttoFIL) *AttoFIL

Sub sets z to the difference x-y and returns z.

func (*AttoFIL) UnmarshalJSON

func (z *AttoFIL) UnmarshalJSON(b []byte) error

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

func DecodeBlock(b []byte) (*Block, error)

DecodeBlock decodes raw cbor bytes into a Block.

func NewBlockForTest

func NewBlockForTest(parent *Block, nonce uint64) *Block

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) Cid

func (b *Block) Cid() cid.Cid

Cid returns the content id of this block.

func (*Block) Equals

func (b *Block) Equals(other *Block) bool

Equals returns true if the Block is equal to other.

func (Block) IsParentOf

func (b Block) IsParentOf(c Block) bool

IsParentOf returns true if the argument is a parent of the receiver.

func (*Block) Score

func (b *Block) Score() uint64

Score returns the score of this block. Naively this will just return the height. But in the future this will return a more sophisticated metric to be used in the fork choice rule Choosing height as the score gives us the same consensus rules as bitcoin

func (*Block) String

func (b *Block) String() string

func (*Block) ToNode

func (b *Block) ToNode() node.Node

ToNode converts the Block to an IPLD node.

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

func NewChannelID(x uint64) *ChannelID

NewChannelID allocates and returns a new ChannelID set to x.

func NewChannelIDFromBytes

func NewChannelIDFromBytes(buf []byte) *ChannelID

NewChannelIDFromBytes allocates and returns a new ChannelID set to the value of buf as the bytes of a big-endian unsigned integer.

func NewChannelIDFromString

func NewChannelIDFromString(s string, base int) (*ChannelID, bool)

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) Bytes

func (z *ChannelID) Bytes() []byte

Bytes returns the absolute value of x as a big-endian byte slice.

func (*ChannelID) Equal

func (z *ChannelID) Equal(y *ChannelID) bool

Equal returns true if z = y

func (*ChannelID) Inc

func (z *ChannelID) Inc() *ChannelID

Inc increments the value of the channel id

func (*ChannelID) KeyString

func (z *ChannelID) KeyString() string

KeyString returns a compact string version of the ID

func (ChannelID) MarshalJSON

func (z ChannelID) MarshalJSON() ([]byte, error)

MarshalJSON converts a ChannelID to a byte array and returns it.

func (*ChannelID) String

func (z *ChannelID) String() string

String returns a string version of the ID

func (*ChannelID) UnmarshalJSON

func (z *ChannelID) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a byte array to a ChannelID.

type Commitments

type Commitments struct {
	CommD     proofs.CommD
	CommR     proofs.CommR
	CommRStar proofs.CommRStar
}

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

func NewGasUnits(cost uint64) GasUnits

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

func MustGenerateKeyInfo(n int, seed io.Reader) []KeyInfo

MustGenerateKeyInfo generates a slice of KeyInfo size `n` with seed `seed`

func (*KeyInfo) Address

func (ki *KeyInfo) Address() (address.Address, error)

Address returns the address for this keyinfo

func (*KeyInfo) Equals

func (ki *KeyInfo) Equals(other *KeyInfo) bool

Equals returns true if the KeyInfo is equal to other.

func (*KeyInfo) Key

func (ki *KeyInfo) Key() []byte

Key returns the private key of KeyInfo

func (*KeyInfo) Marshal

func (ki *KeyInfo) Marshal() ([]byte, error)

Marshal KeyInfo into bytes.

func (*KeyInfo) PublicKey

func (ki *KeyInfo) PublicKey() []byte

PublicKey returns the public key part as uncompressed bytes.

func (*KeyInfo) Type

func (ki *KeyInfo) Type() string

Type returns the type of curve used to generate the private key

func (*KeyInfo) Unmarshal

func (ki *KeyInfo) Unmarshal(b []byte) error

Unmarshal decodes raw cbor bytes into KeyInfo.

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

func NewMsgs(n int) []*Message

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

func NewMsgsWithAddrs(n int, a []address.Address) []*Message

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

func (msg *Message) Cid() (cid.Cid, error)

Cid returns the canonical CID for the message. TODO: can we avoid returning an error?

func (*Message) Equals

func (msg *Message) Equals(other *Message) bool

Equals tests whether two messages are equal

func (*Message) Marshal

func (msg *Message) Marshal() ([]byte, error)

Marshal the message into bytes.

func (*Message) String

func (msg *Message) String() string

func (*Message) ToNode

func (msg *Message) ToNode() (ipld.Node, error)

ToNode converts the Message to an IPLD node.

func (*Message) Unmarshal

func (msg *Message) Unmarshal(b []byte) error

Unmarshal a message from the given bytes.

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

func (ms MockSigner) CreateTicket(proof proofs.PoStProof, signerPubKey []byte) (Signature, error)

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

func (MockSigner) SignBytes

func (ms MockSigner) SignBytes(data []byte, addr address.Address) (Signature, error)

SignBytes cryptographically signs `data` using the Address `addr`.

type Recoverer

type Recoverer interface {
	Ecrecover(data []byte, sig Signature) ([]byte, error)
}

Recoverer is an interface for ecrecover

type Signature

type Signature []byte

Signature is the result of a cryptographic sign operation.

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 Signer

type Signer interface {
	SignBytes(data []byte, addr address.Address) (Signature, error)
}

Signer is an interface for SignBytes

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) Clear

func (s *SortedCidSet) Clear()

Clear removes all entries from the set.

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

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

func NewTipSet(blks ...*Block) (TipSet, error)

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

func (ts TipSet) AddBlock(b *Block) error

AddBlock adds the provided block to this tipset. PRECONDITION: this block has the same height parent set as other members of ts.

func (TipSet) Clone

func (ts TipSet) Clone() TipSet

Clone returns a shallow copy of the TipSet.

func (TipSet) Equals

func (ts TipSet) Equals(ts2 TipSet) bool

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) Height

func (ts TipSet) Height() (uint64, error)

Height returns the height of a tipset.

func (TipSet) MinTicket

func (ts TipSet) MinTicket() (Signature, error)

MinTicket returns the smallest ticket of all blocks in the tipset.

func (TipSet) ParentWeight

func (ts TipSet) ParentWeight() (uint64, error)

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) String

func (ts TipSet) String() string

String returns a formatted string of the TipSet: { <cid1> <cid2> <cid3> }

func (TipSet) ToSlice

func (ts TipSet) ToSlice() []*Block

ToSlice returns the slice of *Block containing the tipset's blocks. Sorted.

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

func (u Uint64) MarshalJSON() ([]byte, error)

MarshalJSON converts a Uint64 to a json string and returns it.

func (*Uint64) UnmarshalJSON

func (u *Uint64) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a json string to a Uint64.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL