MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / MakePartSet

Method MakePartSet

types/block.go:140–156  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

138// This is the form in which the block is gossipped to peers.
139// CONTRACT: partSize is greater than zero.
140func (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.

Calls 5

ToProtoMethod · 0.95
NewPartSetFromDataFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65
MarshalMethod · 0.45