Documentation ¶
Index ¶
- Constants
- func Decrypt(cipherText []byte, password string) ([]byte, error)
- func Encrypt(plainText []byte, password string) ([]byte, error)
- func InvalidPassword(err error) bool
- func Run(cfg conf.Config)
- func RunConsole(a *App) *ishell.Shell
- func VerifyPasswordComplexity(password string) bool
- type App
- func (a *App) ConnectAndDiscover(target string)
- func (a *App) HandleBlock(blk *blockchain.Block)
- func (a *App) HandleTransaction(txn *blockchain.Transaction)
- func (a *App) HandleWork()
- func (a *App) Pay(to string, amount uint64) error
- func (a *App) PushHandler(push *msg.Push)
- func (a *App) RequestHandler(req *msg.Request) msg.Response
- func (a *App) ResumeMiner(restart bool)
- func (a *App) RunMiner()
- func (a *App) SyncBlockChain() (bool, error)
- type User
Constants ¶
const ( // MaxBlockSize is the maximum size of a block in bytes MaxBlockSize = 5000000 // MinBlockSize is the minimum size of a block in bytes MinBlockSize = 1000 )
Variables ¶
This section is empty.
Functions ¶
func InvalidPassword ¶
InvalidPassword is returned from Decrypt if an invalid password is used to decrypt the ciphertext
func Run ¶
Run sets up and starts a new Cumulus node with the given configuration. This should only be called once (except in tests)
func RunConsole ¶
RunConsole starts the Cumulus console. This should be run only once as a goroutine, and logging should be redirected away from stdout before it is run. It takes a pointer to a PeerStore so we can use the PeerStore to interact with other peers and give the user info about the running instance.
func VerifyPasswordComplexity ¶
VerifyPasswordComplexity verifies password complexity
Types ¶
type App ¶
type App struct { CurrentUser *User PeerStore *peer.PeerStore Chain *blockchain.BlockChain Miner *miner.Miner Pool *pool.Pool // contains filtered or unexported fields }
App contains information about a running instance of a Cumulus node
func New ¶
func New(user *User, pStore *peer.PeerStore, chain *blockchain.BlockChain, pool *pool.Pool) *App
New returns a new user with the given parameters
func (*App) ConnectAndDiscover ¶
ConnectAndDiscover tries to connect to a target and discover its peers.
func (*App) HandleBlock ¶
func (a *App) HandleBlock(blk *blockchain.Block)
HandleBlock handles new blocks.
func (*App) HandleTransaction ¶
func (a *App) HandleTransaction(txn *blockchain.Transaction)
HandleTransaction handles new transactions.
func (*App) HandleWork ¶
func (a *App) HandleWork()
HandleWork continually collects new work from existing work channels.
func (*App) PushHandler ¶
PushHandler is called every time a peer sends us a Push message except on peers whos PushHandlers have been overridden.
func (*App) RequestHandler ¶
RequestHandler is called every time a peer sends us a request message expect on peers whos PushHandlers have been overridden.
func (*App) ResumeMiner ¶
ResumeMiner resumes the current mining job if restart is false, otherwise it restarts the miner with a new mining job.
func (*App) RunMiner ¶
func (a *App) RunMiner()
RunMiner continuously pulls transactions form the transaction pool, uses them to create blocks, and mines those blocks. When a block is mined it is added to the blockchain and broadcasted into the network. RunMiner returns when miner.StopMining() or miner.PauseIfRunning() are called.
func (*App) SyncBlockChain ¶
SyncBlockChain updates the local copy of the blockchain by requesting missing blocks from peers. Returns true if the blockchain changed as a result of calling this function, false if it didn't and an error if we are not connected to any peers.
type User ¶
type User struct { Wallet *blockchain.Wallet Name string BlockSize uint32 CryptoWallet bool }
User holds basic user information.
func LoadUser ¶
LoadUser attempts to read user info from the file with the given name in the current working directory in JSON format. On success this returns a pointer to a new user constructed from the information in the file. If an error occurrs it is returned.
func (*User) DecryptPrivateKey ¶
DecryptPrivateKey decrypts the user's private key
func (*User) EncryptPrivateKey ¶
EncryptPrivateKey encrypts the user's private key
func (*User) Public ¶
func (u *User) Public() blockchain.Address
Public returns the public key of the given user