Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PostLoaderConfig = dataloader.PostLoaderConfig{ Wait: 2 * time.Millisecond, MaxBatch: 100, Fetch: func(txHashStrings []string) ([]*model.Post, []error) { var posts = make([]*model.Post, len(txHashStrings)) var errors = make([]error, len(txHashStrings)) for i, txHashString := range txHashStrings { txHash, err := chainhash.NewHashFromStr(txHashString) if err != nil { errors[i] = jerr.Get("error getting tx hash from string", err) continue } memoPost, err := memo.GetPost(*txHash) if err != nil && !client.IsEntryNotFoundError(err) { errors[i] = jerr.Get("error getting lock memo post", err) continue } if memoPost == nil { errors[i] = jerr.Getf(postNotFoundError, "error post not found: "+txHashString) continue } posts[i] = &model.Post{ TxHash: txHash.String(), Address: wallet.Addr(memoPost.Addr).String(), Text: memoPost.Post, } } return posts, errors }, }
View Source
var ProfileLoaderConfig = dataloader.ProfileLoaderConfig{ Wait: 2 * time.Millisecond, MaxBatch: 100, Fetch: func(addressStrings []string) ([]*model.Profile, []error) { var profiles = make([]*model.Profile, len(addressStrings)) var errors = make([]error, len(addressStrings)) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() for i, addressString := range addressStrings { addr, err := wallet.GetAddrFromString(addressString) if err != nil { errors[i] = jerr.Get("error getting address from string", err) continue } addrString := addr.String() var profile = &model.Profile{Address: addrString} addrMemoName, err := memo.GetAddrName(ctx, *addr) if err != nil && !client.IsEntryNotFoundError(err) { errors[i] = jerr.Get("error getting memo name", err) continue } if addrMemoName != nil { profile.Name = &model.SetName{ TxHash: chainhash.Hash(addrMemoName.TxHash).String(), Name: addrMemoName.Name, Address: addrString, } } addrMemoProfile, err := memo.GetAddrProfile(ctx, *addr) if err != nil && !client.IsEntryNotFoundError(err) { errors[i] = jerr.Get("error getting addr memo profile", err) continue } if addrMemoProfile != nil { profile.Profile = &model.SetProfile{ TxHash: chainhash.Hash(addrMemoProfile.TxHash).String(), Text: addrMemoProfile.Profile, Address: addrString, } } addrMemoProfilePic, err := memo.GetAddrProfilePic(ctx, *addr) if err != nil && !client.IsEntryNotFoundError(err) { errors[i] = jerr.Get("error getting addr memo profile pic", err) continue } if addrMemoProfilePic != nil { profile.Pic = &model.SetPic{ TxHash: chainhash.Hash(addrMemoProfilePic.TxHash).String(), Address: addrString, Pic: addrMemoProfilePic.Pic, } } profiles[i] = profile } return profiles, errors }, }
Functions ¶
func IsPostNotFoundError ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.