Documentation ¶
Index ¶
- Constants
- func FormatDatagram(m Message, t *tea.TEA) (data []byte, err error)
- func NewWriterF(f func(writer *Writer)) []byte
- func OpenWriterF(f func(*Writer)) (b []byte, cl func())
- func PutBlock(b *Block)
- func PutPacket(p *Packet)
- func PutWriter(w *Writer)
- func RegisterProtocol(p Protocol) error
- func Verify(pubk, digest, signature []byte) bool
- type Block
- type KV
- type Me
- type Message
- type Packet
- type Peer
- type ProtoType
- type Protocol
- type Storage
- type Writer
- func (w *Writer) Bytes() []byte
- func (w *Writer) FillUInt16() (pos int)
- func (w *Writer) FillUInt32() (pos int)
- func (w *Writer) Grow(n int)
- func (w *Writer) Len() int
- func (w *Writer) Reset()
- func (w *Writer) String() string
- func (w *Writer) Write(b []byte) (n int, err error)
- func (w *Writer) WriteBool(b bool)
- func (w *Writer) WriteByte(b byte) error
- func (w *Writer) WriteHex(h string)
- func (w *Writer) WriteString(v string)
- func (w *Writer) WriteUInt16(v uint16)
- func (w *Writer) WriteUInt16At(pos int, v uint16)
- func (w *Writer) WriteUInt16LE(v uint16)
- func (w *Writer) WriteUInt32(v uint32)
- func (w *Writer) WriteUInt32At(pos int, v uint32)
- func (w *Writer) WriteUInt32LE(v uint32)
- func (w *Writer) WriteUInt64(v uint64)
- func (w *Writer) WriteUInt64LE(v uint64)
Constants ¶
View Source
const ( PROTOTYPE_KV = 1 PROTONAME_KV = "kv" )
View Source
const ( KV_OP_SET = iota KV_OP_DEL )
View Source
const ( PKTTYP_NIL = iota // raw data PKTTYP_GET // get value (a block) by key PKTTYP_SET // set value (a block) of key PKTTYP_DEL // del value (a block) of key PKTTYP_LST // list all peers PKTTYP_ERQ // echo request )
View Source
const ( PKT_HEAD_LEN = 1 + 1 + 16 PKT_DATA_LEN = 256 )
View Source
const PUB_KEY_TAIL = "㴁"
Variables ¶
This section is empty.
Functions ¶
func NewWriterF ¶
func OpenWriterF ¶
OpenWriterF must call func cl to close
func RegisterProtocol ¶
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block 区块链中的一块。 当有分支出现时,将选择 md5值最小的区块进行链接 其余区块将被丢弃,直到 在新的链的末尾重新发起 链接请求,重复比较过程
func ParseBlock ¶
type KV ¶
type Me ¶
type Me struct {
// contains filtered or unexported fields
}
func (*Me) PrivateKey ¶
type Packet ¶
type Packet struct { Dat []byte // an easy-to-use pointer of dat io.Reader io.ReaderFrom io.Writer io.WriterTo // contains filtered or unexported fields }
type ProtoType ¶
type ProtoType uint8
ProtoType is used to decide whether Protocol should be called when parsing Block.dat
type Protocol ¶
type Protocol interface { // take a wrapped data into self and consume it io.Writer // write data into buffer io.Reader // length of data that will be write by calling Read Len() int // protocol name fmt.Stringer // protocol type Type() ProtoType // new self instance New() Protocol }
Protocol wrap any data format into Block.dat
type Writer ¶
Writer 写入
func (*Writer) FillUInt16 ¶
func (*Writer) FillUInt32 ¶
func (*Writer) WriteString ¶
func (*Writer) WriteUInt16 ¶
func (*Writer) WriteUInt16At ¶
func (*Writer) WriteUInt16LE ¶
func (*Writer) WriteUInt32 ¶
func (*Writer) WriteUInt32At ¶
func (*Writer) WriteUInt32LE ¶
func (*Writer) WriteUInt64 ¶
func (*Writer) WriteUInt64LE ¶
Click to show internal directories.
Click to hide internal directories.