github.com/linapex/ethereum-go-chinese@v0.0.0-20190316121929-f8b7a73c3fa1/whisper/whisperv6/doc.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 19:16:46</date> 10 //</624450125208489984> 11 12 13 /* 14 软件包Whisper实现了Whisper协议(版本6)。 15 16 Whisper结合了DHTS和数据报消息系统(如UDP)的各个方面。 17 因此,可以将其与两者进行比较,而不是与 18 物质/能量二元性(为明目张胆地滥用 19 基本而美丽的自然法则)。 20 21 Whisper是一个纯粹的基于身份的消息传递系统。低语提供了一个低层次 22 (非特定于应用程序)但不基于 23 或者受到低级硬件属性和特性的影响, 24 尤其是奇点的概念。 25 **/ 26 27 28 //包含耳语协议常量定义 29 30 package whisperv6 31 32 import ( 33 "time" 34 ) 35 36 //耳语协议参数 37 const ( 38 ProtocolVersion = uint64(6) //协议版本号 39 ProtocolVersionStr = "6.0" //与字符串相同 40 ProtocolName = "shh" //GETH中协议的昵称 41 42 //耳语协议消息代码,根据EIP-627 43 statusCode = 0 //由耳语协议使用 44 messagesCode = 1 //正常低语信息 45 powRequirementCode = 2 //战俘需求 46 bloomFilterExCode = 3 //布卢姆过滤器交换 47 p2pRequestCode = 126 //点对点消息,由DAPP协议使用 48 p2pMessageCode = 127 //对等消息(由对等方使用,但不再转发) 49 NumberOfMessageCodes = 128 50 51 SizeMask = byte(3) //用于从标志中提取有效负载大小字段大小的掩码 52 signatureFlag = byte(4) 53 54 TopicLength = 4 //以字节为单位 55 signatureLength = 65 //以字节为单位 56 aesKeyLength = 32 //以字节为单位 57 aesNonceLength = 12 //以字节为单位;有关详细信息,请参阅cipher.gcmstandardnonconsize&aesgcm.nonconsize()。 58 keyIDSize = 32 //以字节为单位 59 BloomFilterSize = 64 //以字节为单位 60 flagsLength = 1 61 62 EnvelopeHeaderLength = 20 63 64 MaxMessageSize = uint32(10 * 1024 * 1024) //邮件的最大可接受大小。 65 DefaultMaxMessageSize = uint32(1024 * 1024) 66 DefaultMinimumPoW = 0.2 67 68 padSizeLimit = 256 //只是一个任意数字,可以在不破坏协议的情况下进行更改 69 messageQueueLimit = 1024 70 71 expirationCycle = time.Second 72 transmissionCycle = 300 * time.Millisecond 73 74 DefaultTTL = 50 //秒 75 DefaultSyncAllowance = 10 //秒 76 ) 77 78 //mail server表示一个邮件服务器,能够 79 //存档旧邮件以供后续传递 80 //对同龄人。任何实施都必须确保 81 //函数是线程安全的。而且,他们必须尽快返回。 82 //delivermail应使用directmessagescode进行传递, 83 //以绕过到期检查。 84 type MailServer interface { 85 Archive(env *Envelope) 86 DeliverMail(whisperPeer *Peer, request *Envelope) 87 } 88