cnct: do not persist stateless resolvers

Preparation for the anchor resolver which does not have persistent
state.
This commit is contained in:
Joost Jager 2020-03-10 15:07:14 +01:00
parent d2b6472843
commit 07a39b1ebf
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
2 changed files with 12 additions and 2 deletions

@ -372,6 +372,13 @@ func fetchContractWriteBucket(tx *bbolt.Tx, scopeKey []byte) (*bbolt.Bucket, err
func (b *boltArbitratorLog) writeResolver(contractBucket *bbolt.Bucket,
res ContractResolver) error {
// Only persist resolvers that are stateful. Stateless resolvers don't
// expose a resolver key.
resKey := res.ResolverKey()
if resKey == nil {
return nil
}
// First, we'll write to the buffer the type of this resolver. Using
// this byte, we can later properly deserialize the resolver properly.
var (
@ -400,8 +407,6 @@ func (b *boltArbitratorLog) writeResolver(contractBucket *bbolt.Bucket,
return err
}
resKey := res.ResolverKey()
return contractBucket.Put(resKey, buf.Bytes())
}

@ -83,6 +83,11 @@ func (b *mockArbitratorLog) InsertUnresolvedContracts(
b.Lock()
for _, resolver := range resolvers {
resKey := resolver.ResolverKey()
if resKey == nil {
continue
}
b.resolvers[resolver] = struct{}{}
}
b.Unlock()