MakePartSet returns a PartSet containing parts of a serialized block. This is the form in which the block is gossipped to peers. CONTRACT: partSize is greater than zero.
(partSize uint32)
| 138 | // This is the form in which the block is gossipped to peers. |
| 139 | // CONTRACT: partSize is greater than zero. |
| 140 | func (b *Block) MakePartSet(partSize uint32) *PartSet { |
| 141 | if b == nil { |
| 142 | return nil |
| 143 | } |
| 144 | b.mtx.Lock() |
| 145 | defer b.mtx.Unlock() |
| 146 | |
| 147 | pbb, err := b.ToProto() |
| 148 | if err != nil { |
| 149 | panic(err) |
| 150 | } |
| 151 | bz, err := proto.Marshal(pbb) |
| 152 | if err != nil { |
| 153 | panic(err) |
| 154 | } |
| 155 | return NewPartSetFromData(bz, partSize) |
| 156 | } |
| 157 | |
| 158 | // HashesTo is a convenience function that checks if a block hashes to the given argument. |
| 159 | // Returns false if the block is nil or the hash is empty. |