// unmarshalFact decodes a fact from it's binary representation. The domain and // transaction ID are passed in since they are not encoded with the fact itself. // This is because facts are stored relative to a domain and a transaction. func unmarshalFact(m *ProtoFact, b []byte, d string, t uint64, f *origins.Fact) error { m.Reset() if err := proto.Unmarshal(b, m); err != nil { return err } f.Domain = d f.Transaction = t f.Entity = &origins.Ident{ Domain: m.GetEntityDomain(), Name: m.GetEntity(), } f.Attribute = &origins.Ident{ Domain: m.GetAttributeDomain(), Name: m.GetAttribute(), } f.Value = &origins.Ident{ Domain: m.GetValueDomain(), Name: m.GetValue(), } f.Time = chrono.MicroTime(m.GetTime()) if m.GetAdded() { f.Operation = origins.Assertion } else { f.Operation = origins.Retraction } return nil }