Documentation ¶
Index ¶
- Constants
- Variables
- func BlockReq(hash [32]byte) error
- func BuildPacket(typeID uint8, payload []byte) (packet []byte)
- func Connect(connectionString string) *net.TCPConn
- func Init(ipport string)
- func InitLogging()
- func IsBootstrap() bool
- func LastBlockReq() error
- func PrepareHandshake(pingType uint8, localPort int) ([]byte, error)
- func ReadSystemTime() int64
- func TxReq(hash [32]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 = 5 //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 = 20 //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 = 30 //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 FUNDSTX_REQ = 10 ACCTX_REQ = 11 CONFIGTX_REQ = 12 STAKETX_REQ = 13 BLOCK_REQ = 14 BLOCK_HEADER_REQ = 15 ACC_REQ = 16 ROOTACC_REQ = 17 INTERMEDIATE_NODES_REQ = 18 FUNDSTX_RES = 20 ACCTX_RES = 21 CONFIGTX_RES = 22 STAKETX_RES = 23 BLOCK_RES = 24 BlOCK_HEADER_RES = 25 ACC_RES = 26 ROOTACC_RES = 27 INTERMEDIATE_NODES_RES = 28 NEIGHBOR_REQ = 30 NEIGHBOR_RES = 40 TIME_BRDCST = 50 MINER_PING = 100 MINER_PONG = 101 CLIENT_PING = 102 CLIENT_PONG = 103 //Used to signal error NOT_FOUND = 110 )
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 chan []byte = make(chan []byte) //Block from the miner, to the network BlockOut chan []byte = make(chan []byte) //BlockHeader from the miner, to the clients BlockHeaderOut chan []byte = make(chan []byte) VerifiedTxsOut chan []byte = make(chan []byte) //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) BlockReqChan = make(chan []byte) )
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 BlockReq ¶
Both block and tx requests are handled asymmetricaly, using channels as inter-communication All the request in this file are specifically initiated by the miner package
func BuildPacket ¶
func InitLogging ¶
func InitLogging()
func IsBootstrap ¶
func IsBootstrap() bool
func LastBlockReq ¶
func LastBlockReq() error
func ReadSystemTime ¶
func ReadSystemTime() int64
Types ¶
Click to show internal directories.
Click to hide internal directories.