Documentation ¶
Index ¶
- Variables
- func AttoFILToFIL(attoFIL *big.Int) float64
- func FILtoAttoFIL(fil float64) *big.Int
- type FilecoinBackend
- type MockFilecoinBackend
- func (f *MockFilecoinBackend) CreateUser() (string, string, error)
- func (f *MockFilecoinBackend) Get(cid string, userToken string) (io.Reader, error)
- func (f *MockFilecoinBackend) JobStatus(cid string, userToken string) (*userPb.StorageJob, error)
- func (f *MockFilecoinBackend) Store(data io.Reader, addr addr.Address, userToken string) (jobID, contentID string, size int64, err error)
- type MockWalletBackend
- func (w *MockWalletBackend) Balance(addr string, userToken string) (*big.Int, error)
- func (w *MockWalletBackend) GenerateToAddress(addr string, amount *big.Int)
- func (w *MockWalletBackend) NewAddress(userToken string) (string, error)
- func (w *MockWalletBackend) Send(from, to string, amount *big.Int, userToken string) (string, error)
- func (w *MockWalletBackend) SetNextAddress(addr addr.Address)
- func (w *MockWalletBackend) SetNextTime(timestamp time.Time)
- func (w *MockWalletBackend) SetNextTxid(id string)
- func (w *MockWalletBackend) Transactions(addr string, limit, offset int) ([]Transaction, error)
- type PowergateBackend
- func (f *PowergateBackend) CreateUser() (string, string, error)
- func (f *PowergateBackend) Get(cid string, userToken string) (io.Reader, error)
- func (f *PowergateBackend) JobStatus(cid string, userToken string) (*userPb.StorageJob, error)
- func (f *PowergateBackend) Store(data io.Reader, addr addr.Address, userToken string) (jobId, contentID string, size int64, err error)
- type PowergateUser
- type PowergateWalletBackend
- func (w *PowergateWalletBackend) Balance(address string, userToken string) (*big.Int, error)
- func (w *PowergateWalletBackend) GenerateToAddress(addr string, amount *big.Int)
- func (w *PowergateWalletBackend) NewAddress(userToken string) (string, error)
- func (w *PowergateWalletBackend) Send(from, to string, amount *big.Int, userToken string) (string, error)
- func (w *PowergateWalletBackend) SetNextAddress(addr addr.Address)
- func (w *PowergateWalletBackend) SetNextTime(timestamp time.Time)
- func (w *PowergateWalletBackend) SetNextTxid(id string)
- func (w *PowergateWalletBackend) Transactions(addr string, limit, offset int) ([]Transaction, error)
- type Transaction
- type WalletBackend
Constants ¶
This section is empty.
Variables ¶
var ErrInsuffientFunds = errors.New("insufficient funds")
ErrInsuffientFunds is an error that should be returned by WalletBackend.Send method if the address does not have enough funds.
Functions ¶
func AttoFILToFIL ¶
AttoFILtoFIL converts a big.Int containing the attoFIL base unit to a float of the amount of Filecoin.
func FILtoAttoFIL ¶
FILtoAttoFIL converts a float containing an amount of Filecoin to a big.Int representation in the attoFil base unit.
Types ¶
type FilecoinBackend ¶
type FilecoinBackend interface { // Store will put a file to Filecoin and pay for it out of the provided // address. A jobID is return or an error. Store(data io.Reader, addr addr.Address, userToken string) (jobID, contentID string, size int64, err error) JobStatus(cid string, userToken string) (*userPb.StorageJob, error) Get(cid string, userToken string) (io.Reader, error) CreateUser() (id string, token string, error error) }
FilecoinBackend is an interface to a Filecoin backend that interacts with the Filecoin network and handles storage deals and retrieval.
type MockFilecoinBackend ¶
type MockFilecoinBackend struct {
// contains filtered or unexported fields
}
MockFilecoinBackend is a mock backend for a Filecoin service
func NewMockFilecoinBackend ¶
func NewMockFilecoinBackend(dataDir string, adminToken string) (*MockFilecoinBackend, error)
NewMockFilecoinBackend instantiates a new FilecoinBackend
func (*MockFilecoinBackend) CreateUser ¶
func (f *MockFilecoinBackend) CreateUser() (string, string, error)
func (*MockFilecoinBackend) JobStatus ¶
func (f *MockFilecoinBackend) JobStatus(cid string, userToken string) (*userPb.StorageJob, error)
type MockWalletBackend ¶
type MockWalletBackend struct {
// contains filtered or unexported fields
}
MockWalletBackend is a mock backend for the wallet that allows for making mock transactions and generating mock blocks.
func NewMockWalletBackend ¶
func NewMockWalletBackend() *MockWalletBackend
NewMockWalletBackend instantiates a new WalletBackend.
func (*MockWalletBackend) GenerateToAddress ¶
func (w *MockWalletBackend) GenerateToAddress(addr string, amount *big.Int)
GenerateToAddress creates mock coins and sends them to the address.
func (*MockWalletBackend) NewAddress ¶
func (w *MockWalletBackend) NewAddress(userToken string) (string, error)
NewAddress generates a new address and store the key in the backend.
func (*MockWalletBackend) Send ¶
func (w *MockWalletBackend) Send(from, to string, amount *big.Int, userToken string) (string, error)
Send filecoin from one address to another. Returns the cid of the transaction.
func (*MockWalletBackend) SetNextAddress ¶
func (w *MockWalletBackend) SetNextAddress(addr addr.Address)
func (*MockWalletBackend) SetNextTime ¶
func (w *MockWalletBackend) SetNextTime(timestamp time.Time)
func (*MockWalletBackend) SetNextTxid ¶
func (w *MockWalletBackend) SetNextTxid(id string)
func (*MockWalletBackend) Transactions ¶
func (w *MockWalletBackend) Transactions(addr string, limit, offset int) ([]Transaction, error)
Transactions returns the list of transactions for an address.
type PowergateBackend ¶
type PowergateBackend struct {
// contains filtered or unexported fields
}
PowergateBackend is a mock backend for a Filecoin service using Powergate
func NewPowergateBackend ¶
func NewPowergateBackend(dataDir string, adminToken string, hostname string) (*PowergateBackend, error)
NewPowergateBackend instantiates a new FilecoinBackend
func (*PowergateBackend) CreateUser ¶
func (f *PowergateBackend) CreateUser() (string, string, error)
func (*PowergateBackend) JobStatus ¶
func (f *PowergateBackend) JobStatus(cid string, userToken string) (*userPb.StorageJob, error)
type PowergateUser ¶
type PowergateUser struct {
// contains filtered or unexported fields
}
type PowergateWalletBackend ¶
type PowergateWalletBackend struct {
// contains filtered or unexported fields
}
MockWalletBackend is a mock backend for the wallet that allows for making mock transactions and generating mock blocks.
func NewPowergateWalletBackend ¶
func NewPowergateWalletBackend(hostname string) (*PowergateWalletBackend, error)
NewMockWalletBackend instantiates a new WalletBackend.
func (*PowergateWalletBackend) GenerateToAddress ¶
func (w *PowergateWalletBackend) GenerateToAddress(addr string, amount *big.Int)
GenerateToAddress creates mock coins and sends them to the address.
func (*PowergateWalletBackend) NewAddress ¶
func (w *PowergateWalletBackend) NewAddress(userToken string) (string, error)
NewAddress generates a new address and store the key in the backend.
func (*PowergateWalletBackend) Send ¶
func (w *PowergateWalletBackend) Send(from, to string, amount *big.Int, userToken string) (string, error)
Send filecoin from one address to another. Returns the cid of the transaction.
func (*PowergateWalletBackend) SetNextAddress ¶
func (w *PowergateWalletBackend) SetNextAddress(addr addr.Address)
func (*PowergateWalletBackend) SetNextTime ¶
func (w *PowergateWalletBackend) SetNextTime(timestamp time.Time)
func (*PowergateWalletBackend) SetNextTxid ¶
func (w *PowergateWalletBackend) SetNextTxid(id string)
func (*PowergateWalletBackend) Transactions ¶
func (w *PowergateWalletBackend) Transactions(addr string, limit, offset int) ([]Transaction, error)
Transactions returns the list of transactions for an address.
type Transaction ¶
Transaction represents a Filecoin transaction.
func (*Transaction) MarshalJSON ¶
func (t *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON is a custom JSON marshaller for Transaction.
type WalletBackend ¶
type WalletBackend interface { // NewAddress generates a new address and store the key in the backend. NewAddress(userToken string) (string, error) // Send filecoin from one address to another. Returns the cid of the // transaction. Send(from, to string, amount *big.Int, userToken string) (string, error) // Balance returns the balance for an address. Balance(address string, userToken string) (*big.Int, error) // Transactions returns the list of transactions for an address. Transactions(addr string, limit, offset int) ([]Transaction, error) }
WalletBackend is an interface for a Filecoin wallet that can hold the keys for multiple addresses and can make transactions.