Documentation ¶
Index ¶
- Constants
- Variables
- func CreateVote(sVote, tVote []byte, hsVote, htVote uint64, w *wallet.Wallet) protobufs.CasperVote
- func GenerateMerkleProof(receipts []*protobufs.Receipt, indexProof int, ...) []byte
- func GetPeerList(network string) ([]string, error)
- func IsJustified(currentCheckpoint uint64, index uint64) bool
- func IsVoteValid(b *blockchain.Blockchain, sourceHash, targetHash []byte, TargetHeight uint64) bool
- func MakeSpecificRequest(w *wallet.Wallet, shard uint32, dataRequest []byte, ...) error
- func SendTransaction(senderWallet *wallet.Wallet, recipient, fname string, amount, gas uint64, ...) error
- func TraverseNat(port uint16, desc string) (string, error)
- type ConnectionStore
- func (cs *ConnectionStore) AddGenesisToQueue(block *protoBlockchain.Block, shard uint32)
- func (cs *ConnectionStore) AddInterest(key string)
- func (cs *ConnectionStore) AddVote(vote *protobufs.CasperVote, shard uint32) error
- func (cs *ConnectionStore) CheckMerkleProof(merkleProof *protobufs.MerkleProof) (bool, error)
- func (cs *ConnectionStore) CheckShard(shard uint32) bool
- func (cs *ConnectionStore) CheckpointAgreement(SourceHeight, TargetHeight uint64, currentShard uint32) bool
- func (cs *ConnectionStore) Connect(ip string) error
- func (cs *ConnectionStore) FindPeers() error
- func (cs *ConnectionStore) GetCasperVote(index int, shard uint32) (protobufs.CasperVote, error)
- func (cs *ConnectionStore) ImportBlock(block *protobufs.Block, shard uint32) error
- func (cs *ConnectionStore) Loop()
- func (cs *ConnectionStore) MakeEnvelopeBroadcast(dataBroadcast []byte, typeBroadcast network.Broadcast_BroadcastType, ...)
- func (cs *ConnectionStore) RemoveInterest(key string)
- func (cs *ConnectionStore) SaveBlock(block *protobufs.Block, shard uint32) error
- func (cs *ConnectionStore) StartPeerServer()
- func (cs *ConnectionStore) UpdateChain(nextShard uint32, oldShard string) error
- func (cs *ConnectionStore) ValidatorLoop(currentShard uint32)
- func (cs *ConnectionStore) VerifyProof(mp *protobufs.MerkleProof, shard uint32) bool
Constants ¶
const (
MaxBlockPeer = 200
)
Maximum amount of blocks downloaded by one node at once
Variables ¶
var ReceiptBurned = make(map[string]bool)
TODO put ReceiptBurned in a file
Functions ¶
func CreateVote ¶
CreateVote : Create a vote based on casper Vote struct CasperVote: - Source -> hash of the source block - Target -> hash of any descendent of s - SourceHeight -> height of s - TargetHeight -> height of t - R, S -> signature of <s, t, h(s), h(t)> with validator private key
func GenerateMerkleProof ¶
func GetPeerList ¶
GetPeerList returns other nodes in the network
func IsJustified ¶
IsJustified : A block is justified if is the root or if it's between 2 checkpoint
func IsVoteValid ¶
func IsVoteValid(b *blockchain.Blockchain, sourceHash, targetHash []byte, TargetHeight uint64) bool
IsVoteValid check if s is an ancestor of t in the chain
func MakeSpecificRequest ¶
Types ¶
type ConnectionStore ¶
type ConnectionStore struct {
// contains filtered or unexported fields
}
ConnectionStore handles peer messaging
func StartServer ¶
func StartServer(port, network string, shardsChain map[uint32]*blockchain.Blockchain, beaconChain *blockchain.BeaconChain, idn *wallet.Wallet) (*ConnectionStore, error)
StartServer creates a new ConnectionStore, which handles network peers
func (*ConnectionStore) AddGenesisToQueue ¶
func (cs *ConnectionStore) AddGenesisToQueue(block *protoBlockchain.Block, shard uint32)
func (*ConnectionStore) AddInterest ¶
func (cs *ConnectionStore) AddInterest(key string)
AddInterest adds an interest, this is used as a filter to have more efficient broadcasts and avoid sending everything to everyone
func (*ConnectionStore) AddVote ¶
func (cs *ConnectionStore) AddVote(vote *protobufs.CasperVote, shard uint32) error
AddVote add a vote in receivedVotes and put it on the db
func (*ConnectionStore) CheckMerkleProof ¶
func (cs *ConnectionStore) CheckMerkleProof(merkleProof *protobufs.MerkleProof) (bool, error)
func (*ConnectionStore) CheckShard ¶
func (cs *ConnectionStore) CheckShard(shard uint32) bool
CheckShard check if the message arrived is from your interests (shards)
func (*ConnectionStore) CheckpointAgreement ¶
func (cs *ConnectionStore) CheckpointAgreement(SourceHeight, TargetHeight uint64, currentShard uint32) bool
CheckpointAgreement : Every checkpoint there should be an agreement of 2/3 of the validators
func (*ConnectionStore) Connect ¶
func (cs *ConnectionStore) Connect(ip string) error
Connect connects to a server and adds it to the connectionStore
func (*ConnectionStore) FindPeers ¶
func (cs *ConnectionStore) FindPeers() error
FindPeers tries to find all peers for the selected network
func (*ConnectionStore) GetCasperVote ¶
func (cs *ConnectionStore) GetCasperVote(index int, shard uint32) (protobufs.CasperVote, error)
GetCasperVote get a casper vote inside CasperVotesDb
func (*ConnectionStore) ImportBlock ¶
func (cs *ConnectionStore) ImportBlock(block *protobufs.Block, shard uint32) error
ImportBlock imports a block into the blockchain and checks if it's valid This should be called on blocks that are finalized by PoS
func (*ConnectionStore) Loop ¶
func (cs *ConnectionStore) Loop()
Loop start ValidatorLoop for every interest
func (*ConnectionStore) MakeEnvelopeBroadcast ¶
func (cs *ConnectionStore) MakeEnvelopeBroadcast(dataBroadcast []byte, typeBroadcast network.Broadcast_BroadcastType, shardAddress uint32, shardEnvelope uint32)
func (*ConnectionStore) RemoveInterest ¶
func (cs *ConnectionStore) RemoveInterest(key string)
func (*ConnectionStore) SaveBlock ¶
func (cs *ConnectionStore) SaveBlock(block *protobufs.Block, shard uint32) error
SaveBlock saves an unvalidated block into the blockchain to be used with Casper
func (*ConnectionStore) StartPeerServer ¶
func (cs *ConnectionStore) StartPeerServer()
StartPeerServer creates an HTTP server that replies with known peers
func (*ConnectionStore) UpdateChain ¶
func (cs *ConnectionStore) UpdateChain(nextShard uint32, oldShard string) error
UpdateChain asks all connected nodes for their chain lenght, if any of them has a chain longer than the current one it will import
func (*ConnectionStore) ValidatorLoop ¶
func (cs *ConnectionStore) ValidatorLoop(currentShard uint32)
ValidatorLoop updates the current expected validator and generates a block if the validator has the same identity as the node generates a block
func (*ConnectionStore) VerifyProof ¶
func (cs *ConnectionStore) VerifyProof(mp *protobufs.MerkleProof, shard uint32) bool