Documentation
¶
Index ¶
Constants ¶
View Source
const ( ConfigFileName = "config" BlockFileName = "block" WalletFileName = "wallet" ConfigBucketIdentity = "self" BlockBucketIdentity = "block" ChainStateBucketIdentity = "chain_state" ChainLastIndexKey = "last" ConfigGuidKey = "guid" ConfigVersionKey = "version" ConfigPortKey = "port" ConfigSeedKey = "seeds" ConfigReceiveAddressKey = "receive_address" DefaultVersion uint32 = 32 DefaultPort uint32 = 34212 DefaultSeedNode = "127.0.0.1:34212" HeaderLength uint32 = 4 )
Variables ¶
View Source
var Config = &struct { DB *bolt.DB SeedNodes []string Version uint32 Guid []byte ReceiveAddress string HeartbeatTaskSpec string RequestHeightTaskSpec string // ---------------------------------- DHT Config ------------------------------------ // the bucket expired duration BucketExpiredAfter time.Duration // the node expired duration NodeExpriedAfter time.Duration // how long it checks whether the bucket is expired CheckBucketPeriod time.Duration // the max transaction id MaxTransactionCursor uint64 // how many nodes routing table can hold MaxNodes int // in mainline hash_table, k = 8 K int // for crawling mode, we put all nodes in one bucket, so BucketSize may // not be K BucketSize int // the nodes num to be fresh in a bucket RefreshNodeCount int // udp, udp4, udp6 Network string // local network address LocalAddr *net.UDPAddr CheckPeerPeriod time.Duration ServerPort int }{ HeartbeatTaskSpec: "*/10 * * * * *", RequestHeightTaskSpec: "0 * * * * *", }
View Source
var ConfigFileGroup = ""
View Source
var InvalidMessageType = errors.New("invalid MessageType")
View Source
var InvalidTransactionType = errors.New("invalid TransactionType")
Functions ¶
func GetBlockFilePath ¶
func GetBlockFilePath() string
func GetConfigFilePath ¶
func GetConfigFilePath() string
func GetWalletFilePath ¶
func GetWalletFilePath() string
func InitConfig ¶
func InitConfig(fileGroup string)
Types ¶
type MessageType ¶
type MessageType uint32
swagger:enum
const ( MESSAGE_TYPE_UNKNOWN MessageType = iota MESSAGE_TYPE__HEARTBEAT // 心跳检测 MESSAGE_TYPE__HEARTBEAT_ACK // 心跳检测确认 MESSAGE_TYPE__FIND_NODE // 查找节点 MESSAGE_TYPE__FIND_NODE_ACK // 查找节点响应 MESSAGE_TYPE__HELLO // 首次握手 MESSAGE_TYPE__HELLO_ACK // 首次握手确认 MESSAGE_TYPE__HELLO_TCP // TCP握手 MESSAGE_TYPE__BROADCAST_NEW_PEER_TO_PEERS // 新节点接入广播 MESSAGE_TYPE__NEW_PEERS_TO_PEER // 节点介绍 MESSAGE_TYPE__REQUEST_HEIGHT // 获取最新节点高度 MESSAGE_TYPE__BLOCKS_HASH // 发送区块哈希 MESSAGE_TYPE__GET_BLOCK // 获取区块 MESSAGE_TYPE__GET_BLOCK_ACK // 响应获取区块 MESSAGE_TYPE__NEW_TRANSACTION // 新交易 )
消息类型
func ParseMessageTypeFromLabelString ¶
func ParseMessageTypeFromLabelString(s string) (MessageType, error)
func ParseMessageTypeFromString ¶
func ParseMessageTypeFromString(s string) (MessageType, error)
func (MessageType) EnumType ¶
func (MessageType) EnumType() string
func (MessageType) Enums ¶
func (MessageType) Enums() map[int][]string
func (MessageType) Label ¶
func (v MessageType) Label() string
func (MessageType) MarshalText ¶
func (v MessageType) MarshalText() ([]byte, error)
func (MessageType) String ¶
func (v MessageType) String() string
func (*MessageType) UnmarshalText ¶
func (v *MessageType) UnmarshalText(data []byte) (err error)
type TransactionType ¶
type TransactionType uint8
swagger:enum
const ( TRANSACTION_TYPE_UNKNOWN TransactionType = iota TRANSACTION_TYPE__COINBASE // 共识奖励交易 TRANSACTION_TYPE__TRANSFER // 普通转账交易 TRANSACTION_TYPE__DATA // 业务数据承载交易 )
交易类型
func ParseTransactionTypeFromLabelString ¶
func ParseTransactionTypeFromLabelString(s string) (TransactionType, error)
func ParseTransactionTypeFromString ¶
func ParseTransactionTypeFromString(s string) (TransactionType, error)
func (TransactionType) EnumType ¶
func (TransactionType) EnumType() string
func (TransactionType) Enums ¶
func (TransactionType) Enums() map[int][]string
func (TransactionType) Label ¶
func (v TransactionType) Label() string
func (TransactionType) MarshalText ¶
func (v TransactionType) MarshalText() ([]byte, error)
func (TransactionType) String ¶
func (v TransactionType) String() string
func (*TransactionType) UnmarshalText ¶
func (v *TransactionType) UnmarshalText(data []byte) (err error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.