Documentation ¶
Index ¶
- func TestPeerListRebalance()
- type HeartBeatData
- type JsonPeerList
- type Pair
- type PairList
- type PeerList
- func (peers *PeerList) Add(addr string, id int32)
- func (peers *PeerList) Copy() map[string]int32
- func (peers *PeerList) Delete(addr string)
- func (peers *PeerList) GetPeerMap() map[string]int32
- func (peers *PeerList) GetSelfId() int32
- func (peers *PeerList) InjectPeerMapJson(peerMapJsonStr string, selfAddr string)
- func (peers *PeerList) PeerMapToJson() (string, error)
- func (peers *PeerList) Rebalance()
- func (peers *PeerList) Register(id int32)
- func (peers *PeerList) Show() string
- type PeerMap
- type RegisterData
- type SyncBlockChain
- func (sbc *SyncBlockChain) BlockChainToJson() (string, error)
- func (sbc *SyncBlockChain) CheckParentHash(insertBlock p2.Block) bool
- func (sbc *SyncBlockChain) CountValues(value string) int
- func (sbc *SyncBlockChain) GenBlock(mpt p1.MerklePatriciaTrie, public_key string) p2.Block
- func (sbc *SyncBlockChain) Get(height int32) ([]p2.Block, bool)
- func (sbc *SyncBlockChain) GetBlock(height int32, hash string) (p2.Block, bool)
- func (sbc *SyncBlockChain) GetLatestBlocks() []p2.Block
- func (sbc *SyncBlockChain) GetLength() (height int32)
- func (sbc *SyncBlockChain) GetParentBlock(block p2.Block) (p2.Block, error)
- func (sbc *SyncBlockChain) Insert(block p2.Block)
- func (sbc *SyncBlockChain) Show() string
- func (sbc *SyncBlockChain) ShowMPT() string
- func (sbc *SyncBlockChain) UpdateEntireBlockChain(blockChainJson string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestPeerListRebalance ¶
func TestPeerListRebalance()
Types ¶
type HeartBeatData ¶
type HeartBeatData struct { IfNewBlock bool `json:"ifNewBlock"` Id int32 `json:"id"` BlockJson string `json:"blockJson"` PeerMapJson string `json:"peerMapJson"` Addr string `json:"addr"` Hops int32 `json:"hops"` }
Heartbeat is the JSON representation of the data we need to send to the other blockchains
func NewHeartBeatData ¶
func PrepareHeartBeatData ¶
func PrepareHeartBeatData(sbc *SyncBlockChain, selfId int32, peerMapJson string, addr string, verified bool, trie p1.MerklePatriciaTrie) HeartBeatData
Create a new instance of HeartBeatData, then decide whether to create a new block and send it to other peers.
func (*HeartBeatData) HeartBeatToJson ¶
func (heartbeat *HeartBeatData) HeartBeatToJson() string
type JsonPeerList ¶
type JsonPeerList struct {
JsonRep string
}
type PeerList ¶
type PeerList struct {
// contains filtered or unexported fields
}
func NewPeerList ¶
func (*PeerList) GetPeerMap ¶
func (*PeerList) InjectPeerMapJson ¶
Todo: Take peerMap as json String insert each entry into own peer list except for selfAddr
func (*PeerList) PeerMapToJson ¶
TODO: Fix error checking
type RegisterData ¶
type RegisterData struct { AssignedId int32 `json:"assignedId"` PeerMapJson string `json:"peerMapJson"` }
func NewRegisterData ¶
func NewRegisterData(id int32, peerMapJson string) RegisterData
func (*RegisterData) EncodeToJson ¶
func (data *RegisterData) EncodeToJson() (string, error)
TODO: Check this for correctness
type SyncBlockChain ¶
type SyncBlockChain struct {
// contains filtered or unexported fields
}
func NewBlockChain ¶
func NewBlockChain() SyncBlockChain
func (*SyncBlockChain) BlockChainToJson ¶
func (sbc *SyncBlockChain) BlockChainToJson() (string, error)
func (*SyncBlockChain) CheckParentHash ¶
func (sbc *SyncBlockChain) CheckParentHash(insertBlock p2.Block) bool
Check if this block is found in the chain
func (*SyncBlockChain) CountValues ¶
func (sbc *SyncBlockChain) CountValues(value string) int
func (*SyncBlockChain) GenBlock ¶
func (sbc *SyncBlockChain) GenBlock(mpt p1.MerklePatriciaTrie, public_key string) p2.Block
Create a new block to add to Sync. Blockchain
func (*SyncBlockChain) Get ¶
func (sbc *SyncBlockChain) Get(height int32) ([]p2.Block, bool)
Returns false if not found
func (*SyncBlockChain) GetLatestBlocks ¶
func (sbc *SyncBlockChain) GetLatestBlocks() []p2.Block
func (*SyncBlockChain) GetLength ¶
func (sbc *SyncBlockChain) GetLength() (height int32)
func (*SyncBlockChain) GetParentBlock ¶
func (*SyncBlockChain) Insert ¶
func (sbc *SyncBlockChain) Insert(block p2.Block)
func (*SyncBlockChain) Show ¶
func (sbc *SyncBlockChain) Show() string
func (*SyncBlockChain) ShowMPT ¶
func (sbc *SyncBlockChain) ShowMPT() string
func (*SyncBlockChain) UpdateEntireBlockChain ¶
func (sbc *SyncBlockChain) UpdateEntireBlockChain(blockChainJson string)
Click to show internal directories.
Click to hide internal directories.