github.com/annchain/OG@v0.0.9/plugin/og/messages.go (about)

     1  package og
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/annchain/OG/common/hexutil"
     6  	general_message "github.com/annchain/OG/message"
     7  	"github.com/annchain/OG/ogcore/message"
     8  )
     9  
    10  //go:generate msgp
    11  
    12  var MessageTypeOg general_message.GeneralMessageType = 1
    13  
    14  //msgp:tuple GeneralMessageOg
    15  type GeneralMessageOg struct {
    16  	InnerMessageType message.OgMessageType
    17  	InnerMessage     []byte
    18  }
    19  
    20  func (g *GeneralMessageOg) GetType() general_message.GeneralMessageType {
    21  	return MessageTypeOg
    22  }
    23  
    24  func (g *GeneralMessageOg) GetBytes() []byte {
    25  	b, err := g.MarshalMsg(nil)
    26  	if err != nil {
    27  		panic(err)
    28  	}
    29  	return b
    30  }
    31  
    32  func (g *GeneralMessageOg) String() string {
    33  	return fmt.Sprintf("GeneralMessageOg %d len=%d %s", g.InnerMessageType, len(g.InnerMessage),
    34  		hexutil.Encode(g.InnerMessage))
    35  }