42 lines
547 B
Go
42 lines
547 B
Go
package p2p
|
|
|
|
import "blockchain/chain"
|
|
|
|
type Msg interface {
|
|
msg()
|
|
}
|
|
|
|
type BlockMsg struct {
|
|
Block *chain.Block
|
|
From Peer
|
|
}
|
|
|
|
type TxMsg struct {
|
|
Tx *chain.Transaction
|
|
From Peer
|
|
}
|
|
|
|
type GetBlocksMsg struct {
|
|
Height int
|
|
From Peer
|
|
}
|
|
|
|
type BlocksMsg struct {
|
|
Blocks []*chain.Block
|
|
}
|
|
|
|
type GetPeersMsg struct {
|
|
From Peer
|
|
}
|
|
|
|
type PeersMsg struct {
|
|
Peers []Peer
|
|
}
|
|
|
|
func (BlockMsg) msg() {}
|
|
func (TxMsg) msg() {}
|
|
func (GetBlocksMsg) msg() {}
|
|
func (BlocksMsg) msg() {}
|
|
func (GetPeersMsg) msg() {}
|
|
func (PeersMsg) msg() {}
|