@ -10,6 +10,7 @@ import (
"bytes"
"bytes"
"errors"
"errors"
"fmt"
"fmt"
"log"
"os"
"os"
"sort"
"sort"
@ -556,6 +557,8 @@ func Bootstrap(storage Chonk, bootstrap AUM) (*Authority, error) {
// Everything looks good, write it to storage.
// Everything looks good, write it to storage.
if err := storage . CommitVerifiedAUMs ( [ ] AUM { bootstrap } ) ; err != nil {
if err := storage . CommitVerifiedAUMs ( [ ] AUM { bootstrap } ) ; err != nil {
return nil , fmt . Errorf ( "commit: %v" , err )
return nil , fmt . Errorf ( "commit: %v" , err )
} else {
log . Printf ( "tka.Bootstrap: successfully committed bootstrap AUM (%s)" , bootstrap . Hash ( ) )
}
}
if err := storage . SetLastActiveAncestor ( bootstrap . Hash ( ) ) ; err != nil {
if err := storage . SetLastActiveAncestor ( bootstrap . Hash ( ) ) ; err != nil {
return nil , fmt . Errorf ( "set ancestor: %v" , err )
return nil , fmt . Errorf ( "set ancestor: %v" , err )
@ -587,6 +590,7 @@ func (a *Authority) InformIdempotent(storage Chonk, updates []AUM) (Authority, e
}
}
stateAt := make ( map [ AUMHash ] State , len ( updates ) + 1 )
stateAt := make ( map [ AUMHash ] State , len ( updates ) + 1 )
toCommit := make ( [ ] AUM , 0 , len ( updates ) )
toCommit := make ( [ ] AUM , 0 , len ( updates ) )
toCommitHashes := make ( [ ] AUMHash , 0 , len ( updates ) )
prevHash := a . Head ( )
prevHash := a . Head ( )
// The state at HEAD is the current state of the authority. It's likely
// The state at HEAD is the current state of the authority. It's likely
@ -636,10 +640,13 @@ func (a *Authority) InformIdempotent(storage Chonk, updates []AUM) (Authority, e
}
}
prevHash = hash
prevHash = hash
toCommit = append ( toCommit , update )
toCommit = append ( toCommit , update )
toCommitHashes = append ( toCommitHashes , update . Hash ( ) )
}
}
if err := storage . CommitVerifiedAUMs ( toCommit ) ; err != nil {
if err := storage . CommitVerifiedAUMs ( toCommit ) ; err != nil {
return Authority { } , fmt . Errorf ( "commit: %v" , err )
return Authority { } , fmt . Errorf ( "commit: %v" , err )
} else {
log . Printf ( "tka.CommitVerifiedAUMs: successfully committed %d AUMs: %v" , len ( toCommit ) , toCommitHashes )
}
}
if isHeadChain {
if isHeadChain {