Documentation ¶
Index ¶
- Constants
- Variables
- func AccTxAlreadyInStash(slice []*protocol.AccTx, newTXHash [32]byte) bool
- func AggDataTxAlreadyInStash(slice []*protocol.AggDataTx, newTXHash [32]byte) bool
- func AggTxAlreadyInStash(slice []*protocol.AggTx, newTXHash [32]byte) bool
- func BlockAlreadyReceived(slice []*protocol.Block, newBlockHash [32]byte) bool
- func BlockReq(hash [32]byte, hashWithoutTx [32]byte) error
- func BuildPacket(typeID uint8, payload []byte) (packet []byte)
- func CommitteeCheckReq(address [32]byte, height int)
- func CommitteeCheckRes(p *peer, payload []byte)
- func Connect(connectionString string) *net.TCPConn
- func DataTxAlreadyInStash(slice []*protocol.DataTx, newTXHash [32]byte) bool
- func EmptyingiplistChan()
- func EpochBlockRes(p *peer, payload []byte)
- func FirstEpochBlockReq() error
- func FirstEpochBlockRes(p *peer, payload []byte)
- func FundsTxAlreadyInStash(slice []*protocol.FundsTx, newTXHash [32]byte) bool
- func GenesisReq() error
- func Init(ipport string)
- func InitLogging()
- func IsBootstrap() bool
- func LastBlockReq() error
- func LastEpochBlockReq() error
- func LastEpochBlockRes(p *peer, payload []byte)
- func NeighborReq()
- func PrepareHandshake(pingType uint8, localPort int) ([]byte, error)
- func PrintMinerConns()
- func ReadSystemTime() int64
- func ShardBlockReq(height int, shardID int)
- func StakeTxAlreadyInStash(slice []*protocol.StakeTx, newTXHash [32]byte) bool
- func StateTransitionReqShard(shardID int, height int)
- func TransactionAssignmentReq(height int, shardID int)
- func TransactionAssignmentRes(p *peer, payload []byte)
- func TxReq(hash [32]byte, reqType uint8) error
- func TxWithTxCntReq(payload []byte, reqType uint8) error
- type Header
Constants ¶
View Source
const ( //MIN_MINERS is a lower bound of connections. If there are less, the system actively requests miner peers //from neighbors and establishes connections to them MIN_MINERS = 20 //MAX_MINERS is an upper bound of connections. Miner handshakes are rejected if the amount of connections //grows above this number. Client connections are always accepted MAX_MINERS = 30 //In order to get a reasonable system time, there needs to be a minimal amount of times available from other peers MIN_PEERS_FOR_TIME = 5 //Interval to check system health in seconds HEALTH_CHECK_INTERVAL = 15 //Broadcast local time to the network in seconds TIME_BRDCST_INTERVAL = 60 //Calculate system time every UPDATE_SYS_TIME seconds UPDATE_SYS_TIME = 90 //Protocol constants IPV4ADDR_SIZE = 4 PORT_SIZE = 2 )
Package-wide constants and configuration parameters
View Source
const ( PEERTYPE_MINER = 1 PEERTYPE_CLIENT = 2 )
View Source
const ( FUNDSTX_BRDCST = 1 ACCTX_BRDCST = 2 CONFIGTX_BRDCST = 3 STAKETX_BRDCST = 4 VERIFIEDTX_BRDCST = 5 BLOCK_BRDCST = 6 BLOCK_HEADER_BRDCST = 7 TX_BRDCST_ACK = 8 AGGTX_BRDCST = 9 DATATX_BRDCST = 10 AGGDATATX_BRDCST = 11 COMMITTEETX_BRDCST = 12 GENESIS_REQ = 19 FUNDSTX_REQ = 20 ACCTX_REQ = 21 CONFIGTX_REQ = 22 STAKETX_REQ = 23 BLOCK_REQ = 24 BLOCK_HEADER_REQ = 25 ACC_REQ = 26 ROOTACC_REQ = 27 INTERMEDIATE_NODES_REQ = 28 AGGTX_REQ = 29 UNKNOWNTX_REQ = 30 SPECIALTX_REQ = 31 NOT_FOUND_TX_REQ = 32 AGGDATATX_REQ = 33 FUNDSTX_RES = 40 ACCTX_RES = 41 CONFIGTX_RES = 42 STAKETX_RES = 43 BLOCK_RES = 44 BlOCK_HEADER_RES = 45 ACC_RES = 46 ROOTACC_RES = 47 INTERMEDIATE_NODES_RES = 48 AGGTX_RES = 49 AGGDATATX_RES = 50 NEIGHBOR_REQ = 130 NEIGHBOR_RES = 140 TIME_BRDCST = 150 MINER_PING = 100 MINER_PONG = 101 CLIENT_PING = 102 CLIENT_PONG = 103 //Used to signal error NOT_FOUND = 110 STATE_REQ = 120 STATE_RES = 121 FIRST_EPOCH_BLOCK_REQ = 122 FIRST_EPOCH_BLOCK_RES = 123 EPOCH_BLOCK_REQ = 124 EPOCH_BLOCK_RES = 125 VALIDATOR_SHARD_BRDCST = 126 VALIDATOR_SHARD_REQ = 127 VALIDATOR_SHARD_RES = 128 EPOCH_BLOCK_BRDCST = 129 LAST_EPOCH_BLOCK_RES = 131 LAST_EPOCH_BLOCK_REQ = 132 STATE_TRANSITION_BRDCST = 133 STATE_TRANSITION_REQ = 136 STATE_TRANSITION_RES = 137 GENESIS_RES = 138 SHARD_BLOCK_REQ = 141 SHARD_BLOCK_RES = 142 TRANSACTION_ASSIGNMENT_REQ = 143 TRANSACTION_ASSIGNMENT_RES = 144 TRANSACTION_ASSIGNMENT_BRDCST = 145 COMMITTEE_CHECK_BRDCST = 146 COMMITTEE_CHECK_REQ = 147 COMMITTEE_CHECK_RES = 148 FINETX_BRDCST = 149 )
Mapping constants, used to parse incoming messages
View Source
const HEADER_LEN = 5
Variables ¶
View Source
var ( //Block from the network, to the miner BlockIn = make(chan []byte, 1000) //Block from the miner, to the network BlockOut = make(chan []byte, 100) //BlockHeader from the miner, to the clients BlockHeaderOut = make(chan []byte) //State transition from the miner to the network StateTransitionOut = make(chan []byte) //Fine TX from the miner to the network FineTxOut = make(chan []byte) //Transaction assignment from the committee to the network TransactionAssignmentOut = make(chan []byte) //Committee check from committee to the network CommitteeCheckOut = make(chan []byte) //State transition from the network to the miner StateTransitionIn = make(chan []byte) //Transaction Assignment from the network to the miner TransactionAssignmentIn = make(chan []byte) //CommitteeCheck from the network to the committee CommitteeCheckIn = make(chan []byte) //FineTx from the network to the committee FineTxIn = make(chan []byte) //EpochBlock from the network, to the miner EpochBlockIn = make(chan []byte) //EpochBlock from the miner, to the network EpochBlockOut = make(chan []byte) EpochBlockReceivedChan = make(chan protocol.EpochBlock) VerifiedTxsOut = make(chan []byte) VerifiedTxsBrdcstOut = make(chan []byte, 1000) //Data requested by miner, to allow parallelism, we have a chan for every tx type. FundsTxChan = make(chan *protocol.FundsTx) AccTxChan = make(chan *protocol.AccTx) ConfigTxChan = make(chan *protocol.ConfigTx) StakeTxChan = make(chan *protocol.StakeTx) AggTxChan = make(chan *protocol.AggTx) DataTxChan = make(chan *protocol.DataTx) AggDataTxChan = make(chan *protocol.AggDataTx) BlockReqChan = make(chan []byte) StateTransitionShardReqChan = make(chan []byte) CommitteeCheckReqChan = make(chan []byte) StateTransitionShardOut = make(chan []byte) CommitteeCheckShardOut = make(chan []byte) ShardBlockShardOut = make(chan []byte) TransactionAssignmentReqOut = make(chan []byte) ShardBlockReqChan = make(chan []byte) TransactionAssignmentReqChan = make(chan []byte) FirstEpochBlockReqChan = make(chan []byte) EpochBlockReqChan = make(chan []byte) LastEpochBlockReqChan = make(chan []byte) GenesisReqChan = make(chan []byte) ValidatorShardMapReq = make(chan []byte) ReceivedFundsTXStash = make([]*protocol.FundsTx, 0) ReceivedAggTxStash = make([]*protocol.AggTx, 0) ReceivedStakeTxStash = make([]*protocol.StakeTx, 0) ReceivedAccTxStash = make([]*protocol.AccTx, 0) ReceivedDataTxStash = make([]*protocol.DataTx, 0) ReceivedAggDataTxStash = make([]*protocol.AggDataTx, 0) )
View Source
var ( //List of ip addresses. A connection to a subset of the list will be established as soon as the network health //monitor triggers. Ipport string )
View Source
var (
LogMapping map[uint8]string
)
Functions ¶
func AccTxAlreadyInStash ¶
func AggDataTxAlreadyInStash ¶
func AggTxAlreadyInStash ¶
func BlockAlreadyReceived ¶
func BuildPacket ¶
func CommitteeCheckReq ¶
func CommitteeCheckRes ¶
func CommitteeCheckRes(p *peer, payload []byte)
func DataTxAlreadyInStash ¶
func EmptyingiplistChan ¶
func EmptyingiplistChan()
func EpochBlockRes ¶
func EpochBlockRes(p *peer, payload []byte)
func FirstEpochBlockReq ¶
func FirstEpochBlockReq() error
func FirstEpochBlockRes ¶
func FirstEpochBlockRes(p *peer, payload []byte)
func FundsTxAlreadyInStash ¶
Checks if Tx Is in the received stash. If true, we received the transaction with a request already.
func GenesisReq ¶
func GenesisReq() error
func InitLogging ¶
func InitLogging()
func IsBootstrap ¶
func IsBootstrap() bool
func LastBlockReq ¶
func LastBlockReq() error
func LastEpochBlockReq ¶
func LastEpochBlockReq() error
func LastEpochBlockRes ¶
func LastEpochBlockRes(p *peer, payload []byte)
func NeighborReq ¶
func NeighborReq()
Requests that the p2p package issues requesting data from other miners. Tx and block requests are processed in the miner_interface.go file, because this involves inter-communication between the two packages
func PrintMinerConns ¶
func PrintMinerConns()
func ReadSystemTime ¶
func ReadSystemTime() int64
func ShardBlockReq ¶
the committe node might have to request blocks from the network. shard blocks are uniquely identified with their block height and shard ID
func StakeTxAlreadyInStash ¶
func StateTransitionReqShard ¶
func TransactionAssignmentRes ¶
func TransactionAssignmentRes(p *peer, payload []byte)
func TxWithTxCntReq ¶
Request specific transaction
Types ¶
Click to show internal directories.
Click to hide internal directories.