Hash returns the object Hash, the hash is calculated on-the-fly the first time it's called, in all subsequent calls the same Hash is returned even if the type or the content have changed. The Hash is only generated if the size of the content is exactly the object size.
()
| 18 | // if the type or the content have changed. The Hash is only generated if the |
| 19 | // size of the content is exactly the object size. |
| 20 | func (o *MemoryObject) Hash() Hash { |
| 21 | if o.h == ZeroHash && int64(len(o.cont)) == o.sz { |
| 22 | o.h = ComputeHash(o.t, o.cont) |
| 23 | } |
| 24 | |
| 25 | return o.h |
| 26 | } |
| 27 | |
| 28 | // Type returns the ObjectType |
| 29 | func (o *MemoryObject) Type() ObjectType { return o.t } |