Пример #1
0
func (n *NetworkConnection) AddBlock(block libytc.Block) {
	msg := new(MessageFormat)
	msg.Type = "Block"
	msg.Payload = n.s.EncodeBlock(block)
	msg.Chain = block.Chain()
	n.outbound.Encode(msg)
}
Пример #2
0
func (g GFCEncoder) EncodeBlock(block libytc.Block) (out []byte) {
	b := new(EncodedGFCBlock)
	b.Revision = block.Revision()
	for _, v := range block.(*GFCBlock).updates {
		b.Blocks = append(b.Blocks, g.EncodeUpdate(v))
	}

	out, err := json.Marshal(b)
	if err != nil {
		log.Fatal(err)
	}
	return
}
Пример #3
0
func (s *Server) EncodeBlock(block libytc.Block) []byte {
	return s.encoder[block.Chain()].EncodeBlock(block)
}