Example #1
0
File: vars.go Project: nictuku/bitz
// init initializes package variables and constants.
func init() {
	// Flip the byte order for BitMessage, which is different than BitCoin.
	encVarint.ByteOrder = binary.BigEndian
	buf := new(bytes.Buffer)
	// Don't attract attention to this client just yet, use the vanilla client
	// user agent.
	// encVarstring.WriteVarString(userAgent, "/bitz:1/")
	encVarstring.WriteVarString(buf, "/PyBitmessage:0.2.8/")
	userAgent = buf.Bytes()

	buf = new(bytes.Buffer)
	putVarIntList(buf, []uint64{streamOne})
	streamNumbers = buf.Bytes()

	// TODO: rotate the nonce numbers. A package variable isn't a good place
	// to keep this because it would be racy. Move it to the server.
	err := binary.Read(rand.Reader, binary.LittleEndian, &nonce)
	if err != nil {
		nonce = uint64(time.Now().UnixNano())
	}
}
Example #2
0
func (this *DataWriter) WriteVarString(value string) error {
	i, err := varstring.WriteVarString(this.w, value)
	this.count += int64(i)
	return err
}